From a1d26e4177522ce1ffb54f569e22223e429d4f0f Mon Sep 17 00:00:00 2001 From: Chris Manchester Date: Wed, 25 Oct 2017 15:10:04 -0700 Subject: [PATCH] Bug 1403346 - Make a separate variable used to append pgo flags to compile command lines. r=glandium This commit establishes a separate variable to add PROFILE_GEN and PROFILE_USE CFLAGS to compile and link command lines. Currently the make backend orchestrates the pgo build steps and is the only thing aware of whether we're in the profile generate or profile use stage. The flags are separated here to allow other flags to be moved to mozbuild, but this will not yet sufficient to perform a PGO build independent of the make backend. MozReview-Commit-ID: IX30l2MvvNc --- config/config.mk | 10 ++++------ config/rules.mk | 4 ++-- js/src/old-configure.in | 8 ++++---- old-configure.in | 8 ++++---- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/config/config.mk b/config/config.mk index ffa08a8341e5..93d4ae9dbbf0 100644 --- a/config/config.mk +++ b/config/config.mk @@ -203,8 +203,7 @@ endif # Enable profile-based feedback ifneq (1,$(NO_PROFILE_GUIDED_OPTIMIZE)) ifdef MOZ_PROFILE_GENERATE -OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS)) -OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS)) +PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_GEN_CFLAGS)) OS_LDFLAGS += $(PROFILE_GEN_LDFLAGS) ifeq (WINNT,$(OS_ARCH)) AR_FLAGS += -LTCG @@ -212,8 +211,7 @@ endif endif # MOZ_PROFILE_GENERATE ifdef MOZ_PROFILE_USE -OS_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS)) -OS_CXXFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS)) +PGO_CFLAGS += $(if $(filter $(notdir $<),$(notdir $(NO_PROFILE_GUIDED_OPTIMIZE))),,$(PROFILE_USE_CFLAGS)) OS_LDFLAGS += $(PROFILE_USE_LDFLAGS) ifeq (WINNT,$(OS_ARCH)) AR_FLAGS += -LTCG @@ -312,8 +310,8 @@ CXXFLAGS += $(WARNINGS_AS_ERRORS) CFLAGS += $(WARNINGS_AS_ERRORS) endif # ALLOW_COMPILER_WARNINGS -COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES) -COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES) +COMPILE_CFLAGS = $(COMPUTED_CFLAGS) $(_DEPEND_CFLAGS) $(CFLAGS) $(PGO_CFLAGS) $(MOZBUILD_CFLAGS) $(MK_COMPILE_DEFINES) +COMPILE_CXXFLAGS = $(COMPUTED_CXXFLAGS) $(_DEPEND_CFLAGS) $(CXXFLAGS) $(PGO_CFLAGS) $(MOZBUILD_CXXFLAGS) $(MK_COMPILE_DEFINES) COMPILE_CMFLAGS = $(OS_COMPILE_CMFLAGS) $(MOZBUILD_CMFLAGS) COMPILE_CMMFLAGS = $(OS_COMPILE_CMMFLAGS) $(MOZBUILD_CMMFLAGS) ASFLAGS += $(MOZBUILD_ASFLAGS) diff --git a/config/rules.mk b/config/rules.mk index 727a527208ea..aa8314ce3cd2 100644 --- a/config/rules.mk +++ b/config/rules.mk @@ -598,7 +598,7 @@ ifdef MOZ_PROFILE_GENERATE touch -t `date +%Y%m%d%H%M.%S -d 'now+5seconds'` pgo.relink endif else # !WINNT || GNU_CC - $(call EXPAND_CC_OR_CXX,$@) -o $@ $(CXXFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) + $(call EXPAND_CC_OR_CXX,$@) -o $@ $(CXXFLAGS) $(PGO_CFLAGS) $(PROGOBJS) $(RESFILE) $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(EXE_DEF_FILE) $(call CHECK_BINARY,$@) endif # WINNT && !GNU_CC @@ -657,7 +657,7 @@ ifdef MSMANIFEST_TOOL fi endif # MSVC with manifest tool else - $(call EXPAND_CC_OR_CXX,$@) $(CXXFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) + $(call EXPAND_CC_OR_CXX,$@) $(CXXFLAGS) $(PGO_CFLAGS) -o $@ $< $(WIN32_EXE_LDFLAGS) $(LDFLAGS) $(WRAP_LDFLAGS) $(STATIC_LIBS) $(MOZ_PROGRAM_LDFLAGS) $(SHARED_LIBS) $(EXTRA_LIBS) $(OS_LIBS) $(BIN_FLAGS) $(call CHECK_BINARY,$@) endif # WINNT && !GNU_CC diff --git a/js/src/old-configure.in b/js/src/old-configure.in index 82730906c2c7..c66915aa4b45 100644 --- a/js/src/old-configure.in +++ b/js/src/old-configure.in @@ -439,8 +439,8 @@ dnl ======================================================== dnl GNU specific defaults dnl ======================================================== if test "$GNU_CC"; then - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' DSO_LDOPTS='-shared' if test "$GCC_USE_GNU_LD"; then # Some tools like ASan use a runtime library that is only @@ -564,8 +564,8 @@ dnl ======================================================== case "$target" in *-darwin*) - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' MOZ_OPTIMIZE_FLAGS="-O3 -fno-stack-protector" CFLAGS="$CFLAGS -fno-common" CXXFLAGS="$CXXFLAGS -fno-common -stdlib=libc++" diff --git a/old-configure.in b/old-configure.in index 9c90099bde47..f34859faeee3 100644 --- a/old-configure.in +++ b/old-configure.in @@ -516,8 +516,8 @@ if test "$GNU_CC"; then SSSE3_FLAGS="-mssse3" # FIXME: Let us build with strict aliasing. bug 414641. CFLAGS="$CFLAGS -fno-strict-aliasing" - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -Wl,-h,$(DSO_SONAME) -o $@' WARNINGS_AS_ERRORS='-Werror' DSO_CFLAGS='' DSO_PIC_CFLAGS='-fPIC' @@ -764,8 +764,8 @@ dnl ======================================================== case "$target" in *-darwin*) - MKSHLIB='$(CXX) $(CXXFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' - MKCSHLIB='$(CC) $(CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' + MKSHLIB='$(CXX) $(CXXFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' + MKCSHLIB='$(CC) $(CFLAGS) $(PGO_CFLAGS) $(DSO_PIC_CFLAGS) $(DSO_LDOPTS) -o $@' MOZ_OPTIMIZE_FLAGS="-O3" CXXFLAGS="$CXXFLAGS -stdlib=libc++" DSO_LDOPTS=''