Transition the linker flag for the toolchain_ld_base and toolchain_ld_cpp macros to linker flag properties. This work follows the toolchain abstraction started in PR#24851. toolchain_ld_base() was intended for base linker flags, but has slowly become a 'set-any-linker-flag-here' and thus having several `if(<check>)` or `<func>_ifdef(<check> ...)`. Move the check to the top-level Zephyr CMakeLists.txt file, so that it becomes cleaner which part is responsible for setting a value, and then move the actual value (the linker flag) definition to the linker flag property location. It also helps adding support for new linkers, as it becomes clearer which linker flags Zephyr always expects, for example `base` and `cpp_base`, as well as those settings which are targeting for a given purpose, such as linker sort alignment. It also makes it clearer when those are used, for example in top-level CMakeLists.txt with CONFIG_LINKER_SORT_BY_ALIGNMENT compared to this information being buried in a linker support macro. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
15 lines
683 B
CMake
15 lines
683 B
CMake
# The coverage linker flag is specific for clang.
|
|
if (CONFIG_COVERAGE_NATIVE_GCOV)
|
|
set_property(TARGET linker PROPERTY coverage --coverage)
|
|
elseif(CONFIG_COVERAGE_NATIVE_SOURCE)
|
|
set_property(TARGET linker PROPERTY coverage -fprofile-instr-generate -fcoverage-mapping)
|
|
endif()
|
|
|
|
# Extra warnings options for twister run
|
|
set_property(TARGET linker PROPERTY ld_extra_warning_options ${LINKERFLAGPREFIX},--fatal-warnings)
|
|
|
|
# GNU ld and LLVM lld complains when used with llvm/clang:
|
|
# error: section: init_array is not contiguous with other relro sections
|
|
#
|
|
# So do not create RELRO program header.
|
|
set_property(TARGET linker APPEND PROPERTY cpp_base ${LINKERFLAGPREFIX},-z,norelro)
|