Skip to content

Commit aff53b2

Browse files
committed
Make the yacc rules safe for parallel make. See discussion on pgsql-patches
and comment in src/backend/parser/Makefile for the technical details.
1 parent 7c50767 commit aff53b2

File tree

6 files changed

+38
-17
lines changed

6 files changed

+38
-17
lines changed

contrib/cube/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.5 2001/09/06 10:49:29 petere Exp $
1+
# $Header: /cvsroot/pgsql/contrib/cube/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $
22

33
subdir = contrib/cube
44
top_builddir = ../..
@@ -12,7 +12,9 @@ DOCS = README.cube
1212
REGRESS = cube
1313

1414

15-
cubeparse.c cubeparse.h: cubeparse.y
15+
cubeparse.c: cubeparse.h ;
16+
17+
cubeparse.h: cubeparse.y
1618
ifdef YACC
1719
$(YACC) -d $(YFLAGS) -p cube_yy $<
1820
mv -f y.tab.c cubeparse.c

contrib/seg/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.5 2001/09/06 10:49:30 petere Exp $
1+
# $Header: /cvsroot/pgsql/contrib/seg/Makefile,v 1.6 2001/11/16 16:32:33 petere Exp $
22

33
subdir = contrib/seg
44
top_builddir = ../..
@@ -11,7 +11,9 @@ DOCS = README.seg
1111
REGRESS = seg
1212

1313

14-
segparse.c segparse.h: segparse.y
14+
segparse.c: segparse.h ;
15+
16+
segparse.h: segparse.y
1517
ifdef YACC
1618
$(YACC) -d $(YFLAGS) -p seg_yy $<
1719
mv -f y.tab.c segparse.c

src/backend/bootstrap/Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for the bootstrap module
44
#
5-
# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.28 2001/08/22 20:02:56 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/backend/bootstrap/Makefile,v 1.29 2001/11/16 16:32:33 petere Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -25,7 +25,7 @@ SUBSYS.o: $(OBJS)
2525
$(LD) $(LDREL) $(LDOUT) $@ $^
2626

2727

28-
bootstrap.o bootscanner.c: $(srcdir)/bootstrap_tokens.h
28+
bootstrap.o bootscanner.o: $(srcdir)/bootstrap_tokens.h
2929

3030

3131
# `sed' rules to remove conflicts between bootstrap scanner and parser
@@ -37,7 +37,9 @@ sed -e 's/^yy/Int_yy/g' \
3737
endef
3838

3939

40-
$(srcdir)/bootparse.c $(srcdir)/bootstrap_tokens.h: bootparse.y Makefile
40+
$(srcdir)/bootparse.c: $(srcdir)/bootstrap_tokens.h ;
41+
42+
$(srcdir)/bootstrap_tokens.h: bootparse.y Makefile
4143
ifdef YACC
4244
$(YACC) -d $(YFLAGS) $<
4345
$(sed-magic) < y.tab.c > $(srcdir)/bootparse.c

src/backend/parser/Makefile

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for parser
44
#
5-
# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.34 2001/08/09 18:13:23 petere Exp $
5+
# $Header: /cvsroot/pgsql/src/backend/parser/Makefile,v 1.35 2001/11/16 16:32:33 petere Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -20,15 +20,26 @@ all: SUBSYS.o
2020
SUBSYS.o: $(OBJS)
2121
$(LD) $(LDREL) $(LDOUT) $@ $^
2222

23-
$(srcdir)/gram.c $(srcdir)/parse.h: gram.y
23+
24+
# There is no correct way to write a rule that generates two files.
25+
# Rules with two targets don't have that meaning, they are merely
26+
# shorthand for two otherwise separate rules. To be safe for parallel
27+
# make, we must chain the dependencies like this. The semicolon is
28+
# important, otherwise make will choose the built-in rule for
29+
# gram.y=>gram.c.
30+
31+
$(srcdir)/gram.c: $(srcdir)/parse.h ;
32+
33+
$(srcdir)/parse.h: gram.y
2434
ifdef YACC
2535
$(YACC) -d $(YFLAGS) $<
26-
mv y.tab.c $(srcdir)/gram.c
27-
mv y.tab.h $(srcdir)/parse.h
36+
mv -f y.tab.c $(srcdir)/gram.c
37+
mv -f y.tab.h $(srcdir)/parse.h
2838
else
2939
@$(missing) bison $< $@
3040
endif
3141

42+
3243
$(srcdir)/scan.c: scan.l
3344
ifdef FLEX
3445
$(FLEX) $(FLEXFLAGS) -Pbase_yy -o'$@' $<

src/interfaces/ecpg/preproc/Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.77 2001/09/19 14:09:32 meskes Exp $
1+
# $Header: /cvsroot/pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.78 2001/11/16 16:32:33 petere Exp $
22

33
subdir = src/interfaces/ecpg/preproc
44
top_builddir = ../../../..
@@ -35,11 +35,13 @@ endif
3535
ecpg: $(OBJS)
3636
$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LIBS) -o $@
3737

38-
$(srcdir)/preproc.c $(srcdir)/preproc.h: preproc.y
38+
$(srcdir)/preproc.c: $(srcdir)/preproc.h ;
39+
40+
$(srcdir)/preproc.h: preproc.y
3941
ifdef YACC
4042
$(YACC) -d $(YFLAGS) $<
41-
mv y.tab.c $(srcdir)/preproc.c
42-
mv y.tab.h $(srcdir)/preproc.h
43+
mv -f y.tab.c $(srcdir)/preproc.c
44+
mv -f y.tab.h $(srcdir)/preproc.h
4345
else
4446
@$(missing) bison $< $@
4547
endif

src/pl/plpgsql/src/Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for the plpgsql shared object
44
#
5-
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.19 2001/10/09 04:15:38 tgl Exp $
5+
# $Header: /cvsroot/pgsql/src/pl/plpgsql/src/Makefile,v 1.20 2001/11/16 16:32:33 petere Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -64,7 +64,9 @@ pl_gram.o pl_scan.o pl_handler.o pl_comp.o pl_exec.o pl_funcs.o: plpgsql.h $(src
6464
# Note: Since the yacc and lex files are shipped in the distribution,
6565
# they must be generated in the srcdir (as opposed to builddir).
6666

67-
$(srcdir)/pl_gram.c $(srcdir)/pl.tab.h: gram.y
67+
$(srcdir)/pl_gram.c: $(srcdir)/pl.tab.h ;
68+
69+
$(srcdir)/pl.tab.h: gram.y
6870
ifdef YACC
6971
$(YACC) -d $(YFLAGS) $<
7072
sed -e 's/yy/plpgsql_yy/g' -e 's/YY/PLPGSQL_YY/g' < y.tab.c > $(srcdir)/pl_gram.c

0 commit comments

Comments
 (0)