Skip to content

Commit

Permalink
Bug 1734594 - Terminate the sccache server in cases where submakes en…
Browse files Browse the repository at this point in the history
…d in an error. r=firefox-build-system-reviewers,andi

Differential Revision: https://phabricator.services.mozilla.com/D127919
  • Loading branch information
glandium committed Oct 8, 2021
1 parent b53e11a commit a9fc880
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions client.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ build::
# 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
SCCACHE_STOP = $(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server

# When a command fails, make is going to abort, but we need to terminate the
# sccache server, otherwise it will prevent make itself from terminating
# because it would still be running and holding a jobserver token.
# However, we also need to preserve the command's exit code, thus the
# gymnastics.
SCCACHE_STOP_ON_FAILURE = || (x=$$?; $(SCCACHE_STOP) || true; exit $$x)

build::
# Terminate any sccache server that might still be around.
-$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server > /dev/null 2>&1
-$(SCCACHE_STOP) > /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)
Expand All @@ -51,17 +60,17 @@ endif

### Build it
build::
+$(MOZ_MAKE)
+$(MOZ_MAKE) $(SCCACHE_STOP_ON_FAILURE)

ifdef MOZ_AUTOMATION
build::
+$(MOZ_MAKE) automation/build
+$(MOZ_MAKE) automation/build $(SCCACHE_STOP_ON_FAILURE)
endif

ifdef MOZBUILD_MANAGE_SCCACHE_DAEMON
build::
# Terminate sccache server. This prints sccache stats.
-$(MOZBUILD_MANAGE_SCCACHE_DAEMON) --stop-server
-$(SCCACHE_STOP)
endif

.PHONY: \
Expand Down

0 comments on commit a9fc880

Please sign in to comment.