Fix cross-shlib linking in temporary installs on HPUX 10.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 21 Jan 2017 20:15:39 +0000 (15:15 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 21 Jan 2017 20:15:39 +0000 (15:15 -0500)
Turns out this has been broken for years and we'd not noticed.  The one
case that was getting exercised in the buildfarm, or probably anywhere
else, was postgres_fdw.sl's reference to libpq.sl; and it turns out that
that was always going to libpq.sl in the actual installation directory
not the temporary install.  We'd not noticed because the buildfarm script
does "make install" before it tests contrib.  However, the recent addition
of a logical-replication test to the core regression scripts resulted in
trying to use libpqwalreceiver.sl before "make install" happens, and that
failed for lack of finding libpq.sl, as shown by failures on buildfarm
members gaur and pademelon.

There are two changes needed to fix it: the magic environment variable to
specify shlib search path at runtime is SHLIB_PATH not LD_LIBRARY_PATH,
and the shlib link command needs to specify the +s switch else the library
will not honor SHLIB_PATH.

I'm not quite sure why buildfarm members anole and gharial (HPUX 11) didn't
show the same failure.  Consulting man pages on the web says that HPUX 11
honors both LD_LIBRARY_PATH and SHLIB_PATH, which would explain half of it,
and the rather confusing wording I've been able to find suggests that +s
might effectively be the default in HPUX 11.  But it seems at least as
likely that there's just a libpq.so installed in /usr/lib on that machine;
as long as it's not too ancient, that would satisfy the test.  In any case
I do not think this patch will break HPUX 11.

At the moment I don't see a need to back-patch this, since it only matters
for testing purposes, not to mention that HPUX 10 is probably dead in the
real world anyway.

src/Makefile.global.in
src/Makefile.shlib
src/bin/pg_upgrade/test.sh

index d39d6ca8670f6676aa898ac4d2ae3c6979808d6e..59bd7996d182586a9da7b5f51cc6fd28e7894f70 100644 (file)
@@ -344,7 +344,7 @@ endef
 
 # platform-specific environment variable to set shared library path
 define ld_library_path_var
-$(if $(filter $(PORTNAME),darwin),DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME),aix),LIBPATH,LD_LIBRARY_PATH))
+$(if $(filter $(PORTNAME),darwin),DYLD_LIBRARY_PATH,$(if $(filter $(PORTNAME),aix),LIBPATH,$(if $(filter $(PORTNAME),hpux),SHLIB_PATH,LD_LIBRARY_PATH)))
 endef
 
 define with_temp_install
index 358d90837ced0305810ea33e9987c831ea172029..c293a34d1aa8403f776eefddc14b57d65a180824 100644 (file)
@@ -193,7 +193,7 @@ ifeq ($(PORTNAME), hpux)
     # can't use the CC-syntax rpath pattern here, so instead:
     rpath =
     ifeq ($(enable_rpath), yes)
-      LINK.shared      += +b '$(rpathdir)'
+      LINK.shared      += +s +b '$(rpathdir)'
     endif
     # On HPUX platforms, gcc is usually configured to search for libraries
     # in /usr/local/lib, but ld won't do so.  Add an explicit -L switch so
index 8589dbf5b3d814e5baadb6878674f18f241ca009..cbc525955029b461ba2592fcdb05cbf265157c03 100644 (file)
@@ -83,6 +83,8 @@ if [ "$1" = '--install' ]; then
        export DYLD_LIBRARY_PATH
        LIBPATH=$libdir:$LIBPATH
        export LIBPATH
+       SHLIB_PATH=$libdir:$SHLIB_PATH
+       export SHLIB_PATH
        PATH=$libdir:$PATH
 
        # We need to make it use psql from our temporary installation,