Bug 1367940 - Ensure sccache inherits the make jobserver file descriptors. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 13 Jul 2017 20:10:23 +0900
changeset 608677 627a72c250a746e081ff95368882548a2c6908e3
parent 608676 e84175b2e5117be34d44cb0252fc1a61ac3c739d
child 608952 29ec05f2fd6902433c7e591197ffca5c364c8c3c
push id68369
push userbmo:mh+mozilla@glandium.org
push dateFri, 14 Jul 2017 01:37:53 +0000
reviewersgps
bugs1367940
milestone56.0a1
Bug 1367940 - Ensure sccache inherits the make jobserver file descriptors. r?gps Rustc 1.20 gained support for make jobserver. But when rustc is invoked through sccache, sccache needs to have inherited the make jobserver file descriptor to pass it down to rustc. But what will be running sccache first during the build is not really deterministic. It might as well end up being a script invoking the preprocessor that ends up doing it. And we can't add the necessary + prefix to all commands that potentially can end up invoking sccache. So we manually start the sccache server at the beginning of the build, through preflight. Note this works on automation, but not for local builds, but few people are using sccache locally for rust (yet). Let's figure that out in a followup.
build/sccache.mk
--- a/build/sccache.mk
+++ b/build/sccache.mk
@@ -7,12 +7,16 @@ BASE_DIR = $(OBJDIR)
 else
 # OSX Universal builds only do upload in the first MOZ_BUILD_PROJECTS
 BASE_DIR = $(MOZ_OBJDIR)/$(firstword $(MOZ_BUILD_PROJECTS))
 endif
 
 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))),,+)$(TOPSRCDIR)/sccache2/sccache --start-server
 
 postflight_all:
 	# Terminate sccache server. This prints sccache stats.
 	-$(TOPSRCDIR)/sccache2/sccache --stop-server