Bug 1415971 - Inline sccache.mk into client.mk; r?build
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
--- 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