Bug 1415971 - Inline sccache.mk into client.mk; r=nalexander
authorGregory Szorc <gps@mozilla.com>
Thu, 09 Nov 2017 14:59:06 -0800
changeset 441919 109cb09f0123190631b18be2aa4e7f7e81eeb44d
parent 441918 30fbe1a0ce8c60da004dac0f9edc234ddbf18081
child 441920 512bc6565c8065cd0ff9a933f2705047e72bd7f7
push id8134
push userryanvm@gmail.com
push dateFri, 10 Nov 2017 21:18:48 +0000
treeherdermozilla-beta@6c6c0e855154 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1415971
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1415971 - Inline sccache.mk into client.mk; r=nalexander sccache.mk is the only thing that uses MOZ_PREFLIGHT_ALL and MOZ_POSTFLIGHT_ALL. We're trying to kill client.mk and these variables are next on the chopping block. This commit essentially moves the logic of sccache.mk inline into client.mk. Initially, I wanted to move the management of the sccache daemon to Python as part of what `mach build` invokes. However, the sccache daemon needs access to the make jobserver. Since we don't have an active make process in `mach`, this is obviously problematic. The sccache daemon is also used by configure, which is launched from client.mk. So the best we can do right now is move the sccache daemon logic into client.mk. As part of the port, we pass the path to the sccache binary via an environment variable. This feels slightly better than hardcoding the path that automation uses. MozReview-Commit-ID: zcOYR4I1OG
build/mozconfig.cache
build/sccache.mk
client.mk
--- a/build/mozconfig.cache
+++ b/build/mozconfig.cache
@@ -114,18 +114,17 @@ else
     mk_add_options "export SCCACHE_BUCKET=$bucket"
     case "$master" in
     *us[ew][12].mozilla.com*|*euc1.mozilla.com*)
         mk_add_options "export SCCACHE_NAMESERVER=169.254.169.253"
         ;;
     esac
     export CCACHE="$topsrcdir/sccache2/sccache${suffix}"
     export SCCACHE_VERBOSE_STATS=1
-    mk_add_options MOZ_PREFLIGHT_ALL+=build/sccache.mk
-    mk_add_options MOZ_POSTFLIGHT_ALL+=build/sccache.mk
+    mk_add_options MOZBUILD_MANAGE_SCCACHE_DAEMON=${topsrcdir}/sccache2/sccache
     mk_add_options "UPLOAD_EXTRA_FILES+=sccache.log.gz"
     case "$platform" in
     win*)
         # sccache supports a special flag to create depfiles.
         #TODO: bug 1318370 - move this all into toolchain.configure
         export _DEPEND_CFLAGS='-deps$(MDDEPDIR)/$(@F).pp'
         # Windows builds have a default wrapper that needs to be overridden
         mk_add_options "export CC_WRAPPER="
deleted file mode 100644
--- a/build/sccache.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# 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/.
-
-preflight_all:
-	# Terminate any sccache server that might still be around
-	-$(TOPSRCDIR)/sccache2/sccache --stop-server > /dev/null 2>&1
-	# Start a new server, ensuring it gets the jobserver file descriptors
-	# from make (but don't use the + prefix when make -n is used, so that
-	# the command doesn't run in that case)
-	$(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)env RUST_LOG=sccache::compiler=debug SCCACHE_ERROR_LOG=$(OBJDIR)/dist/sccache.log $(TOPSRCDIR)/sccache2/sccache --start-server
-
-postflight_all:
-	# Terminate sccache server. This prints sccache stats.
-	-$(TOPSRCDIR)/sccache2/sccache --stop-server
--- a/client.mk
+++ b/client.mk
@@ -159,16 +159,28 @@ build_and_deploy: build package install
 ifdef MOZ_PREFLIGHT_ALL
 build 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); \
 	done
 endif
 
+# In automation, manage an sccache daemon. The starting of the server
+# needs to be in a make file so sccache inherits the jobserver.
+ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
+build::
+	# Terminate any sccache server that might still be around.
+	-$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server > /dev/null 2>&1
+	# Start a new server, ensuring it gets the jobserver file descriptors
+	# from make (but don't use the + prefix when make -n is used, so that
+	# the command doesn't run in that case)
+	$(if $(findstring n,$(filter-out --%, $(MAKEFLAGS))),,+)env RUST_LOG=sccache::compiler=debug SCCACHE_ERROR_LOG=$(OBJDIR)/dist/sccache.log $(MOZBUILD_MANAGE_SCCACHE_DAEMON) --start-server
+endif
+
 ####################################
 # Configure
 
 MAKEFILE      = $(wildcard $(OBJDIR)/Makefile)
 CONFIG_STATUS = $(wildcard $(OBJDIR)/config.status)
 
 EXTRA_CONFIG_DEPS := \
   $(TOPSRCDIR)/aclocal.m4 \
@@ -283,16 +295,22 @@ build::  $(OBJDIR)/Makefile $(OBJDIR)/co
 ####################################
 # Postflight, after building all projects
 
 ifdef MOZ_AUTOMATION
 build::
 	$(MAKE) -f $(TOPSRCDIR)/client.mk automation/build
 endif
 
+ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
+build::
+	# Terminate sccache server. This prints sccache stats.
+	-$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server
+endif
+
 ifdef MOZ_POSTFLIGHT_ALL
 build 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); \
 	done
 endif