diff options
author | Martin Thomson <martin.thomson@gmail.com> | 2015-10-30 08:03:44 +0900 |
---|---|---|
committer | Martin Thomson <martin.thomson@gmail.com> | 2015-10-30 08:03:44 +0900 |
commit | 7c6171f8a06e9f6ac87d90fd7d5ca043b9a89a1c (patch) | |
tree | 790e19bc0d644af2bce23962e0515d461def5742 | |
parent | 8d8f4cceb3df8c15ed41f268b2eff4c72d9491a7 (diff) | |
download | nss-hg-7c6171f8a06e9f6ac87d90fd7d5ca043b9a89a1c.tar.gz |
Bug 1211568 - Improve performance of build, r=glandium
-rw-r--r-- | coreconf/Darwin.mk | 40 | ||||
-rw-r--r-- | coreconf/Linux.mk | 59 | ||||
-rw-r--r-- | coreconf/Werror.mk | 70 |
3 files changed, 75 insertions, 94 deletions
diff --git a/coreconf/Darwin.mk b/coreconf/Darwin.mk index 85af903ef..9c992289f 100644 --- a/coreconf/Darwin.mk +++ b/coreconf/Darwin.mk @@ -4,6 +4,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. include $(CORE_DEPTH)/coreconf/UNIX.mk +include $(CORE_DEPTH)/coreconf/Werror.mk DEFAULT_COMPILER = gcc @@ -81,44 +82,7 @@ endif # definitions so that the linker can catch multiply-defined symbols. # Also, common symbols are not allowed with Darwin dynamic libraries. -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) -Wall -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS) - -# 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)) - -COMPILER_NAME = $(shell $(CC) -? 2>&1 >/dev/null | sed -e 's/:.*//;1q') -ifeq ($(COMPILER_NAME),clang) - # -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) -endif - -ifndef NSS_ENABLE_WERROR - ifeq ($(COMPILER_NAME),clang) - 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 disabling -Werror) - endif - endif - export NSS_ENABLE_WERROR -endif - -ifeq ($(NSS_ENABLE_WERROR),1) - 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 -endif +OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(WARNING_CFLAGS) -fno-common -pipe -DDARWIN -DHAVE_STRERROR -DHAVE_BSD_FLOCK $(DARWIN_SDK_CFLAGS) ifdef BUILD_OPT ifeq (11,$(ALLOW_OPT_CODE_SIZE)$(OPT_CODE_SIZE)) diff --git a/coreconf/Linux.mk b/coreconf/Linux.mk index b3b5e408d..7a2411876 100644 --- a/coreconf/Linux.mk +++ b/coreconf/Linux.mk @@ -4,6 +4,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. include $(CORE_DEPTH)/coreconf/UNIX.mk +include $(CORE_DEPTH)/coreconf/Werror.mk # # The default implementation strategy for Linux is now pthreads @@ -132,70 +133,16 @@ 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') +COMPILER_TAG := _$(CC_NAME) endif ifeq ($(USE_PTHREADS),1) OS_PTHREAD = -lpthread endif -OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) -Wall -pipe -ffunction-sections -fdata-sections -DLINUX -Dlinux -DHAVE_STRERROR +OS_CFLAGS = $(DSO_CFLAGS) $(OS_REL_CFLAGS) $(ARCHFLAG) $(WARNING_CFLAGS) -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 - 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_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 (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 -endif - ifdef USE_PTHREADS DEFINES += -D_REENTRANT endif diff --git a/coreconf/Werror.mk b/coreconf/Werror.mk new file mode 100644 index 000000000..6e2588ceb --- /dev/null +++ b/coreconf/Werror.mk @@ -0,0 +1,70 @@ +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# This sets warning flags for unix-like operating systems. + +ifndef CC_NAME + CC_NAME := $(shell $(CC) -? 2>&1 >/dev/null | sed -e 's/:.*//;1q') + export CC_NAME +endif + +ifndef WARNING_CFLAGS + # 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)) + + WARNING_CFLAGS = -Wall + ifeq ($(CC_NAME),clang) + # -Qunused-arguments : clang objects to arguments that it doesn't understand + # and fixing this would require rearchitecture + WARNING_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 + WARNING_CFLAGS += $(call disable_warning,array-bounds) + WARNING_CFLAGS += $(call disable_warning,unevaluated-expression) + endif + endif # if clang + + ifndef NSS_ENABLE_WERROR + ifeq ($(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 ($(CC_NAME),clang) + # Clang reports its version as an older gcc, but it's OK + NSS_ENABLE_WERROR = 1 + else + CC_VERSION := $(subst ., ,$(shell $(CC) -dumpversion)) + ifneq (,$(filter 4.8 4.9,$(word 1,$(CC_VERSION)).$(word 2,$(CC_VERSION)))) + NSS_ENABLE_WERROR = 1 + endif + ifeq (,$(filter 0 1 2 3 4,$(word 1,$(CC_VERSION)))) + NSS_ENABLE_WERROR = 1 + endif + ifndef NSS_ENABLE_WERROR + $(warning Unable to find gcc 4.8 or greater, disabling -Werror) + NSS_ENABLE_WERROR = 0 + endif + endif + endif + endif #ndef NSS_ENABLE_WERROR + + ifeq ($(NSS_ENABLE_WERROR),1) + WARNING_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. + WARNING_CFLAGS += -DNSS_NO_GCC48 + endif + export WARNING_CFLAGS +endif # ndef WARNING_CFLAGS |