Bug 1412932 - Move PGO logic from client.mk into root Makefile.in; r?build draft
authorGregory Szorc <gps@mozilla.com>
Mon, 30 Oct 2017 15:10:09 -0700
changeset 689029 24b9cbde4c6ce8f8b14e3dc33997a4ea37f7843f
parent 689028 3e8da6ff42267dc3dc7296b53b4457ed64193f69
child 689030 cfb57f52eacd9017a0f7d3c720f099ba234863a5
push id86890
push usergszorc@mozilla.com
push dateMon, 30 Oct 2017 22:55:17 +0000
reviewersbuild
bugs1412932
milestone58.0a1
Bug 1412932 - Move PGO logic from client.mk into root Makefile.in; r?build client.mk is going away. This commit moves the PGO build target out of it. We move the code to Makefile.in. This likely isn't its final home, as we'll want to eliminate Makefile.in at some point. However, it is easier to move things to the root Makefile.in than other alternatives. Keep in mind that the logic needs access to primitives like BUILDSTATUS and variables from mk_add_options, which the Makefile.in mechanism has easy access to. MozReview-Commit-ID: 4C43lBhZz4l
Makefile.in
client.mk
--- a/Makefile.in
+++ b/Makefile.in
@@ -217,16 +217,36 @@ ifdef ENABLE_TESTS
 # Additional makefile targets to call automated test suites
 include $(topsrcdir)/testing/testsuite-targets.mk
 endif
 endif
 
 default all::
 	$(call BUILDSTATUS,TIERS $(TIERS) $(if $(MOZ_AUTOMATION),$(MOZ_AUTOMATION_TIERS)))
 
+# PGO build target.
+profiledbuild::
+	$(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use)
+	$(call BUILDSTATUS,TIER_START pgo_profile_generate)
+	$(MAKE) MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1
+	$(call BUILDSTATUS,TIER_FINISH pgo_profile_generate)
+	$(call BUILDSTATUS,TIER_START pgo_package)
+	$(MAKE) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
+	rm -f jarlog/en-US.log
+	$(call BUILDSTATUS,TIER_FINISH pgo_package)
+	$(call BUILDSTATUS,TIER_START pgo_profile)
+	MOZ_PGO_INSTRUMENTED=1 JARLOG_FILE=jarlog/en-US.log EXTRA_TEST_ARGS=10 $(MAKE) pgo-profile-run
+	$(call BUILDSTATUS,TIER_FINISH pgo_profile)
+	$(call BUILDSTATUS,TIER_START pgo_clobber)
+	$(MAKE) maybe_clobber_profiledbuild
+	$(call BUILDSTATUS,TIER_FINISH pgo_clobber)
+	$(call BUILDSTATUS,TIER_START pgo_profile_use)
+	$(MAKE) MOZ_PROFILE_USE=1
+	$(call BUILDSTATUS,TIER_FINISH pgo_profile_use)
+
 include $(topsrcdir)/config/rules.mk
 
 ifdef SCCACHE_VERBOSE_STATS
 default::
 	-$(CCACHE) --show-stats --stats-format=json > sccache-stats.json
 	@echo "===SCCACHE STATS==="
 	-$(CCACHE) --show-stats
 	@echo "==================="
--- a/client.mk
+++ b/client.mk
@@ -134,17 +134,17 @@ CONFIGURES += $(TOPSRCDIR)/js/src/config
 # Make targets that are going to be passed to the real build system
 OBJDIR_TARGETS = install export libs clean realclean distclean upload sdk installer package package-compare stage-package source-package l10n-check automation/build
 
 #######################################################################
 # Rules
 
 # The default rule is build
 build::
-	$(MAKE) -f $(TOPSRCDIR)/client.mk $(if $(MOZ_PGO),profiledbuild,realbuild) CREATE_MOZCONFIG_JSON=
+	$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild CREATE_MOZCONFIG_JSON=
 
 # Include baseconfig.mk for its $(MAKE) validation.
 include $(TOPSRCDIR)/config/baseconfig.mk
 
 # Define mkdir
 include $(TOPSRCDIR)/config/makefiles/makeutils.mk
 include $(TOPSRCDIR)/config/makefiles/autotargets.mk
 
