Commit bdb229fa authored by Danny Oerndrup's avatar Danny Oerndrup Committed by Alberto Escolar
Browse files

cmake: Toolchain abstraction: Introduce toolchain_cc_warning_base



This is placeholder for base warning flags, common to most 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: default avatarDanny Oerndrup <daor@demant.com>
parent 8650b150
Loading
Loading
Loading
Loading
+3 −9
Original line number Diff line number Diff line
@@ -197,13 +197,8 @@ toolchain_cc_nostdinc()

zephyr_compile_options(
  -g # TODO: build configuration enough?
  -Wall
  -Wformat
  -Wformat-security
  -Wno-format-zero-length
  -imacros ${AUTOCONF_H}
  -ffreestanding
  -Wno-main
  -fno-common
  ${TOOLCHAIN_C_FLAGS}
)
@@ -232,6 +227,9 @@ if(CONFIG_LIB_CPLUSPLUS)
  toolchain_ld_cpp()
endif()

# @Intent Add the basic toolchain warning flags
toolchain_cc_warning_base()

# ==========================================================================
#
# cmake -DW=... settings
@@ -262,7 +260,6 @@ zephyr_cc_option(-fno-asynchronous-unwind-tables)
zephyr_cc_option(-fno-pie)
zephyr_cc_option(-fno-pic)
zephyr_cc_option(-fno-strict-overflow)
zephyr_cc_option(-Wno-pointer-sign)

if(CONFIG_OVERRIDE_FRAME_POINTER_DEFAULT)
  if(CONFIG_OMIT_FRAME_POINTER)
@@ -311,9 +308,6 @@ 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)

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

# 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
+17 −0
Original line number Diff line number Diff line
@@ -2,6 +2,23 @@

# See root CMakeLists.txt for description and expectations of these macros

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(