Fix kernel -Werror support

The introduction of secondary arch support for kernel files disabled
-Werror for all kernel files, since the -Werror flags were moved from
{CC,C++}FLAGS to TARGET_WARNING_{CC,C++}FLAGS_<arch>, which, however,
was overwritten by the SetupKernel rule. This commit introduces new
global variables {HAIKU,HOST,TARGET}_WERROR_FLAGS[_<arch>], which
contain the additional -Werror flags to be applied for the architecture.
The config variable WARNINGS can be set to "treatAsErrors" to cause
-Werror and {HOST,TARGET}_WERROR_FLAGS[_<arch>] to be appended to the
compilation flags.

Fixes #10280.
This commit is contained in:
Ingo Weinhold 2013-12-05 12:37:14 +01:00
parent 7b83ce1142
commit 724f4e2d38
4 changed files with 37 additions and 18 deletions

View File

@ -125,6 +125,16 @@ rule ArchitectureSetup architecture
-Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align
-Wsign-compare -Wno-multichar ;
HAIKU_WERROR_FLAGS_$(architecture) = ;
if $(gccVersion[1]) >= 4 {
# -Wuninitialized gives too many false positives.
HAIKU_WERROR_FLAGS_$(architecture) += -Wno-error=uninitialized ;
# TODO: remove the -Wno-unused-but-set-variable option
HAIKU_WERROR_FLAGS_$(architecture) += -Wno-unused-but-set-variable ;
}
# debug flags
local debugFlags = -ggdb ;
@ -459,32 +469,18 @@ rule ArchitectureSetupWarnings architecture
# we use #warning as placeholders for things to write...
}
# enable -Werror for certain parts of the source tree
HAIKU_WERRORFLAGS = ;
local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
if $(gccVersion[1]) >= 4 {
# -Wuninitialized gives too many false positives.
HAIKU_WERRORFLAGS = -Wno-error=uninitialized ;
# TODO: remove the -Wno-unused-but-set-variable option
HAIKU_WERRORFLAGS += -Wno-unused-but-set-variable ;
}
HAIKU_WERROR_ARCH = $(architecture) ;
rule EnableWerror dirTokens : scope {
AppendToConfigVar TARGET_WARNING_CCFLAGS_$(HAIKU_WERROR_ARCH)
: HAIKU_TOP $(dirTokens)
: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
AppendToConfigVar TARGET_WARNING_C++FLAGS_$(HAIKU_WERROR_ARCH)
: HAIKU_TOP $(dirTokens)
: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors
: $(scope) ;
}
# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
# multichar warnings in headers/private/kernel/debugger_keymaps.h included
# by src/system/kernel/arch/x86/arch_debug_console.cpp.
local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
if $(gccVersion[1]) = 2 {
local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
TARGET_WARNING_C++FLAGS_$(architecture) on $(file)

View File

@ -366,6 +366,8 @@ HOST_WARNING_C++FLAGS = -Wall -Wno-trigraphs -Wno-ctor-dtor-privacy
HOST_KERNEL_WARNING_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ;
HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ;
HOST_WERROR_FLAGS = ;
# debug flags
local hostDebugFlags ;
switch $(HOST_PLATFORM) {
@ -671,7 +673,7 @@ local archDependentBuildVars =
ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS
LINK LINKFLAGS
WARNING_CCFLAGS WARNING_C++FLAGS
WARNING_CCFLAGS WARNING_C++FLAGS WERROR_FLAGS
DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS

View File

@ -291,6 +291,9 @@ rule CreateAsmStructOffsetsHeader header : source
# warning flags
if $(WARNINGS) != 0 {
flags += $(HOST_WARNING_C++FLAGS) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror $(HOST_WERROR_FLAGS) ;
}
}
# debug and other flags
@ -311,6 +314,10 @@ rule CreateAsmStructOffsetsHeader header : source
# warning flags
if $(WARNINGS) != 0 {
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
}
}
# debug and other flags

View File

@ -282,6 +282,9 @@ rule Cc
# warning flags
if $(WARNINGS) != 0 {
flags += $(HOST_WARNING_CCFLAGS) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror $(HOST_WERROR_FLAGS) ;
}
}
# debug and other flags
@ -302,6 +305,10 @@ rule Cc
# warning flags
if $(WARNINGS) != 0 {
flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
}
}
# debug and other flags
@ -353,6 +360,9 @@ rule C++
# warning flags
if $(WARNINGS) != 0 {
flags += $(HOST_WARNING_C++FLAGS) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror $(HOST_WERROR_FLAGS) ;
}
}
# debug and other flags
@ -373,6 +383,10 @@ rule C++
# warning flags
if $(WARNINGS) != 0 {
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
if $(WARNINGS) = treatAsErrors {
flags += -Werror
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
}
}
# debug and other flags