cmake/compiler: Add linker_script compiler property

This property specifies the flag used to pass the linker script filename
through the compiler front end tot he linker.

For clang, we use the general purpose linker-pass through -Wl flag with -T:
-Wl,-T as clang doesn't support -T.

For gcc, we use -T directly as this keeps the picolibc specs file from
inserting the picolibc linker script as well.

If the compiler doesn't specify a value, we continue to use -Wl,-T as
before.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2023-07-05 10:13:08 -07:00 committed by Carles Cufí
commit 424590f7d8
4 changed files with 12 additions and 2 deletions

View file

@ -485,8 +485,9 @@ if(CONFIG_USERSPACE)
endif()
get_property(TOPT GLOBAL PROPERTY TOPT)
set_ifndef( TOPT -Wl,-T) # clang doesn't pick -T for some reason and complains,
# while -Wl,-T works for both, gcc and clang
get_property(COMPILER_TOPT TARGET compiler PROPERTY linker_script)
set_ifndef( TOPT "${COMPILER_TOPT}")
set_ifndef( TOPT -Wl,-T) # Use this if the compiler driver doesn't set a value
if(CONFIG_HAVE_CUSTOM_LINKER_SCRIPT)
set(LINKER_SCRIPT ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT})