From e34ed7c8e28bdba6126dea7dae3d60b2a40c0dda Mon Sep 17 00:00:00 2001 From: Danny Oerndrup Date: Wed, 12 Jun 2019 14:56:46 +0200 Subject: [PATCH] cmake: Toolchain abstraction: Introducing macro toolchain_cc_nocommon The macro is intended to abstract the -fno-common compiler option which controls the placement of uninitialized global variables. The macro leaves it up to the toolchain to define 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/clang/target.cmake | 1 + cmake/compiler/gcc/target.cmake | 1 + cmake/compiler/gcc/target_base.cmake | 14 ++++++++++++++ cmake/compiler/host-gcc/target.cmake | 1 + cmake/compiler/xcc/target.cmake | 1 + 6 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 cmake/compiler/gcc/target_base.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index abf098085c7..069f4511c40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,9 +220,11 @@ toolchain_cc_imacros(${AUTOCONF_H}) # @Intent: Set compiler specific flag for bare metal freestanding option toolchain_cc_freestanding() +# @Intent: Set compiler specific flag for tentative definitions, no-common +toolchain_cc_nocommon() + zephyr_compile_options( -g # TODO: build configuration enough? - -fno-common ${TOOLCHAIN_C_FLAGS} ) diff --git a/cmake/compiler/clang/target.cmake b/cmake/compiler/clang/target.cmake index b20d4075a3f..2fd15bf177a 100644 --- a/cmake/compiler/clang/target.cmake +++ b/cmake/compiler/clang/target.cmake @@ -81,6 +81,7 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake) macro(toolchain_cc_security_fortify) # No op, clang doesn't understand fortify at all diff --git a/cmake/compiler/gcc/target.cmake b/cmake/compiler/gcc/target.cmake index 926aa4c7fb1..991a49c0946 100644 --- a/cmake/compiler/gcc/target.cmake +++ b/cmake/compiler/gcc/target.cmake @@ -141,3 +141,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_asm.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_baremetal.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_imacros.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_base.cmake) diff --git a/cmake/compiler/gcc/target_base.cmake b/cmake/compiler/gcc/target_base.cmake new file mode 100644 index 00000000000..39146c40db6 --- /dev/null +++ b/cmake/compiler/gcc/target_base.cmake @@ -0,0 +1,14 @@ +# SPDX-License-Identifier: Apache-2.0 + +# The intention with this file is, to have a common placeholder for macros +# which does not fit into any of the categories defined by the existing +# target_xxx.cmake files and which have a fairly high commonality between +# toolchains. +# +# See root CMakeLists.txt for description and expectations of this macro + +macro(toolchain_cc_nocommon) + + zephyr_compile_options(-fno-common) + +endmacro() diff --git a/cmake/compiler/host-gcc/target.cmake b/cmake/compiler/host-gcc/target.cmake index 220800571a3..9b653c4bb6e 100644 --- a/cmake/compiler/host-gcc/target.cmake +++ b/cmake/compiler/host-gcc/target.cmake @@ -90,3 +90,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake) diff --git a/cmake/compiler/xcc/target.cmake b/cmake/compiler/xcc/target.cmake index 137cff37fe0..3bb4a9e8a7e 100644 --- a/cmake/compiler/xcc/target.cmake +++ b/cmake/compiler/xcc/target.cmake @@ -84,3 +84,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_imacros.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_base.cmake)