cmake: update board and soc linker script handling
This commit updates the handling of board and SoC linker scripts. Several SoCs creates a linker.ld file which sole purpose is to include another arch common linker script, often with content like this: #include <arch>/linker.ld instead of 100+ SoC specific linker.ld files containing just a single include line of above structure, then this commit introduces two now CMake variables, BOARD_LINKER_SCRIPT and SOC_LINKER_SCRIPT. This allows the board and SoC CMake code to point directly to a common linker script instead of creating a dummy linker.ld file doing this. This removes the need for several dummy linker.ld file. Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
parent
85dd423468
commit
26b649ea53
3 changed files with 43 additions and 24 deletions
|
@ -484,30 +484,6 @@ if(CONFIG_USERSPACE)
|
|||
set(KOBJECT_LINKER_DEP kobject_linker)
|
||||
endif()
|
||||
|
||||
get_property(TOPT GLOBAL PROPERTY TOPT)
|
||||
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})
|
||||
if(NOT EXISTS ${LINKER_SCRIPT})
|
||||
set(LINKER_SCRIPT ${CONFIG_CUSTOM_LINKER_SCRIPT})
|
||||
assert_exists(CONFIG_CUSTOM_LINKER_SCRIPT)
|
||||
endif()
|
||||
else()
|
||||
# Try a board specific linker file
|
||||
set(LINKER_SCRIPT ${BOARD_DIR}/linker.ld)
|
||||
if(NOT EXISTS ${LINKER_SCRIPT})
|
||||
# If not available, try an SoC specific linker file
|
||||
set(LINKER_SCRIPT ${SOC_DIR}/${ARCH}/${SOC_PATH}/linker.ld)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${LINKER_SCRIPT})
|
||||
message(FATAL_ERROR "Could not find linker script: '${LINKER_SCRIPT}'. Corrupted configuration?")
|
||||
endif()
|
||||
|
||||
if(DEFINED BUILD_VERSION)
|
||||
set(build_version_argument "-DBUILD_VERSION=${BUILD_VERSION}")
|
||||
elseif(NOT ZEPHYR_GIT_INDEX)
|
||||
|
@ -976,6 +952,29 @@ set(CMAKE_C_COMPILE_FEATURES ${compile_features_${CSTD}} PARENT_SCOPE)
|
|||
# @Intent: Configure linker scripts, i.e. generate linker scripts with variables substituted
|
||||
toolchain_ld_configure_files()
|
||||
|
||||
get_property(TOPT GLOBAL PROPERTY TOPT)
|
||||
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})
|
||||
if(NOT EXISTS ${LINKER_SCRIPT})
|
||||
set(LINKER_SCRIPT ${CONFIG_CUSTOM_LINKER_SCRIPT})
|
||||
assert_exists(CONFIG_CUSTOM_LINKER_SCRIPT)
|
||||
endif()
|
||||
elseif(DEFINED BOARD_LINKER_SCRIPT)
|
||||
set(LINKER_SCRIPT ${BOARD_LINKER_SCRIPT})
|
||||
elseif(DEFINED SOC_LINKER_SCRIPT)
|
||||
set(LINKER_SCRIPT ${SOC_LINKER_SCRIPT})
|
||||
else()
|
||||
find_package(Deprecated COMPONENTS SEARCHED_LINKER_SCRIPT)
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS ${LINKER_SCRIPT})
|
||||
message(FATAL_ERROR "Could not find linker script: '${LINKER_SCRIPT}'. Corrupted configuration?")
|
||||
endif()
|
||||
|
||||
if(CONFIG_USERSPACE)
|
||||
set(APP_SMEM_ALIGNED_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem_aligned.ld")
|
||||
set(APP_SMEM_UNALIGNED_LD "${PROJECT_BINARY_DIR}/include/generated/app_smem_unaligned.ld")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue