From 054c15eab33799f5959dc8f22974ee9deb009554 Mon Sep 17 00:00:00 2001 From: Sudeep Mohanty Date: Thu, 16 Apr 2026 16:19:28 +0200 Subject: [PATCH] fix(cmakev2): propagate IDF_TOOLCHAIN selection to sdkconfig generation In the cmakev2 build framework, the selected toolchain was not consistently propagated to sdkconfig generation. For clang builds, this produced a configuration that was incompatible with the clang toolchain and broke compilation. Ensure the toolchain selection is observed consistently so sdkconfig and component configuration reflect the intended toolchain for both GCC and clang builds. Made-with: Cursor --- tools/cmakev2/idf.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/cmakev2/idf.cmake b/tools/cmakev2/idf.cmake index 4287d8d4c9..e47bf6c601 100644 --- a/tools/cmakev2/idf.cmake +++ b/tools/cmakev2/idf.cmake @@ -317,6 +317,13 @@ function(__init_toolchain) idf_die("Toolchain file ${toolchain_file} not found") endif() + # IDF_TOOLCHAIN applies to Espressif targets only; on linux (host build) + # it must stay empty so Kconfig leaves both CONFIG_IDF_TOOLCHAIN_GCC and + # CONFIG_IDF_TOOLCHAIN_CLANG unset. + if(NOT "${idf_target}" STREQUAL "linux") + set(IDF_TOOLCHAIN "${toolchain}" CACHE STRING "IDF Build Toolchain Type" FORCE) + endif() + set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" PARENT_SCOPE) idf_build_set_property(IDF_TOOLCHAIN_FILE "${toolchain_file}") endfunction()