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:
+13
-17
@@ -125,6 +125,16 @@ rule ArchitectureSetup architecture
|
|||||||
-Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align
|
-Wno-ctor-dtor-privacy -Woverloaded-virtual -Wpointer-arith -Wcast-align
|
||||||
-Wsign-compare -Wno-multichar ;
|
-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
|
# debug flags
|
||||||
local debugFlags = -ggdb ;
|
local debugFlags = -ggdb ;
|
||||||
|
|
||||||
@@ -459,32 +469,18 @@ rule ArchitectureSetupWarnings architecture
|
|||||||
# we use #warning as placeholders for things to write...
|
# we use #warning as placeholders for things to write...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# enable -Werror for certain parts of the source tree
|
# 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) ;
|
HAIKU_WERROR_ARCH = $(architecture) ;
|
||||||
|
|
||||||
rule EnableWerror dirTokens : scope {
|
rule EnableWerror dirTokens : scope {
|
||||||
AppendToConfigVar TARGET_WARNING_CCFLAGS_$(HAIKU_WERROR_ARCH)
|
SetConfigVar WARNINGS : HAIKU_TOP $(dirTokens) : treatAsErrors
|
||||||
: HAIKU_TOP $(dirTokens)
|
: $(scope) ;
|
||||||
: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
|
|
||||||
AppendToConfigVar TARGET_WARNING_C++FLAGS_$(HAIKU_WERROR_ARCH)
|
|
||||||
: HAIKU_TOP $(dirTokens)
|
|
||||||
: -Werror $(HAIKU_WERRORFLAGS) : $(scope) ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
|
# Work-around for GCC 2 problem -- despite -Wno-multichar it reports
|
||||||
# multichar warnings in headers/private/kernel/debugger_keymaps.h included
|
# multichar warnings in headers/private/kernel/debugger_keymaps.h included
|
||||||
# by src/system/kernel/arch/x86/arch_debug_console.cpp.
|
# by src/system/kernel/arch/x86/arch_debug_console.cpp.
|
||||||
|
local gccVersion = $(HAIKU_GCC_VERSION_$(architecture)) ;
|
||||||
if $(gccVersion[1]) = 2 {
|
if $(gccVersion[1]) = 2 {
|
||||||
local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
|
local file = <src!system!kernel!arch!x86>arch_debug_console.o ;
|
||||||
TARGET_WARNING_C++FLAGS_$(architecture) on $(file)
|
TARGET_WARNING_C++FLAGS_$(architecture) on $(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_CCFLAGS = -Wall -Wno-trigraphs -Wmissing-prototypes ;
|
||||||
HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ;
|
HOST_KERNEL_WARNING_C++FLAGS = -Wall -Wno-trigraphs ;
|
||||||
|
|
||||||
|
HOST_WERROR_FLAGS = ;
|
||||||
|
|
||||||
# debug flags
|
# debug flags
|
||||||
local hostDebugFlags ;
|
local hostDebugFlags ;
|
||||||
switch $(HOST_PLATFORM) {
|
switch $(HOST_PLATFORM) {
|
||||||
@@ -671,7 +673,7 @@ local archDependentBuildVars =
|
|||||||
ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS
|
ARFLAGS ASFLAGS UNARFLAGS CPPFLAGS CCFLAGS C++FLAGS HDRS LDFLAGS
|
||||||
LINK LINKFLAGS
|
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
|
DEBUG_$(HAIKU_DEBUG_LEVELS)_CCFLAGS DEBUG_$(HAIKU_DEBUG_LEVELS)_C++FLAGS
|
||||||
|
|
||||||
|
|||||||
@@ -291,6 +291,9 @@ rule CreateAsmStructOffsetsHeader header : source
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(HOST_WARNING_C++FLAGS) ;
|
flags += $(HOST_WARNING_C++FLAGS) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror $(HOST_WERROR_FLAGS) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
@@ -311,6 +314,10 @@ rule CreateAsmStructOffsetsHeader header : source
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror
|
||||||
|
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
|
|||||||
@@ -282,6 +282,9 @@ rule Cc
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(HOST_WARNING_CCFLAGS) ;
|
flags += $(HOST_WARNING_CCFLAGS) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror $(HOST_WERROR_FLAGS) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
@@ -302,6 +305,10 @@ rule Cc
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
flags += $(TARGET_WARNING_CCFLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror
|
||||||
|
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
@@ -353,6 +360,9 @@ rule C++
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(HOST_WARNING_C++FLAGS) ;
|
flags += $(HOST_WARNING_C++FLAGS) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror $(HOST_WERROR_FLAGS) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
@@ -373,6 +383,10 @@ rule C++
|
|||||||
# warning flags
|
# warning flags
|
||||||
if $(WARNINGS) != 0 {
|
if $(WARNINGS) != 0 {
|
||||||
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
flags += $(TARGET_WARNING_C++FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
if $(WARNINGS) = treatAsErrors {
|
||||||
|
flags += -Werror
|
||||||
|
$(TARGET_WERROR_FLAGS_$(TARGET_PACKAGING_ARCH)) ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# debug and other flags
|
# debug and other flags
|
||||||
|
|||||||
Reference in New Issue
Block a user