summaryrefslogtreecommitdiff
path: root/coreconf/Linux.mk
diff options
context:
space:
mode:
authorMartin Thomson <martin.thomson@gmail.com>2015-08-17 11:22:29 -0700
committerMartin Thomson <martin.thomson@gmail.com>2015-08-17 11:22:29 -0700
commitedfddd7b86ae3cc6b1b2440216d4b83cdd9f321b (patch)
tree243150dab7af42c35c08dd056ee854bad24a1bdd /coreconf/Linux.mk
parent03d2e2d3d9d618778194c3759dee4bc625310f55 (diff)
downloadnss-hg-edfddd7b86ae3cc6b1b2440216d4b83cdd9f321b.tar.gz
Bug 1182667 - Enable warnings as errors, r=rrelyea
Diffstat (limited to 'coreconf/Linux.mk')
-rw-r--r--coreconf/Linux.mk46
1 files changed, 45 insertions, 1 deletions
diff --git a/coreconf/Linux.mk b/coreconf/Linux.mk
index 177a3c874..bbb48ef3c 100644
--- a/coreconf/Linux.mk
+++ b/coreconf/Linux.mk
@@ -125,14 +125,58 @@ ifdef MOZ_DEBUG_SYMBOLS
endif
endif
+ifndef COMPILER_TAG
+COMPILER_TAG = _$(shell $(CC) -? 2>&1 >/dev/null | sed -e 's/:.*//;1q')
+CCC_COMPILER_TAG = _$(shell $(CCC) -? 2>&1 >/dev/null | sed -e 's/:.*//;1q')
+endif
ifeq ($(USE_PTHREADS),1)
OS_PTHREAD = -lpthread
endif
-OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -Wall -Werror-implicit-function-declaration -Wno-switch -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR
+OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -Wall -Werror -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR
OS_LIBS = $(OS_PTHREAD) -ldl -lc
+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
+endif
+
+# Check for the existence of gcc 4.8
+ifndef NSS_HAS_GCC48
+define GCC48_TEST =
+int main() {\n
+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8)\n
+ return 1;\n
+#else\n
+ return 0;\n
+#endif\n
+}\n
+endef
+TEST_GCC48 := /tmp/test_gcc48_$(shell echo $$$$)
+NSS_HAS_GCC48 := (,$(shell echo -e "$(GCC48_TEST)" > $(TEST_GCC48).c && \
+ $(CC) -o $(TEST_GCC48) $(TEST_GCC48).c && \
+ $(TEST_GCC48) && echo true || echo false; \
+ rm -f $(TEST_GCC48) $(TEST_GCC48).c))
+export NSS_HAS_GCC48
+endif
+
+ifeq (true,$(NSS_HAS_GCC48))
+# Old versions of gcc (< 4.8) don't support #pragma diagnostic in functions.
+# Here, we disable use of that #pragma and the warnings it suppresses.
+OS_CFLAGS += -DNSS_NO_GCC48 -Wno-unused-variable
+endif
+
ifdef USE_PTHREADS
DEFINES += -D_REENTRANT
endif