summaryrefslogtreecommitdiff
path: root/src/Makefile.shlib
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-03-23 13:45:37 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-03-23 13:46:00 -0400
commit4b538727e2a0e5eae228650c1c145c90471aa521 (patch)
treec51ecb049aa40b7b4a565b69c6a97a13681b6bf9 /src/Makefile.shlib
parent8694cc96b52a967a49725f32be7aa77fd3b6ac25 (diff)
downloadpostgresql-4b538727e2a0e5eae228650c1c145c90471aa521.tar.gz
Fix make rules that generate multiple output files.
For years, our makefiles have correctly observed that "there is no correct way to write a rule that generates two files". However, what we did is to provide empty rules that "generate" the secondary output files from the primary one, and that's not right either. Depending on the details of the creating process, the primary file might end up timestamped later than one or more secondary files, causing subsequent make runs to consider the secondary file(s) out of date. That's harmless in a plain build, since make will just re-execute the empty rule and nothing happens. But it's fatal in a VPATH build, since make will expect the secondary file to be rebuilt in the build directory. This would manifest as "file not found" failures during VPATH builds from tarballs, if we were ever unlucky enough to ship a tarball with apparently out-of-date secondary files. (It's not clear whether that has ever actually happened, but it definitely could.) To ensure that secondary output files have timestamps >= their primary's, change our makefile convention to be that we provide a "touch $@" action not an empty rule. Also, make sure that this rule actually gets invoked during a distprep run, else the hazard remains. It's been like this a long time, so back-patch to all supported branches. In HEAD, I skipped the changes in src/backend/catalog/Makefile, because those rules are due to get replaced soon in the bootstrap data format patch, and there seems no need to create a merge issue for that patch. If for some reason we fail to land that patch in v11, we'll need to back-fill the changes in that one makefile from v10. Discussion: https://postgr.es/m/18556.1521668179@sss.pgh.pa.us
Diffstat (limited to 'src/Makefile.shlib')
-rw-r--r--src/Makefile.shlib20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 0839f37e0f..74d48c56f2 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -315,13 +315,9 @@ else # PORTNAME == aix
# AIX case
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose some built-in rule.
-
-$(stlib): $(shlib) ;
+# See notes in src/backend/parser/Makefile about the following two rules
+$(stlib): $(shlib)
+ touch $@
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
rm -f $(stlib)
@@ -352,13 +348,9 @@ else
# Win32 case
-# There is no correct way to write a rule that generates two files.
-# Rules with two targets don't have that meaning, they are merely
-# shorthand for two otherwise separate rules. To be safe for parallel
-# make, we must chain the dependencies like this. The semicolon is
-# important, otherwise make will choose some built-in rule.
-
-$(stlib): $(shlib) ;
+# See notes in src/backend/parser/Makefile about the following two rules
+$(stlib): $(shlib)
+ touch $@
# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers