From 025ffa249246b27d95d8d5e76e676cb27704b980 Mon Sep 17 00:00:00 2001 From: Danny Oerndrup Date: Thu, 16 May 2019 12:58:40 +0200 Subject: [PATCH] cmake: Toolchain abstraction: Abstraction of implicit-int error flag Introducing the macro toolchain_cc_warning_error_implicit_int which, abstracts the implicit_int error flag thus leaving it to the toolchain to decide whether this flag is needed or not. 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 | 9 +++------ cmake/compiler/clang/target_warnings.cmake | 7 +++++++ cmake/compiler/gcc/target_warnings.cmake | 7 +++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 69805e4a62e..59f56ceb74e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -259,6 +259,9 @@ endif() # @Intent: Add extended, more specific, toolchain warning flags toolchain_cc_warning_extended() +# @Intent: Trigger an error when a declaration does not specify a type +toolchain_cc_warning_error_implicit_int() + # Allow the user to inject options when calling cmake, e.g. # 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..' include(cmake/extra_flags.cmake) @@ -292,9 +295,6 @@ endif() zephyr_cc_option_ifdef(CONFIG_STACK_USAGE -fstack-usage) -# Force an error when things like SYS_INIT(foo, ...) occur with a missing header. -zephyr_cc_option(-Werror=implicit-int) - # If the compiler supports it, strip the ${ZEPHYR_BASE} prefix from the # __FILE__ macro used in __ASSERT*, in the # .noinit."/home/joe/zephyr/fu/bar.c" section names and in any @@ -303,9 +303,6 @@ zephyr_cc_option(-Werror=implicit-int) # importantly makes builds more deterministic zephyr_cc_option(-fmacro-prefix-map=${ZEPHYR_BASE}=.) -# Prohibit date/time macros, which would make the build non-deterministic -# cc-option(-Werror=date-time) - # TODO: Archiver arguments # ar_option(D) diff --git a/cmake/compiler/clang/target_warnings.cmake b/cmake/compiler/clang/target_warnings.cmake index 129f7643f05..771726f5a96 100644 --- a/cmake/compiler/clang/target_warnings.cmake +++ b/cmake/compiler/clang/target_warnings.cmake @@ -95,6 +95,13 @@ macro(toolchain_cc_warning_extended) endmacro() +macro(toolchain_cc_warning_error_implicit_int) + + # Force an error when things like SYS_INIT(foo, ...) occur with a missing header + zephyr_cc_option(-Werror=implicit-int) + +endmacro() + # # The following macros leaves it up to the root CMakeLists.txt to choose # the variables in which to put the requested flags, and whether or not diff --git a/cmake/compiler/gcc/target_warnings.cmake b/cmake/compiler/gcc/target_warnings.cmake index 3152ded8121..a14233d0313 100644 --- a/cmake/compiler/gcc/target_warnings.cmake +++ b/cmake/compiler/gcc/target_warnings.cmake @@ -81,6 +81,13 @@ macro(toolchain_cc_warning_extended) endmacro() +macro(toolchain_cc_warning_error_implicit_int) + + # Force an error when things like SYS_INIT(foo, ...) occur with a missing header + zephyr_cc_option(-Werror=implicit-int) + +endmacro() + # # The following macros leaves it up to the root CMakeLists.txt to choose # the variables in which to put the requested flags, and whether or not