On macOS, use -isysroot in link steps as well as compile steps.
authorTom Lane <[email protected]>
Fri, 20 Nov 2020 05:58:26 +0000 (00:58 -0500)
committerTom Lane <[email protected]>
Fri, 20 Nov 2020 05:58:26 +0000 (00:58 -0500)
We previously put the -isysroot switch only into CPPFLAGS, theorizing
that it was only needed to find the right copies of include files.
However, it seems that we also need to use it while linking programs,
to find the right stub ".tbd" files for libraries.  We got away
without that up to now, but apparently that was mostly luck.  It may
also be that failures are only observed when the Xcode version is
noticeably out of sync with the host macOS version; the case that's
prompting action right now is that builds fail when using latest Xcode
(12.2) on macOS Catalina, even though it's fine on Big Sur.

Hence, add -isysroot to LDFLAGS as well.  (It seems that the more
common practice is to put it in CFLAGS, whence it'd be included at
both compile and link steps.  However, we can't mess with CFLAGS in
the platform template file without confusing configure's logic for
choosing default CFLAGS.)

Back-patch of 49407dc32 into all supported branches.

Report and patch by James Hilliard (some cosmetic mods by me)

Discussion: https://postgr.es/m/20201120003314[email protected]

configure
configure.in
src/template/darwin

index 19624435685196ee4845c4356eba9101f1a7db5c..055f8fe6b752463e192150a38581c2ea1b1e6274 100755 (executable)
--- a/configure
+++ b/configure
@@ -17206,8 +17206,10 @@ _ACEOF
 # literally, so that it's possible to override it at build time using
 # a command like "make ... PG_SYSROOT=path".  This has to be done after
 # we've finished all configure checks that depend on CPPFLAGS.
+# The same for LDFLAGS, too.
 if test x"$PG_SYSROOT" != x; then
   CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  LDFLAGS=`echo "$LDFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
 fi
 
 
index 639e9a9dbf988faaf3bcd7d0711c4b49671d133f..f2f24384718e6d14b16e771f6f86ef83d581ec41 100644 (file)
@@ -2300,8 +2300,10 @@ AC_SUBST(PG_VERSION_NUM)
 # literally, so that it's possible to override it at build time using
 # a command like "make ... PG_SYSROOT=path".  This has to be done after
 # we've finished all configure checks that depend on CPPFLAGS.
+# The same for LDFLAGS, too.
 if test x"$PG_SYSROOT" != x; then
   CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  LDFLAGS=`echo "$LDFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
 fi
 AC_SUBST(PG_SYSROOT)
 
index f4d4e9d7cf80d5c55e0da63ece81e4ccf69e66d7..32414d21a98a22000b6c1f9df55d5632ee292e80 100644 (file)
@@ -11,6 +11,7 @@ fi
 if test x"$PG_SYSROOT" != x"" ; then
   if test -d "$PG_SYSROOT" ; then
     CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
+    LDFLAGS="-isysroot $PG_SYSROOT $LDFLAGS"
   else
     PG_SYSROOT=""
   fi