From cc77132214314039ac2c14db1e73b8859d26e690 Mon Sep 17 00:00:00 2001 From: Keith Short Date: Wed, 19 Apr 2023 16:17:47 -0600 Subject: zephyr: Honor warnings as errors config for tests The clang compiler flags were unconditionally enabling errors for several warnings classes. Only enable these errors when the CONFIG_COMPILER_WARNINGS_AS_ERRORS option is enabled. BUG=none BRANCH=none TEST=./twister -W Change-Id: I2530a8af9aa51e12b5ae6d0e3d68b4963ecf82a1 Signed-off-by: Keith Short Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4451651 Reviewed-by: Yuval Peress --- zephyr/cmake/compiler/clang/compiler_flags.cmake | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/zephyr/cmake/compiler/clang/compiler_flags.cmake b/zephyr/cmake/compiler/clang/compiler_flags.cmake index f24e1f1f4c..2fffd4b755 100644 --- a/zephyr/cmake/compiler/clang/compiler_flags.cmake +++ b/zephyr/cmake/compiler/clang/compiler_flags.cmake @@ -9,18 +9,20 @@ set_compiler_property(PROPERTY hosted) # Disable position independent code. if ("${ARCH}" STREQUAL "posix" OR "${ARCH}" STREQUAL "unit_testing") - add_compile_options(-fPIC) + add_compile_options(-fPIC) else() - add_compile_options(-fno-PIC) + add_compile_options(-fno-PIC) endif() # When testing, look for stack smashing add_compile_option_ifdef(CONFIG_ZTEST -fstack-protector-all) -check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable - -Werror=unused-variable -Werror=missing-braces - -Werror=sometimes-uninitialized -Werror=unused-function - -Werror=array-bounds) +if(DEFINED CONFIG_COMPILER_WARNINGS_AS_ERRORS) + check_set_compiler_property(APPEND PROPERTY warning_extended -Wunused-variable + -Werror=unused-variable -Werror=missing-braces + -Werror=sometimes-uninitialized -Werror=unused-function + -Werror=array-bounds) +endif() # clang flags for coverage generation set_property(TARGET compiler PROPERTY coverage --coverage -fno-inline) -- cgit v1.2.1