From faa72b7015ef9cf44a1c91b9af0810063ca6003f Mon Sep 17 00:00:00 2001 From: Danny Oerndrup Date: Tue, 11 Jun 2019 15:56:57 +0200 Subject: [PATCH] cmake: Toolchain abstraction: Introducing toolchain_cc_freestanding The macro is intended to abstract the -ffreestanding compiler option which tells the compiler that this is a bare metal env. The option is compiler and thus toolchain specific, but this macro leaves it up to the toolchain to decide the value of the option. The intent here is to abstract Zephyr's dependence on toolchains, thus allowing for easier porting to other, perhaps commercial, toolchains and/or usecases. No functional change expected. Signed-off-by: Danny Oerndrup --- CMakeLists.txt | 4 +++- cmake/compiler/gcc/target_baremetal.cmake | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5132e8e40a..96d1807b37f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -214,10 +214,12 @@ endif() # @Intent: Set compiler specific flags for standard C includes toolchain_cc_nostdinc() +# @Intent: Set compiler specific flag for bare metal freestanding option +toolchain_cc_freestanding() + zephyr_compile_options( -g # TODO: build configuration enough? -imacros ${AUTOCONF_H} - -ffreestanding -fno-common ${TOOLCHAIN_C_FLAGS} ) diff --git a/cmake/compiler/gcc/target_baremetal.cmake b/cmake/compiler/gcc/target_baremetal.cmake index d2686044350..41e6ce877a6 100644 --- a/cmake/compiler/gcc/target_baremetal.cmake +++ b/cmake/compiler/gcc/target_baremetal.cmake @@ -1,5 +1,6 @@ # SPDX-License-Identifier: Apache-2.0 +# See root CMakeLists.txt for description and expectations of these macros macro(toolchain_cc_nostdinc) @@ -11,3 +12,9 @@ macro(toolchain_cc_nostdinc) endif() endmacro() + +macro(toolchain_cc_freestanding) + + zephyr_compile_options(-ffreestanding) + +endmacro()