summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2018-11-29 20:53:44 +0000
committerTom Lane2018-11-29 20:53:44 +0000
commit0ff56de46eb0a045417c5c22a5a07c4d6ea9ff78 (patch)
tree0130af9630e7c33ad2c2e2a2cbf93baaa589f830
parentf7001b00a08f37bac306a6ae2028afb3dd2c5084 (diff)
Ensure static libraries have correct mod time even if ranlib messes it up.
In at least Apple's version of ranlib, the output file is updated to have a mod time equal to the max of the timestamps of its components, and that data only has seconds precision. On a filesystem with sub-second file timestamp precision --- say, APFS --- this can result in the finished static library appearing older than its input files, which causes useless rebuilds and possible outright failures in parallel makes. We've only seen this reported in the field from people using Apple's ranlib with a non-Apple make, because Apple's make doesn't know about sub-second timestamps either so it doesn't decide rebuilds are needed. But Apple's ranlib presumably shares code with at least some BSDen, so it's not that unlikely that the same problem could arise elsewhere. To fix, just "touch" the output file after ranlib finishes. We seem to need this in only one place. There are other calls of ranlib in our makefiles, but they are working on intermediate files whose timestamps are not actually important, or else on an installed static library for which sub-second timestamp precision is unlikely to matter either. (Also, so far as I can tell, Apple's ranlib doesn't mess up the file timestamp in the latter usage anyhow.) In passing, change "ranlib" to "$(RANLIB)" in one place that was bypassing the make macro for no good reason. Per bug #15525 from Jack Kelly (via Alyssa Ross). Back-patch to all supported branches. Discussion: https://postgr.es/m/[email protected]
-rw-r--r--src/Makefile.shlib8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 63d5d9e8ee..342496eecd 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -287,11 +287,17 @@ all-static-lib: $(stlib)
all-shared-lib: $(shlib)
+# In this rule, "touch $@" works around a problem on some platforms wherein
+# ranlib updates the library file's mod time with a value calculated to
+# seconds precision. If the filesystem has sub-second timestamps, this can
+# cause the library file to appear older than its input files, triggering
+# parallel-make problems.
ifndef haslibarule
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
rm -f $@
$(LINK.static) $@ $^
$(RANLIB) $@
+ touch $@
endif #haslibarule
@@ -451,7 +457,7 @@ install-lib-static: $(stlib) installdirs-lib
$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
ifeq ($(PORTNAME), darwin)
cd '$(DESTDIR)$(libdir)' && \
- ranlib $(stlib)
+ $(RANLIB) $(stlib)
endif
install-lib-shared: $(shlib) installdirs-lib