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>
This commit is contained in:
Mark Ruvald Pedersen 2019-04-25 16:31:30 +02:00 committed by Anas Nashif
commit 65f02c04d5
3 changed files with 18 additions and 12 deletions

View file

@ -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

View file

@ -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)

View file

@ -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()