Merge branch 'fix/harden_empty_toolchain_output' into 'master'

fix: harden build against empty toolchain output

Closes IDFGH-17820

See merge request espressif/esp-idf!50136
This commit is contained in:
Frantisek Hrbata
2026-08-10 09:31:40 +02:00
7 changed files with 122 additions and 20 deletions

View File

@@ -4,11 +4,7 @@
idf_build_get_property(target IDF_TARGET)
if(NOT (${target} STREQUAL "linux" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE toolchain_name
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_QUIET)
__compiler_query(toolchain_name ${CMAKE_C_COMPILER} -dumpmachine)
check_expected_tool_version(${toolchain_name} ${CMAKE_C_COMPILER})
endif()

View File

@@ -7,20 +7,13 @@ endif()
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
# without '--target' option 'clang -dumpmachine' prints default target arch and it might be not Xtensa
# so use `-print-targets` option
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-targets
OUTPUT_VARIABLE dump_machine
)
__compiler_query(dump_machine ${CMAKE_C_COMPILER} -print-targets)
else()
execute_process(
COMMAND ${CMAKE_C_COMPILER} -dumpmachine
OUTPUT_VARIABLE dump_machine
OUTPUT_STRIP_TRAILING_WHITESPACE
)
__compiler_query(dump_machine ${CMAKE_C_COMPILER} -dumpmachine)
endif()
message(STATUS "Compiler supported targets: ${dump_machine}")
if(NOT (${CMAKE_SYSTEM_NAME} STREQUAL "Generic" AND ${dump_machine} MATCHES xtensa))
if(NOT ("${CMAKE_SYSTEM_NAME}" STREQUAL "Generic" AND "${dump_machine}" MATCHES "xtensa"))
# Sub-projects (e.g. ULP RISC-V on an xtensa target) may use a
# non-IDF toolchain provided by the parent build. Skip validation
# when a custom toolchain is explicitly declared.