Skip to content
Permalink
Browse files

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>
  • Loading branch information...
mped-oticon authored and nashif committed Apr 25, 2019
1 parent 0cad53b commit 1f01325ee53752aedcb62e38806d9be69bfa9010
@@ -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(
@@ -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)
@@ -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)
@@ -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()
@@ -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.
#

0 comments on commit 1f01325

Please sign in to comment.
You can’t perform that action at this time.