From c6727d49b78d3e99c05337b6640f0aa34b434994 Mon Sep 17 00:00:00 2001 From: Aurelien Jarno Date: Mon, 26 Nov 2018 13:48:34 +0100 Subject: [PATCH] arch: ARM: set -mthumb, -mcpu, -mfpu and -mfloat-abi in linker flags Some toolchains are built with multilib enabled in order to provide multiple versions of the same library, optimized for different ABI or architecture. They require the the ABI/architecture/CPU selection options to be passed at linked time. This is important for example when linking with newlib. Signed-off-by: Aurelien Jarno --- CMakeLists.txt | 4 ++++ cmake/compiler/gcc.cmake | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8647e51faa8..49d294d7f4a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,10 @@ zephyr_compile_options( ) endif() +zephyr_ld_options( + ${TOOLCHAIN_LD_FLAGS} +) + if(NOT CONFIG_NATIVE_APPLICATION) zephyr_ld_options( -nostdlib diff --git a/cmake/compiler/gcc.cmake b/cmake/compiler/gcc.cmake index 2a8e501a712..63d51f061df 100644 --- a/cmake/compiler/gcc.cmake +++ b/cmake/compiler/gcc.cmake @@ -82,15 +82,22 @@ else() -mthumb -mcpu=${GCC_M_CPU} ) + list(APPEND TOOLCHAIN_LD_FLAGS + -mthumb + -mcpu=${GCC_M_CPU} + ) include(${ZEPHYR_BASE}/cmake/fpu-for-gcc-m-cpu.cmake) if(CONFIG_FLOAT) list(APPEND TOOLCHAIN_C_FLAGS -mfpu=${FPU_FOR_${GCC_M_CPU}}) + list(APPEND TOOLCHAIN_LD_FLAGS -mfpu=${FPU_FOR_${GCC_M_CPU}}) if (CONFIG_FP_SOFTABI) list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=softfp) + list(APPEND TOOLCHAIN_LD_FLAGS -mfloat-abi=softfp) elseif(CONFIG_FP_HARDABI) list(APPEND TOOLCHAIN_C_FLAGS -mfloat-abi=hard) + list(APPEND TOOLCHAIN_LD_FLAGS -mfloat-abi=hard) endif() endif() elseif("${ARCH}" STREQUAL "arc")