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
|
@ -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")
|
||||
|
|
|
@ -57,6 +57,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
|
|||
|
||||
zephyr_get_include_directories_for_lang(C current_includes)
|
||||
get_property(current_defines GLOBAL PROPERTY PROPERTY_LINKER_SCRIPT_DEFINES)
|
||||
cmake_path(GET SOC_LINKER_SCRIPT PARENT_PATH soc_linker_script_includes)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT ${linker_script_gen}
|
||||
|
@ -74,6 +75,7 @@ macro(configure_linker_script linker_script_gen linker_pass_define)
|
|||
-D_ASMLANGUAGE
|
||||
-imacros ${AUTOCONF_H}
|
||||
${current_includes}
|
||||
-I${soc_linker_script_includes}
|
||||
${current_defines}
|
||||
${template_script_defines}
|
||||
-E ${LINKER_SCRIPT}
|
||||
|
|
|
@ -131,5 +131,23 @@ if(NOT "${Deprecated_FIND_COMPONENTS}" STREQUAL "")
|
|||
"${Deprecated_FIND_COMPONENTS}")
|
||||
endif()
|
||||
|
||||
if("SEARCHED_LINKER_SCRIPT" IN_LIST Deprecated_FIND_COMPONENTS)
|
||||
# This code was deprecated after Zephyr v3.5.0
|
||||
list(REMOVE_ITEM Deprecated_FIND_COMPONENTS SEARCHED_LINKER_SCRIPT)
|
||||
|
||||
# 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()
|
||||
message(DEPRECATION
|
||||
"Pre-defined `linker.ld` script is deprecated. Please set "
|
||||
"BOARD_LINKER_SCRIPT or SOC_LINKER_SCRIPT to point to ${LINKER_SCRIPT} "
|
||||
"or one of the Zephyr provided common linker scripts for the ${ARCH} "
|
||||
"architecture."
|
||||
)
|
||||
endif()
|
||||
|
||||
set(Deprecated_FOUND True)
|
||||
set(DEPRECATED_FOUND True)
|
||||
|
|
Loading…
Reference in a new issue