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
This commit is contained in:
Tom Lane 2018-12-01 17:19:51 -05:00
parent 3295f82022
commit 29180e5d78
3 changed files with 12 additions and 6 deletions

View file

@ -2,5 +2,5 @@
/preproc.c
/preproc.h
/pgc.c
/typename.c
/ecpg

View file

@ -16,13 +16,16 @@ top_builddir = ../../../..
include $(top_builddir)/src/Makefile.global
override CPPFLAGS := -I../include -I$(top_srcdir)/src/interfaces/ecpg/include \
-I. -I$(srcdir) -DECPG_COMPILE \
$(CPPFLAGS)
-I. -I$(srcdir) \
-I$(top_srcdir)/src/interfaces/ecpg/ecpglib \
-I$(libpq_srcdir) \
-DECPG_COMPILE \
$(CPPFLAGS)
override CFLAGS += $(PTHREAD_CFLAGS)
OBJS= preproc.o pgc.o type.o ecpg.o output.o parser.o \
keywords.o c_keywords.o ecpg_keywords.o ../ecpglib/typename.o descriptor.o variable.o \
keywords.o c_keywords.o ecpg_keywords.o typename.o descriptor.o variable.o \
$(WIN32RES)
# Suppress parallel build to avoid a bug in GNU make 3.82
@ -36,8 +39,9 @@ all: ecpg
ecpg: $(OBJS) | submake-libpgport
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) $^ $(LIBS) $(PTHREAD_LIBS) -o $@$(X)
../ecpglib/typename.o: ../ecpglib/typename.c
$(MAKE) -C $(dir $@) $(notdir $@)
# We symlink typename.c from ecpglib and recompile it here
typename.c: % : $(top_srcdir)/src/interfaces/ecpg/ecpglib/%
rm -f $@ && $(LN_S) $< .
# See notes in src/backend/parser/Makefile about the following two rules
preproc.h: preproc.c
@ -64,6 +68,7 @@ uninstall:
clean distclean:
rm -f *.o ecpg$(X)
rm -f typename.c
# `make distclean' must not remove preproc.y, preproc.c, preproc.h, or pgc.c
# since we want to ship those files in the distribution for people with

View file

@ -291,6 +291,7 @@ sub mkvcbuild
my $ecpg = $solution->AddProject('ecpg', 'exe', 'interfaces',
'src/interfaces/ecpg/preproc');
$ecpg->AddIncludeDir('src/interfaces/ecpg/include');
$ecpg->AddIncludeDir('src/interfaces/ecpg/ecpglib');
$ecpg->AddIncludeDir('src/interfaces/libpq');
$ecpg->AddPrefixInclude('src/interfaces/ecpg/preproc');
$ecpg->AddFiles('src/interfaces/ecpg/preproc', 'pgc.l', 'preproc.y');