diff options
author | Martin Thomson <martin.thomson@gmail.com> | 2015-10-23 11:20:26 -0700 |
---|---|---|
committer | Martin Thomson <martin.thomson@gmail.com> | 2015-10-23 11:20:26 -0700 |
commit | 88afc2f3cf26632bbcc4262fe2b996e43936564b (patch) | |
tree | e7f110aeca5c1d4bc201eb5df4b94520ac813ebe /coreconf/Linux.mk | |
parent | 72fd67a3158eb5b8ed00061248ef856c74509fc7 (diff) | |
download | nss-hg-88afc2f3cf26632bbcc4262fe2b996e43936564b.tar.gz |
Bug 1216318 - Updates to -Werror configuration, r=kaieNSS_3_21_Beta3
Diffstat (limited to 'coreconf/Linux.mk')
-rw-r--r-- | coreconf/Linux.mk | 71 |
1 files changed, 46 insertions, 25 deletions
diff --git a/coreconf/Linux.mk b/coreconf/Linux.mk index ad0cc1240..b3b5e408d 100644 --- a/coreconf/Linux.mk +++ b/coreconf/Linux.mk @@ -143,36 +143,57 @@ endif OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -Wall -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR OS_LIBS = $(OS_PTHREAD) -ldl -lc +# This tests to see if enabling the warning is possible before +# setting an option to disable it. +disable_warning=$(shell $(CC) -x c -E -Werror -W$(1) /dev/null >/dev/null 2>&1 && echo -Wno-$(1)) + ifeq ($(COMPILER_TAG),_clang) -# -Qunused-arguments : clang objects to arguments that it doesn't understand -# and fixing this would require rearchitecture -# -Wno-parentheses-equality : because clang warns about macro expansions -OS_CFLAGS += -Qunused-arguments -Wno-parentheses-equality -ifdef BUILD_OPT -# clang is unable to handle glib's expansion of strcmp and similar for optimized -# builds, so ignore the resulting errors. -# See https://llvm.org/bugs/show_bug.cgi?id=20144 -OS_CFLAGS += -Wno-array-bounds -Wno-unevaluated-expression -endif -# Clang reports its version as an older gcc, but it's OK -NSS_HAS_GCC48 = true + # -Qunused-arguments : clang objects to arguments that it doesn't understand + # and fixing this would require rearchitecture + OS_CFLAGS += -Qunused-arguments + # -Wno-parentheses-equality : because clang warns about macro expansions + OS_CFLAGS += $(call disable_warning,parentheses-equality) + ifdef BUILD_OPT + # clang is unable to handle glib's expansion of strcmp and similar for optimized + # builds, so ignore the resulting errors. + # See https://llvm.org/bugs/show_bug.cgi?id=20144 + OS_CFLAGS += $(call disable_warning,array-bounds) + OS_CFLAGS += $(call disable_warning,unevaluated-expression) + endif endif -ifndef NSS_HAS_GCC48 -NSS_HAS_GCC48 := $(shell \ - [ `$(CC) -dumpversion | cut -f 1 -d . -` -eq 4 -a \ - `$(CC) -dumpversion | cut -f 2 -d . -` -ge 8 -o \ - `$(CC) -dumpversion | cut -f 1 -d . -` -ge 5 ] && \ - echo true || echo false) -export NSS_HAS_GCC48 +ifndef NSS_ENABLE_WERROR + ifneq ($(OS_TARGET),Android) + # Android lollipop generates the following warning: + # error: call to 'sprintf' declared with attribute warning: + # sprintf is often misused; please use snprintf [-Werror] + # So, just suppress -Werror entirely on Android + NSS_ENABLE_WERROR = 0 + $(warning !!! OS_TARGET is Android, disabling -Werror) + else + ifeq ($(COMPILER_TAG),_clang) + # Clang reports its version as an older gcc, but it's OK + NSS_ENABLE_WERROR = 1 + else + NSS_ENABLE_WERROR := $(shell \ + [ `$(CC) -dumpversion | cut -f 1 -d . -` -eq 4 -a \ + `$(CC) -dumpversion | cut -f 2 -d . -` -ge 8 -o \ + `$(CC) -dumpversion | cut -f 1 -d . -` -ge 5 ] && \ + echo 1 || echo 0) + ifneq ($(NSS_ENABLE_WERROR),1) + $(warning !!! Unable to find gcc 4.8 or greater, disabling -Werror) + endif + endif + endif + export NSS_ENABLE_WERROR endif -ifeq (true,$(NSS_HAS_GCC48)) -OS_CFLAGS += -Werror + +ifeq (1,$(NSS_ENABLE_WERROR)) + OS_CFLAGS += -Werror else -# Old versions of gcc (< 4.8) don't support #pragma diagnostic in functions. -# Use this to disable use of that #pragma and the warnings it suppresses. -OS_CFLAGS += -DNSS_NO_GCC48 -$(warning Unable to find gcc >= 4.8 disabling -Werror) + # Old versions of gcc (< 4.8) don't support #pragma diagnostic in functions. + # Use this to disable use of that #pragma and the warnings it suppresses. + OS_CFLAGS += -DNSS_NO_GCC48 endif ifdef USE_PTHREADS |