cmake: Toolchain abstraction: use LINKER, introduce toolchain_ld_base

toolchain_ld_base() represents flags that are fundamental to linking or
otherwise does not belong in any further specified linker flag category.

No functional change expected.

This is motivated by the wish to abstract Zephyr's usage of toolchains,
permitting non-intrusive porting to other (commercial) toolchains.

Signed-off-by: Mark Ruvald Pedersen <mped@oticon.com>
This commit is contained in:
Mark Ruvald Pedersen 2019-04-25 15:46:11 +02:00 committed by Anas Nashif
parent 0cad53b5ce
commit 1f01325ee5
5 changed files with 25 additions and 6 deletions

View file

@ -221,9 +221,8 @@ zephyr_compile_options(
$<$<COMPILE_LANGUAGE:ASM>:-D_ASMLANGUAGE>
)
zephyr_ld_options(
${TOOLCHAIN_LD_FLAGS}
)
# @Intent: Set fundamental linker specific flags
toolchain_ld_base()
if(NOT CONFIG_NATIVE_APPLICATION)
zephyr_ld_options(

View file

@ -9,7 +9,6 @@ find_program(CMAKE_C_COMPILER ${CROSS_COMPILE}${CC} PATH ${TOOLCHAIN_HOME} NO_
find_program(CMAKE_OBJCOPY ${CROSS_COMPILE}objcopy PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_OBJDUMP ${CROSS_COMPILE}objdump PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_AS ${CROSS_COMPILE}as PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_LINKER ${CROSS_COMPILE}ld PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_AR ${CROSS_COMPILE}ar PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_RANLIB ${CROSS_COMPILE}ranlib PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
find_program(CMAKE_READELF ${CROSS_COMPILE}readelf PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)

View file

@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
find_program(CMAKE_LINKER ${CROSS_COMPILE}ld PATH ${TOOLCHAIN_HOME} NO_DEFAULT_PATH)
# Load toolchain_ld-family macros
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_base.cmake)

View file

@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0
# See root CMakeLists.txt for description and expectations of these macros
macro(toolchain_ld_base)
# TOOLCHAIN_LD_FLAGS comes from compiler/gcc/target.cmake
zephyr_ld_options(
${TOOLCHAIN_LD_FLAGS}
)
endmacro()

View file

@ -42,9 +42,12 @@ endif()
unset(CMAKE_C_COMPILER)
unset(CMAKE_C_COMPILER CACHE)
# Configure the toolchain based on what toolchain technology is used
# (gcc, host-gcc etc.)
# A toolchain consist of a compiler and a linker.
# In Zephyr, toolchains require a port under cmake/toolchain/.
# Each toolchain port must set COMPILER and LINKER.
# E.g. toolchain/llvm may pick {clang, ld} or {clang, lld}.
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target.cmake OPTIONAL)
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target.cmake OPTIONAL)
# Uniquely identify the toolchain wrt. it's capabilities.
#