Bug 1412932 - Switch to PGO build in Makefile.in; r=ted

Previously, client.mk made the decision of whether to perform a PGO
build. This required passing around MOZ_PGO and invoking a separate
make target if this variable was set.

In this commit, we move this logic to Makefile.in. We employ a special
mechanism in rules.mk to override the default make target so
`make` evaluates "profiledbuild" if MOZ_PGO is set. This also
required using an explicit target for $(MAKE) invocations inside
the "profiledbuild" rule to avoid infinite recursion.

MozReview-Commit-ID: 8sHiVspMisM

--HG--
extra : rebase_source : 76c8a0c592015802f2b9ad52fe2001012a4611f6
extra : source : 24e28b37fbc0ad55ee449699e09c62042af41b55
This commit is contained in:
Gregory Szorc 2017-11-07 16:38:39 -08:00
Родитель b95c15093f
Коммит 9e26b9fde3
3 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -226,22 +226,27 @@ default all::
profiledbuild:: profiledbuild::
$(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use) $(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use)
$(call BUILDSTATUS,TIER_START pgo_profile_generate) $(call BUILDSTATUS,TIER_START pgo_profile_generate)
$(MAKE) MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1 $(MAKE) default MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
$(call BUILDSTATUS,TIER_FINISH pgo_profile_generate) $(call BUILDSTATUS,TIER_FINISH pgo_profile_generate)
$(call BUILDSTATUS,TIER_START pgo_package) $(call BUILDSTATUS,TIER_START pgo_package)
$(MAKE) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT= $(MAKE) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
rm -f jarlog/en-US.log rm -f jarlog/en-US.log
$(call BUILDSTATUS,TIER_FINISH pgo_package) $(call BUILDSTATUS,TIER_FINISH pgo_package)
$(call BUILDSTATUS,TIER_START pgo_profile) $(call BUILDSTATUS,TIER_START pgo_profile)
MOZ_PGO_INSTRUMENTED=1 JARLOG_FILE=jarlog/en-US.log EXTRA_TEST_ARGS=10 $(MAKE) pgo-profile-run $(MAKE) pgo-profile-run MOZ_PGO_INSTRUMENTED=1 JARLOG_FILE=jarlog/en-US.log EXTRA_TEST_ARGS=10
$(call BUILDSTATUS,TIER_FINISH pgo_profile) $(call BUILDSTATUS,TIER_FINISH pgo_profile)
$(call BUILDSTATUS,TIER_START pgo_clobber) $(call BUILDSTATUS,TIER_START pgo_clobber)
$(MAKE) maybe_clobber_profiledbuild $(MAKE) maybe_clobber_profiledbuild
$(call BUILDSTATUS,TIER_FINISH pgo_clobber) $(call BUILDSTATUS,TIER_FINISH pgo_clobber)
$(call BUILDSTATUS,TIER_START pgo_profile_use) $(call BUILDSTATUS,TIER_START pgo_profile_use)
$(MAKE) MOZ_PROFILE_USE=1 $(MAKE) default MOZ_PROFILE_USE=1
$(call BUILDSTATUS,TIER_FINISH pgo_profile_use) $(call BUILDSTATUS,TIER_FINISH pgo_profile_use)
# Change default target to PGO build if PGO is enabled.
ifdef MOZ_PGO
OVERRIDE_DEFAULT_GOAL := profiledbuild
endif
include $(topsrcdir)/config/rules.mk include $(topsrcdir)/config/rules.mk
ifdef SCCACHE_VERBOSE_STATS ifdef SCCACHE_VERBOSE_STATS

Просмотреть файл

@ -86,8 +86,7 @@ endef
# before evaluation. $(shell) replacing newlines with spaces, || is always # before evaluation. $(shell) replacing newlines with spaces, || is always
# followed by a space (since sed doesn't remove newlines), except on the # followed by a space (since sed doesn't remove newlines), except on the
# last line, so replace both '|| ' and '||'. # last line, so replace both '|| ' and '||'.
# Also, make MOZ_PGO available to mozconfig when passed on make command line. MOZCONFIG_CONTENT := $(subst ||,$(CR),$(subst || ,$(CR),$(shell $(TOPSRCDIR)/mach environment --format=client.mk | sed 's/$$/||/')))
MOZCONFIG_CONTENT := $(subst ||,$(CR),$(subst || ,$(CR),$(shell MOZ_PGO=$(MOZ_PGO) $(TOPSRCDIR)/mach environment --format=client.mk | sed 's/$$/||/')))
$(eval $(MOZCONFIG_CONTENT)) $(eval $(MOZCONFIG_CONTENT))
export FOUND_MOZCONFIG export FOUND_MOZCONFIG
@ -104,9 +103,6 @@ MOZCONFIG_OUT_FILTERED := $(filter-out $(START_COMMENT)%,$(MOZCONFIG_OUT_LINES))
ifdef AUTOCLOBBER ifdef AUTOCLOBBER
export AUTOCLOBBER=1 export AUTOCLOBBER=1
endif endif
ifdef MOZ_PGO
export MOZ_PGO
endif
ifdef MOZ_PARALLEL_BUILD ifdef MOZ_PARALLEL_BUILD
MOZ_MAKE_FLAGS := $(filter-out -j%,$(MOZ_MAKE_FLAGS)) MOZ_MAKE_FLAGS := $(filter-out -j%,$(MOZ_MAKE_FLAGS))
@ -290,7 +286,7 @@ endif
# Build it # Build it
build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status build:: $(OBJDIR)/Makefile $(OBJDIR)/config.status
+$(MOZ_MAKE) $(if $(MOZ_PGO),profiledbuild) +$(MOZ_MAKE)
#################################### ####################################
# Other targets # Other targets

Просмотреть файл

@ -34,6 +34,7 @@ class TestBuild(unittest.TestCase):
self._old_env = dict(os.environ) self._old_env = dict(os.environ)
os.environ.pop('MOZCONFIG', None) os.environ.pop('MOZCONFIG', None)
os.environ.pop('MOZ_OBJDIR', None) os.environ.pop('MOZ_OBJDIR', None)
os.environ.pop('MOZ_PGO', None)
def tearDown(self): def tearDown(self):
os.environ.clear() os.environ.clear()