]> granicus.if.org Git - postgresql/commitdiff
Eliminate parallel-make hazard in ecpg/preproc.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 Dec 2018 22:19:51 +0000 (17:19 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 1 Dec 2018 22:19:51 +0000 (17:19 -0500)
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

src/interfaces/ecpg/preproc/.gitignore
src/interfaces/ecpg/preproc/Makefile
src/tools/msvc/Mkvcbuild.pm

index aacfb844bda0ef43e1433a30732a4f2bf1877f50..38ae2fe4d928e650a8a163b3477f6a8844d31d69 100644 (file)
@@ -2,5 +2,5 @@
 /preproc.c
 /preproc.h
 /pgc.c
-
+/typename.c
 /ecpg
index 07721752c8feddecd9197458ae44072035893b65..8ceadd112b6e45af4f33aa9fb5a9331395dd9346 100644 (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
index b562044fa716c5a83a4f1e334cfb47674f41e5e3..2921d193a16a1ac15ad08ef7c6823a989c3e9922 100644 (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');