Skip to content
Permalink
Browse files

cmake: Toolchain abstraction: Introduce toolchain_cc_warning_extended

This is placeholder for extended warning flags, likely to change between
toolchains.

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 <daor@demant.com>
  • Loading branch information...
daor-oti authored and aescolar committed May 6, 2019
1 parent bdb229f commit cbbbdeaae52725f8fd4c35044f2694c9ecbb6831
@@ -251,6 +251,8 @@ if(W MATCHES "3")
toolchain_cc_warning_dw_3()
endif()

# @Intent Add extended, more specific, toolchain warning flags
toolchain_cc_warning_extended()

# Allow the user to inject options when calling cmake, e.g.
# 'cmake -DEXTRA_CFLAGS="-Werror -Wno-deprecated-declarations" ..'
@@ -274,29 +276,9 @@ zephyr_compile_options(${COMPILER_OPT_AS_LIST})

# TODO: Include arch compiler options at this point.

if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
zephyr_cc_option(
#FIXME: need to fix all of those
-Wno-sometimes-uninitialized
-Wno-shift-overflow
-Wno-missing-braces
-Wno-self-assign
-Wno-address-of-packed-member
-Wno-unused-function
-Wno-initializer-overrides
-Wno-section
-Wno-unknown-warning-option
-Wno-unused-variable
-Wno-format-invalid-specifier
-Wno-gnu
# comparison of unsigned expression < 0 is always false
-Wno-tautological-compare
)
else() # GCC assumed
zephyr_cc_option(
-Wno-unused-but-set-variable
-fno-reorder-functions
)
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang")
# GCC assumed
zephyr_cc_option(-fno-reorder-functions)

if(NOT ${ZEPHYR_TOOLCHAIN_VARIANT} STREQUAL "xcc")
zephyr_cc_option(-fno-defer-pop)
@@ -79,7 +79,7 @@ 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)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_baremetal.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/gcc/target_warnings.cmake)
include(${ZEPHYR_BASE}/cmake/compiler/${COMPILER}/target_warnings.cmake)

macro(toolchain_cc_security_fortify)
# No op, clang doesn't understand fortify at all
@@ -0,0 +1,96 @@
# SPDX-License-Identifier: Apache-2.0

# See root CMakeLists.txt for description and expectations of this macro

macro(toolchain_cc_warning_base)

zephyr_compile_options(
-Wall
-Wformat
-Wformat-security
-Wno-format-zero-length
-Wno-main
)

zephyr_cc_option(-Wno-pointer-sign)

# Prohibit void pointer arithmetic. Illegal in C99
zephyr_cc_option(-Wpointer-arith)

endmacro()

macro(toolchain_cc_warning_dw_1)

zephyr_compile_options(
-Wextra
-Wunused
-Wno-unused-parameter
-Wmissing-declarations
-Wmissing-format-attribute
-Wold-style-definition
)
zephyr_cc_option(
-Wmissing-prototypes
-Wmissing-include-dirs
-Wunused-but-set-variable
-Wno-missing-field-initializers
)

endmacro()

macro(toolchain_cc_warning_dw_2)

zephyr_compile_options(
-Waggregate-return
-Wcast-align
-Wdisabled-optimization
-Wnested-externs
-Wshadow
)
zephyr_cc_option(
-Wlogical-op
-Wmissing-field-initializers
)

endmacro()

macro(toolchain_cc_warning_dw_3)

zephyr_compile_options(
-Wbad-function-cast
-Wcast-qual
-Wconversion
-Wpacked
-Wpadded
-Wpointer-arith
-Wredundant-decls
-Wswitch-default
)
zephyr_cc_option(
-Wpacked-bitfield-compat
-Wvla
)

endmacro()

macro(toolchain_cc_warning_extended)

zephyr_cc_option(
#FIXME: need to fix all of those
-Wno-sometimes-uninitialized
-Wno-shift-overflow
-Wno-missing-braces
-Wno-self-assign
-Wno-address-of-packed-member
-Wno-unused-function
-Wno-initializer-overrides
-Wno-section
-Wno-unknown-warning-option
-Wno-unused-variable
-Wno-format-invalid-specifier
-Wno-gnu
# comparison of unsigned expression < 0 is always false
-Wno-tautological-compare
)

endmacro()
@@ -72,3 +72,11 @@ macro(toolchain_cc_warning_dw_3)
)

endmacro()

macro(toolchain_cc_warning_extended)

zephyr_cc_option(
-Wno-unused-but-set-variable
)

endmacro()

0 comments on commit cbbbdea

Please sign in to comment.
You can’t perform that action at this time.