From 16cc516dfbb6dac01fcd0bfcb717a681b132c0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= Date: Thu, 9 Feb 2023 20:34:48 +0100 Subject: [PATCH] Remove .bootstrap and scan.c target race If the parallelism of a make invocation is great enough to generate both .bootstrap and scan.c simultaneously, there's a great chance that the rule in .bootstrap will be overruled by the (possibly failing) redirection in the scan.c, resulting in an empty scan.c and a failing build. Instead, we can use an empty scan.c as an (inaccurate) proxy for the boostrap. Bug: https://bugs.gentoo.org/883611 --- a/Makefile.in +++ b/Makefile.in @@ -126,14 +126,9 @@ PERF_REPORT = -p all: $(FLEX) -$(FLEX): .bootstrap $(OBJECTS) $(FLEXLIB) +$(FLEX): $(OBJECTS) $(FLEXLIB) @ECHO_LD@$(CC) $(CFLAGS) -o $(FLEX) $(LDFLAGS) $(OBJECTS) $(FLEXLIB) $(LIBS) -.bootstrap: initscan.c - @rm -f scan.c - cp $(srcdir)/initscan.c scan.c - touch .bootstrap - parse.c: parse.y $(YACC) -d $(srcdir)/parse.y @sed '/extern char.*malloc/d' parse.tmp @@ -145,6 +140,7 @@ parse.h: parse.c scan.c: scan.l $(SHELL) $(srcdir)/mkscan.sh $(FLEX_EXEC) $(FLEX_FLAGS) $(COMPRESSION) $(srcdir)/scan.l >scan.c + grep . $@ || cp initscan.c scan.c scan$o: scan.c parse.h flexdef.h config.h yylex$o: yylex.c parse.h flexdef.h config.h @@ -259,8 +255,8 @@ clean :: mostlyclean $(FLEXLIB) config.log config.cache distclean :: clean - rm -f .bootstrap $(FLEX) scan.c tags TAGS Makefile man2html.tmp \ - config.status config.h stamp-h config.log config.cache + rm -f $(FLEX) scan.c tags TAGS Makefile man2html.tmp config.status \ + config.h stamp-h config.log config.cache maintainer-clean: distclean @echo "This command is intended for maintainers to use;" -- 2.39.1