Skip to content
Permalink
Browse files

cmake: Toolchain abstraction: introduce toolchain_ld_baremetal()

The intent of toolchain_ld_baremetal() is to collect the flags belonging
to non-hosted (i.e. POSIX-based) targets.

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 4080818 commit 65f02c04d5e0893f66010158de49303113c6ff76
Showing with 18 additions and 12 deletions.
  1. +2 −12 CMakeLists.txt
  2. +1 −0 cmake/linker/ld/target.cmake
  3. +15 −0 cmake/linker/ld/target_baremetal.cmake
@@ -225,11 +225,8 @@ zephyr_compile_options(
toolchain_ld_base()

if(NOT CONFIG_NATIVE_APPLICATION)
zephyr_ld_options(
-nostdlib
-static
-no-pie
)
# @Intent: Set linker specific flags for bare metal target
toolchain_ld_baremetal()
endif()

if(CONFIG_LIB_CPLUSPLUS)
@@ -379,13 +376,6 @@ if(CONFIG_USERSPACE)
endif()
endif()

if(NOT CONFIG_NATIVE_APPLICATION)
zephyr_ld_options(
${LINKERFLAGPREFIX},-X
${LINKERFLAGPREFIX},-N
)
endif()

zephyr_ld_options(
${LINKERFLAGPREFIX},--gc-sections
${LINKERFLAGPREFIX},--build-id=none
@@ -6,3 +6,4 @@ set_ifndef(LINKERFLAGPREFIX -Wl)

# Load toolchain_ld-family macros
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_base.cmake)
include(${ZEPHYR_BASE}/cmake/linker/${LINKER}/target_baremetal.cmake)
@@ -0,0 +1,15 @@
# SPDX-License-Identifier: Apache-2.0

# See root CMakeLists.txt for description and expectations of these macros

macro(toolchain_ld_baremetal)

zephyr_ld_options(
-nostdlib
-static
-no-pie
${LINKERFLAGPREFIX},-X
${LINKERFLAGPREFIX},-N
)

endmacro()

0 comments on commit 65f02c0

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