From cb0fd451c2ef6b41b910f82d9d4ca1544cbcae81 Mon Sep 17 00:00:00 2001 From: Mark Ruvald Pedersen Date: Wed, 30 Jan 2019 21:48:25 +0100 Subject: [PATCH] cmake: Toolchain abstraction: Assembly Introduce toolchain_cc_asm macro to capture toolchain specific flags related to assembly. -D_ASMLANGUAGE is kept common for all, assuming -D as define flag is supported by all compilers (which is almost the case). No functional change expected. Clang's flags are compatible with gcc, and are thus inherited. This is motivated by the wish to abstract Zephyr's usage of toolchains, permitting easier porting to other (commercial) toolchains. Signed-off-by: Mark Ruvald Pedersen --- CMakeLists.txt | 8 +++++++- cmake/compiler/clang/target.cmake | 1 + cmake/compiler/gcc/target.cmake | 1 + cmake/compiler/gcc/target_asm.cmake | 6 ++++++ cmake/compiler/host-gcc/target.cmake | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 cmake/compiler/gcc/target_asm.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 4cc238a5190..da0fccb0151 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -205,8 +205,14 @@ zephyr_compile_options( ${TOOLCHAIN_C_FLAGS} ) +# @Intent: Obtain compiler specific flags related to assembly +toolchain_cc_asm_base_flags(ASM_BASE_FLAG) +zephyr_compile_options( + $<$:${ASM_BASE_FLAG}> +) + +# Common toolchain-agnostic assembly flags zephyr_compile_options( - $<$:-xassembler-with-cpp> $<$:-D_ASMLANGUAGE> ) diff --git a/cmake/compiler/clang/target.cmake b/cmake/compiler/clang/target.cmake index fd02fb4539c..4cafe015c52 100644 --- a/cmake/compiler/clang/target.cmake +++ b/cmake/compiler/clang/target.cmake @@ -58,3 +58,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_fortify.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_canaries.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_cpp.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake) diff --git a/cmake/compiler/gcc/target.cmake b/cmake/compiler/gcc/target.cmake index 037e66a7c55..0db94fbe1c9 100644 --- a/cmake/compiler/gcc/target.cmake +++ b/cmake/compiler/gcc/target.cmake @@ -143,3 +143,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_security_fortify.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_security_canaries.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_optimizations.cmake) include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_cpp.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_asm.cmake) diff --git a/cmake/compiler/gcc/target_asm.cmake b/cmake/compiler/gcc/target_asm.cmake new file mode 100644 index 00000000000..c942d37b03e --- /dev/null +++ b/cmake/compiler/gcc/target_asm.cmake @@ -0,0 +1,6 @@ +# See root CMakeLists.txt for description and expectations of this macro + +macro(toolchain_cc_asm_base_flags dest_var_name) + # Specify assembly as the source language for the preprocessor to expect + set_ifndef(${dest_var_name} "-xassembler-with-cpp") +endmacro() diff --git a/cmake/compiler/host-gcc/target.cmake b/cmake/compiler/host-gcc/target.cmake index bc318e0e800..004fd5c9692 100644 --- a/cmake/compiler/host-gcc/target.cmake +++ b/cmake/compiler/host-gcc/target.cmake @@ -81,3 +81,4 @@ include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_fortify.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_security_canaries.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_optimizations.cmake) include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_cpp.cmake) +include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_asm.cmake)