diff --git a/build/jam/ArchitectureRules b/build/jam/ArchitectureRules index 5a838867d7..4bfb17d9a9 100644 --- a/build/jam/ArchitectureRules +++ b/build/jam/ArchitectureRules @@ -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 = arch_debug_console.o ; TARGET_WARNING_C++FLAGS_$(architecture) on $(file) diff --git a/build/jam/BuildSetup b/build/jam/BuildSetup index a435ee5c43..fa72d75516 100644 --- a/build/jam/BuildSetup +++ b/build/jam/BuildSetup @@ -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 diff --git a/build/jam/MainBuildRules b/build/jam/MainBuildRules index 5a84d5e285..ba9822077e 100644 --- a/build/jam/MainBuildRules +++ b/build/jam/MainBuildRules @@ -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 diff --git a/build/jam/OverriddenJamRules b/build/jam/OverriddenJamRules index 50ef8ef05a..8a11b6b844 100644 --- a/build/jam/OverriddenJamRules +++ b/build/jam/OverriddenJamRules @@ -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