Skip to content

Commit 29180e5

Browse files
committed
Eliminate parallel-make hazard in ecpg/preproc.
Re-making ecpglib's typename.o is dangerous because another make thread could be doing that at the same time. While we've not heard field complaints traceable to this, it seems inevitable that it'd bite someone eventually. Instead, symlink typename.c into the preproc directory and recompile it there. That file is small enough that compiling it twice isn't much of a penalty. Furthermore, this way we get a .o file that's made without shlib CFLAGS, which seems cleaner. This requires adding more stuff to the module's -I list. The MSVC aspect of that is untested, but I'm sure the buildfarm will tell me if I got it wrong. Per a suggestion from Peter Eisentraut. Although this is theoretically a bug fix, the lack of field reports makes me feel we needn't back-patch. Discussion: https://postgr.es/m/31364.1543511708@sss.pgh.pa.us
1 parent 3295f82 commit 29180e5

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

src/interfaces/ecpg/preproc/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
/preproc.c
33
/preproc.h
44
/pgc.c
5-
5+
/typename.c
66
/ecpg

src/interfaces/ecpg/preproc/Makefile

+10-5
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,16 @@ top_builddir = ../../../..
1616
include $(top_builddir)/src/Makefile.global
1717

1818
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
19-
-I. -I$(srcdir) -DECPG_COMPILE \
20-
$(CPPFLAGS)
19+
-I. -I$(srcdir) \
20+
-I$(top_srcdir)/src/interfaces/ecpg/ecpglib \
21+
-I$(libpq_srcdir) \
22+
-DECPG_COMPILE \
23+
$(CPPFLAGS)
2124

2225
override CFLAGS += $(PTHREAD_CFLAGS)
2326

2427
OBJS= preproc.o pgc.o type.o ecpg.o output.o parser.o \
25-
keywords.o c_keywords.o ecpg_keywords.o ../ecpglib/typename.o descriptor.o variable.o \
28+
keywords.o c_keywords.o ecpg_keywords.o typename.o descriptor.o variable.o \
2629
$(WIN32RES)
2730

2831
# Suppress parallel build to avoid a bug in GNU make 3.82
@@ -36,8 +39,9 @@ all: ecpg
3639
ecpg: $(OBJS) | submake-libpgport
3740
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
3841

39-
../ecpglib/typename.o: ../ecpglib/typename.c
40-
$(MAKE) -C $(dir $@) $(notdir $@)
42+
# We symlink typename.c from ecpglib and recompile it here
43+
typename.c: % : $(top_srcdir)/src/interfaces/ecpg/ecpglib/%
44+
rm -f $@ && $(LN_S) $< .
4145

4246
# See notes in src/backend/parser/Makefile about the following two rules
4347
preproc.h: preproc.c
@@ -64,6 +68,7 @@ uninstall:
6468

6569
clean distclean:
6670
rm -f *.o ecpg$(X)
71+
rm -f typename.c
6772

6873
# `make distclean' must not remove preproc.y, preproc.c, preproc.h, or pgc.c
6974
# since we want to ship those files in the distribution for people with

src/tools/msvc/Mkvcbuild.pm

+1
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ sub mkvcbuild
291291
my $ecpg = $solution->AddProject('ecpg', 'exe', 'interfaces',
292292
'src/interfaces/ecpg/preproc');
293293
$ecpg->AddIncludeDir('src/interfaces/ecpg/include');
294+
$ecpg->AddIncludeDir('src/interfaces/ecpg/ecpglib');
294295
$ecpg->AddIncludeDir('src/interfaces/libpq');
295296
$ecpg->AddPrefixInclude('src/interfaces/ecpg/preproc');
296297
$ecpg->AddFiles('src/interfaces/ecpg/preproc', 'pgc.l', 'preproc.y');

0 commit comments

Comments
 (0)