mirror of
https://github.com/espressif/esp-idf.git
synced 2026-04-27 19:13:21 +00:00
fix(cmakev2/idf): fix IDF_TOOLCHAIN build property for linux target
The IDF_TOOLCHAIN build property is currently incorrectly set to the default `gcc` value for the linux target, whereas it should be empty. This misconfiguration causes confusion for components like `soc`, which adjust toolchain options based on the IDF_TOOLCHAIN(CONFIG_IDF_TOOLCHAIN_GCC) build property's setting. When sdkconfig is generated, the IDF_TOOLCHAIN build property is passed as an environmental variable to kconfgen, and the CONFIG_IDF_TOOLCHAIN configuration option is set based on this variable. Additionally, the CONFIG_IDF_TOOLCHAIN_GCC and CONFIG_IDF_TOOLCHAIN_CLANG configuration options are set accordingly. Subsequently, CONFIG_IDF_TOOLCHAIN_GCC is used in several places, such as `components/soc/project_include.cmake`, to configure the toolchain (compiler flags) by invoking functions from `tools/cmake/toolchain_flags.cmake`, which is included only for non-linux targets. As a result the configuration fails, because functions from `tools/cmake/toolchain_flags.cmake` are not available on linux target. Since the IDF_TOOLCHAIN cmake cache variable is actually set in the `tools/cmake/toolchain.cmake` file, the IDF_TOOLCHAIN build property should be set after the toolchain is initialized in cmakev2's project initialization. Note that each toolchain file, except for linux, includes `toolchain.cmake`, which in turn includes `toolchain_flags.cmake`. This means the IDF_TOOLCHAIN cmake cache variable is set for every target except linux, because the toolchain file for linux is empty. As a result CONFIG_IDF_TOOLCHAIN is empty and CONFIG_IDF_TOOLCHAIN_GCC not set as for cmakev1. Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
This commit is contained in:
@@ -266,16 +266,15 @@ endfunction()
|
||||
#[[
|
||||
__init_toolchain()
|
||||
|
||||
Determine the IDF_TOOLCHAIN value from the IDF_TOOLCHAIN environment
|
||||
variable or the CMake cache variable. If none of these are set, use the
|
||||
default gcc toolchain. Ensure there are no inconsistencies in the
|
||||
IDF_TOOLCHAIN values set in different locations. Also ensure that the
|
||||
Determine the toolchain file, set IDF_TOOLCHAIN_FILE build property and
|
||||
global CMAKE_TOOLCHAIN_FILE CMake variable. Also ensure that the
|
||||
CMAKE_TOOLCHAIN_FILE is set to the correct file according to the current
|
||||
IDF_TARGET.
|
||||
|
||||
Set the IDF_TOOLCHAIN and IDF_TOOLCHAIN_FILE build properties. Also,
|
||||
configure the IDF_TOOLCHAIN CMake cache variable and set the
|
||||
CMAKE_TOOLCHAIN_FILE global variable.
|
||||
Note: The IDF_TOOLCHAIN build property is set after the toolchain
|
||||
configuration in ``idf_project_init``. The ``tools/cmake/toolchain.cmake``
|
||||
is included in the toolchain file and it sets the IDF_TOOLCHAIN variable in
|
||||
CMake's cache.
|
||||
#]]
|
||||
function(__init_toolchain)
|
||||
set(cache_toolchain $CACHE{IDF_TOOLCHAIN})
|
||||
@@ -318,9 +317,7 @@ function(__init_toolchain)
|
||||
idf_die("Toolchain file ${toolchain_file} not found")
|
||||
endif()
|
||||
|
||||
set(IDF_TOOLCHAIN ${toolchain} CACHE STRING "IDF Build Toolchain Type")
|
||||
set(CMAKE_TOOLCHAIN_FILE "${toolchain_file}" PARENT_SCOPE)
|
||||
idf_build_set_property(IDF_TOOLCHAIN "${toolchain}")
|
||||
idf_build_set_property(IDF_TOOLCHAIN_FILE "${toolchain_file}")
|
||||
endfunction()
|
||||
|
||||
|
||||
@@ -560,6 +560,11 @@ macro(idf_project_init)
|
||||
# Ensure this function is executed only once throughout the entire
|
||||
# project.
|
||||
|
||||
# The IDF_TOOLCHAIN variable is established as a CMake cache variable
|
||||
# during the toolchain initialization process in
|
||||
# ``tools/cmake/toolchain.cmake``.
|
||||
idf_build_set_property(IDF_TOOLCHAIN "${IDF_TOOLCHAIN}")
|
||||
|
||||
# Warn about the use of deprecated variables.
|
||||
deprecate_variable(COMPONENTS)
|
||||
deprecate_variable(EXCLUDE_COMPONENTS)
|
||||
|
||||
Reference in New Issue
Block a user