From 3ae97ed06838a0395a7ffbfddbdefc14f4b40062 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Thu, 7 Aug 2025 08:22:59 +0200 Subject: [PATCH] feat(cmakev2/build): set LINKER_TYPE build property in __init_build_configuration Set the LINKER_TYPE build property. Different linkers may have varying options, so it's important to identify the linker type to configure the options correctly. Currently, LINKER_TYPE is used to set the appropriate linker options for linking the entire archive, which differs between the GNU and Apple linkers when building on the host. Signed-off-by: Frantisek Hrbata --- tools/cmakev2/build.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/cmakev2/build.cmake b/tools/cmakev2/build.cmake index c2a981af40a..3ca8da6b46a 100644 --- a/tools/cmakev2/build.cmake +++ b/tools/cmakev2/build.cmake @@ -575,6 +575,21 @@ function(__init_build_configuration) idf_build_set_property(ASM_COMPILE_OPTIONS "${asm_compile_options}" APPEND) idf_build_set_property(COMPILE_DEFINITIONS "${compile_definitions}" APPEND) idf_build_set_property(LINK_OPTIONS "${link_options}" APPEND) + + # Set the LINKER_TYPE build property. Different linkers may have varying + # options, so it's important to identify the linker type to configure the + # options correctly. Currently, LINKER_TYPE is used to set the appropriate + # linker options for linking the entire archive, which differs between the + # GNU and Apple linkers when building on the host. + if(CONFIG_IDF_TARGET_LINUX AND CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin") + # Compiling for the host, and the host is macOS, so the linker is Darwin LD. + # Note, when adding support for Clang and LLD based toolchain this check will + # need to be modified. + set(linker_type "Darwin") + else() + set(linker_type "GNU") + endif() + idf_build_set_property(LINKER_TYPE "${linker_type}") endfunction() #[[