summaryrefslogtreecommitdiff
path: root/sys-devel/reflex/files/reflex-20230206-parallel-build.patch
blob: ecfadc14639fbe3a87b0e0330494eb2f41acef80 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 16cc516dfbb6dac01fcd0bfcb717a681b132c0b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arsen=20Arsenovi=C4=87?= <arsen@gentoo.org>
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' <y.tab.c >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