Re: BUG #19727: pg-combinebackup fails to link - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19727: pg-combinebackup fails to link
Date
Msg-id 859825.1790781896@sss.pgh.pa.us
Whole thread
In response to Re: BUG #19727: pg-combinebackup fails to link  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
I wrote:
> Ross Burton <ross@burtonini.com> writes:
>> This is a makefile dependency bug exposed in parallel builds, and can
>> be reproduced on demand with a minimal reproducer.

> Very interesting!  So the problem is that the scope of the effects of
> this:
> jsonapi_shlib.o: override CPPFLAGS += -DJSONAPI_USE_PQEXPBUFFER
> isn't terribly well-defined.

I dug in the gmake manual and verified that they document this
behavior and point out that it can produce inconsistent results.
So we need to fix it.  The attached seems to do the trick, but
now I wonder where else there might be similar issues.  I did
a few rounds of "make -s -j32 --shuffle" and didn't see any
other compilation failures, but that isn't a very thorough test.

            regards, tom lane

diff --git a/src/common/Makefile b/src/common/Makefile
index 3404601b6bf..daeba105af9 100644
--- a/src/common/Makefile
+++ b/src/common/Makefile
@@ -162,11 +162,6 @@ libpgcommon_shlib.a: $(OBJS_SHLIB)
     rm -f $@
     $(AR) $(AROPT) $@ $^

-# The JSON API normally exits on out-of-memory; disable that behavior for shared
-# library builds. This requires libpq's pqexpbuffer.h.
-jsonapi_shlib.o: override CPPFLAGS += -DJSONAPI_USE_PQEXPBUFFER
-jsonapi_shlib.o: override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
-
 # Because this uses its own compilation rule, it doesn't use the
 # dependency tracking logic from Makefile.global.  To make sure that
 # dependency tracking works anyway for the *_shlib.o files, depend on
@@ -176,6 +171,12 @@ jsonapi_shlib.o: override CPPFLAGS := -I$(libpq_srcdir) $(CPPFLAGS)
 %_shlib.o: %.c %.o
     $(CC) $(CFLAGS) $(CFLAGS_SL) $(CPPFLAGS) -c $< -o $@

+# The JSON API normally exits on out-of-memory; disable that behavior for shared
+# library builds. This requires libpq's pqexpbuffer.h.
+# This rule overrides the previous one, so must duplicate its effects.
+jsonapi_shlib.o: jsonapi.c jsonapi.o
+    $(CC) $(CFLAGS) $(CFLAGS_SL) -DJSONAPI_USE_PQEXPBUFFER -I$(libpq_srcdir) $(CPPFLAGS) -c $< -o $@
+
 libpgcommon_excluded_shlib.a: $(OBJS_EXCLUDED_SHLIB)
     rm -f $@
     $(AR) $(AROPT) $@ $^

pgsql-bugs by date:

Previous
From: Andrey Rachitskiy
Date:
Subject: Re: BUG #19732: first_value/last_value/nth_value return NULL with EXCLUDE TIES when the current row is outside its f
Next
From: Alexander Lakhin
Date:
Subject: Re: Postmaster crashes on SIGHUP when oauth_validator_libraries holds only whitespace