mirror of https://github.com/ARMmbed/mbed-os.git
CMake: Fix GCC_ARM pre-linking stage (#13575)
Make it generic for all targets. It was previously hardcoded for K64Fpull/13566/head
parent
1b576c3046
commit
47f61485b8
|
@ -75,21 +75,13 @@ endfunction()
|
||||||
# Specifies linker script used for linking `target`.
|
# Specifies linker script used for linking `target`.
|
||||||
#
|
#
|
||||||
function(mbed_set_mbed_target_linker_script target)
|
function(mbed_set_mbed_target_linker_script target)
|
||||||
get_property(mbed_target_startup GLOBAL PROPERTY MBED_TARGET_LINKER_FILE)
|
get_property(mbed_target_linker_script GLOBAL PROPERTY MBED_TARGET_LINKER_FILE)
|
||||||
|
mbed_generate_gcc_options_for_linker(${target} _linker_preprocess_definitions _linker_preprocess_options)
|
||||||
# TODO: @mbed-os-tools This pre-build commands should get details from target + profile.
|
|
||||||
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
if(MBED_TOOLCHAIN STREQUAL "GCC_ARM")
|
||||||
set(CMAKE_PRE_BUILD_COMMAND
|
set(CMAKE_PRE_BUILD_COMMAND
|
||||||
COMMAND "arm-none-eabi-cpp" -E -P
|
COMMAND "arm-none-eabi-cpp" -E -P
|
||||||
-Wl,--gc-sections -Wl,--wrap,main -Wl,--wrap,_malloc_r -Wl,--wrap,_free_r
|
${_linker_preprocess_options} ${_linker_preprocess_definitions}
|
||||||
-Wl,--wrap,_realloc_r -Wl,--wrap,_memalign_r -Wl,--wrap,_calloc_r
|
${mbed_target_linker_script} -o ${CMAKE_BINARY_DIR}/${target}.link_script.ld
|
||||||
-Wl,--wrap,exit -Wl,--wrap,atexit -Wl,-n
|
|
||||||
-mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=softfp
|
|
||||||
-DMBED_ROM_START=0x0 -DMBED_ROM_SIZE=0x100000 -DMBED_RAM_START=0x20000000
|
|
||||||
-DMBED_RAM_SIZE=0x30000 -DMBED_RAM1_START=0x1fff0000
|
|
||||||
-DMBED_RAM1_SIZE=0x10000 -DMBED_BOOT_STACK_SIZE=1024
|
|
||||||
-DXIP_ENABLE=0
|
|
||||||
${mbed_target_startup} -o ${CMAKE_BINARY_DIR}/${target}.link_script.ld
|
|
||||||
|
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
BYPRODUCTS "${CMAKE_BINARY_DIR}/${target}.link_script.ld"
|
BYPRODUCTS "${CMAKE_BINARY_DIR}/${target}.link_script.ld"
|
||||||
|
@ -98,7 +90,7 @@ function(mbed_set_mbed_target_linker_script target)
|
||||||
set(CMAKE_PRE_BUILD_COMMAND COMMAND "")
|
set(CMAKE_PRE_BUILD_COMMAND COMMAND "")
|
||||||
target_link_options(mbed-os
|
target_link_options(mbed-os
|
||||||
PUBLIC
|
PUBLIC
|
||||||
"--scatter=${mbed_target_startup}"
|
"--scatter=${mbed_target_linker_script}"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
|
|
|
@ -55,3 +55,23 @@ function(mbed_set_toolchain_options target)
|
||||||
${link_options}
|
${link_options}
|
||||||
)
|
)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# GCC ARM requires preprecessing linker script, execute generators to get definitions needed for
|
||||||
|
# this step - linker options and compile definitions
|
||||||
|
function(mbed_generate_gcc_options_for_linker target definitions_file linker_options_file)
|
||||||
|
set(_compile_definitions
|
||||||
|
"$<TARGET_PROPERTY:${target},COMPILE_DEFINITIONS>"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(_linker_options
|
||||||
|
"$<TARGET_PROPERTY:${target},LINK_OPTIONS>"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(_compile_definitions
|
||||||
|
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
|
||||||
|
)
|
||||||
|
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n")
|
||||||
|
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/linker_options.txt" CONTENT "${_linker_options}\n")
|
||||||
|
set(definitions_file @${CMAKE_BINARY_DIR}/compile_time_defs.txt)
|
||||||
|
set(linker_options_file @${CMAKE_BINARY_DIR}/linker_options.txt)
|
||||||
|
endfunction()
|
||||||
|
|
Loading…
Reference in New Issue