From af5b3203b55b71047ca6eb80db72e91824a41a53 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 30 Jul 2019 11:40:24 +0930 Subject: [PATCH] Makefile: fix parallel `update-mocks` build. We always rebuild headerversions to examine critical system headers, however that stomps on parallel builds with: make[1]: execvp: tools/headerversions: Text file busy Signed-off-by: Rusty Russell --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4001b9b01..728ea333e 100644 --- a/Makefile +++ b/Makefile @@ -385,8 +385,9 @@ gen_version.h: FORCE @if cmp $@.new $@ >/dev/null 2>&2; then rm -f $@.new; else mv $@.new $@; echo Version updated; fi # We force make to relink this every time, to detect version changes. +# Do it atomically, otherwise parallel builds can get upset! tools/headerversions: FORCE tools/headerversions.o $(CCAN_OBJS) - @$(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@ + @trap "rm -f $@.tmp.$$$$" EXIT; $(LINK.o) tools/headerversions.o $(CCAN_OBJS) $(LOADLIBES) $(LDLIBS) -o $@.tmp.$$$$ && mv $@.tmp.$$$$ $@ # That forces this rule to be run every time, too. gen_header_versions.h: tools/headerversions