Skip to content

Commit 39276db

Browse files
committed
cmake: linker: separate toolchain_ld_options() calls for grouped flags
Fixes #91045 Adding NO_SPLIT in the TOOLCHAIN_LD_FLAGS list caused every flags in the list to be checked together by the linker. This caused issues where incompatible flags was passed together, and the result was that none was propagated to the linker. By using separate variables, we can achieve the initial goal of NO_SPLIT to only group a sub-set of flags. Signed-off-by: Pierrick Guillaume <pguillaume@fymyte.com>
1 parent 9caab5b commit 39276db

File tree

4 files changed

+10
-3
lines changed

4 files changed

+10
-3
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,12 @@ if(DEFINED TOOLCHAIN_LD_FLAGS)
403403
zephyr_ld_options(${TOOLCHAIN_LD_FLAGS})
404404
endif()
405405

406+
if(DEFINED TOOLCHAIN_GROUPED_LD_FLAGS)
407+
foreach(GROUPED_FLAGS IN LISTS TOOLCHAIN_GROUPED_LD_FLAGS)
408+
zephyr_ld_options(NO_SPLIT ${${GROUPED_FLAGS}})
409+
endforeach()
410+
endif()
411+
406412
zephyr_link_libraries(PROPERTY base)
407413

408414
zephyr_link_libraries_ifndef(CONFIG_LINKER_USE_RELAX PROPERTY no_relax)

cmake/compiler/clang/target_arm.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,4 @@ if(CONFIG_FP16)
3939
endif()
4040
endif()
4141
list(APPEND TOOLCHAIN_C_FLAGS ${ARM_C_FLAGS})
42-
list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT ${ARM_C_FLAGS})
42+
list(APPEND TOOLCHAIN_GROUPED_LD_FLAGS ARM_C_FLAGS)

cmake/compiler/gcc/target_arm.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ if(CONFIG_THREAD_LOCAL_STORAGE)
4545
endif()
4646

4747
list(APPEND TOOLCHAIN_C_FLAGS ${ARM_C_FLAGS})
48-
list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT ${ARM_C_FLAGS})
48+
list(APPEND TOOLCHAIN_GROUPED_LD_FLAGS ARM_C_FLAGS)
4949

5050
# Flags not supported by llext linker
5151
# (regexps are supported and match whole word)

cmake/compiler/gcc/target_riscv.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ if(CONFIG_RISCV_ISA_EXT_ZMMUL AND
8787
endif()
8888

8989
list(APPEND TOOLCHAIN_C_FLAGS -mabi=${riscv_mabi} -march=${riscv_march})
90-
list(APPEND TOOLCHAIN_LD_FLAGS NO_SPLIT -mabi=${riscv_mabi} -march=${riscv_march})
90+
list(APPEND RISCV_LD_FLAGS -mabi=${riscv_mabi} -march=${riscv_march})
91+
list(APPEND TOOLCHAIN_GROUPED_LD_FLAGS RISCV_LD_FLAGS)
9192

9293
# Flags not supported by llext linker
9394
# (regexps are supported and match whole word)

0 commit comments

Comments
 (0)