@@ -168,39 +168,16 @@ endif
 
 # Windows equivalents
 build_all: build
 clobber clobber_all: clean
 
 # helper target for mobile
 build_and_deploy: build package install
 
-####################################
-# Profile-Guided Optimization
-#  This is up here so that this is usable in multi-pass builds, where you
-# might not have a runnable application until all the build passes have run.
-profiledbuild::
-	$(call BUILDSTATUS,TIERS pgo_profile_generate pgo_package pgo_profile pgo_clobber pgo_profile_use)
-	$(call BUILDSTATUS,TIER_START pgo_profile_generate)
-	$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1 MOZ_PGO_INSTRUMENTED=1 CREATE_MOZCONFIG_JSON=
-	$(call BUILDSTATUS,TIER_FINISH pgo_profile_generate)
-	$(call BUILDSTATUS,TIER_START pgo_package)
-	$(MAKE) -C $(OBJDIR) package MOZ_PGO_INSTRUMENTED=1 MOZ_INTERNAL_SIGNING_FORMAT= MOZ_EXTERNAL_SIGNING_FORMAT=
-	rm -f $(OBJDIR)/jarlog/en-US.log
-	$(call BUILDSTATUS,TIER_FINISH pgo_package)
-	$(call BUILDSTATUS,TIER_START pgo_profile)
-	MOZ_PGO_INSTRUMENTED=1 JARLOG_FILE=jarlog/en-US.log EXTRA_TEST_ARGS=10 $(MAKE) -C $(OBJDIR) pgo-profile-run
-	$(call BUILDSTATUS,TIER_FINISH pgo_profile)
-	$(call BUILDSTATUS,TIER_START pgo_clobber)
-	$(MAKE) -C $(OBJDIR) maybe_clobber_profiledbuild
-	$(call BUILDSTATUS,TIER_FINISH pgo_clobber)
-	$(call BUILDSTATUS,TIER_START pgo_profile_use)
-	$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1 CREATE_MOZCONFIG_JSON=
-	$(call BUILDSTATUS,TIER_FINISH pgo_profile_use)
-
 #####################################################
 # Preflight, before building any project
 
 ifdef MOZ_PREFLIGHT_ALL
 realbuild preflight_all::
 	set -e; \
 	for mkfile in $(MOZ_PREFLIGHT_ALL); do \
 	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile preflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
@@ -301,30 +278,30 @@ ifneq (,$(CONFIG_STATUS))
 $(OBJDIR)/config/autoconf.mk: $(TOPSRCDIR)/config/autoconf.mk.in
 	$(PYTHON) $(OBJDIR)/config.status -n --file=$(OBJDIR)/config/autoconf.mk
 endif
 
 ####################################
 # Build it
 
 realbuild::  $(OBJDIR)/Makefile $(OBJDIR)/config.status
-	+$(MOZ_MAKE)
+	+$(MOZ_MAKE) $(if $(MOZ_PGO),profiledbuild)
 
 ####################################
 # Other targets
 
 # Pass these target onto the real build system
 $(OBJDIR_TARGETS):: $(OBJDIR)/Makefile $(OBJDIR)/config.status
 	+$(MOZ_MAKE) $@
 
 ####################################
 # Postflight, after building all projects
 
 ifdef MOZ_AUTOMATION
-$(if $(MOZ_PGO),profiledbuild,realbuild)::
+realbuild::
 	$(MAKE) -f $(TOPSRCDIR)/client.mk automation/build
 endif
 
 ifdef MOZ_POSTFLIGHT_ALL
 realbuild postflight_all::
 	set -e; \
 	for mkfile in $(MOZ_POSTFLIGHT_ALL); do \
 	  $(MAKE) -f $(TOPSRCDIR)/$$mkfile postflight_all TOPSRCDIR=$(TOPSRCDIR) OBJDIR=$(OBJDIR) MOZ_OBJDIR=$(MOZ_OBJDIR); \
@@ -337,16 +314,15 @@ echo-variable-%:
 # This makefile doesn't support parallel execution. It does pass
 # MOZ_MAKE_FLAGS to sub-make processes, so they will correctly execute
 # in parallel.
 .NOTPARALLEL:
 
 .PHONY: \
     realbuild \
     build \
-    profiledbuild \
     build_all \
     clobber \
     clobber_all \
     configure \
     preflight_all \
     postflight_all \
     $(OBJDIR_TARGETS)