[PATCH 1/1] Fix compilation on mac with Xcode >= 11.4. - Mailing list pgsql-hackers

From James Hilliard
Subject [PATCH 1/1] Fix compilation on mac with Xcode >= 11.4.
Date
Msg-id 20201120003314.20560-1-james.hilliard1@gmail.com
Whole thread Raw
Responses Re: [PATCH 1/1] Fix compilation on mac with Xcode >= 11.4.
List pgsql-hackers
It would appear weak symbol linking is not handled properly without
'isysroot' parameter passed to linker.

Fixes:
Undefined symbols for architecture x86_64:
  "___darwin_check_fd_set_overflow", referenced from:
      _ClientAuthentication in auth.o
      _pgstat_init in pgstat.o
      _ServerLoop in postmaster.o
ld: symbol(s) not found for architecture x86_64

See:
https://github.com/qt/qtwebengine-chromium/commit/d5c4b6230b7f915f6e044e230c0c575249938400
---
 configure           | 4 +++-
 configure.ac        | 4 +++-
 src/template/darwin | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/configure b/configure
index ace4ed5dec..92b089907e 100755
--- a/configure
+++ b/configure
@@ -19041,7 +19041,6 @@ if test "$with_readline" = yes; then
 else
   link_test_func=exit
 fi
-
 if test "$PORTNAME" = "darwin"; then
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC supports -Wl,-dead_strip_dylibs" >&5
 $as_echo_n "checking whether $CC supports -Wl,-dead_strip_dylibs... " >&6; }
@@ -19194,6 +19193,9 @@ _ACEOF
 # we've finished all configure checks that depend on CPPFLAGS.
 if test x"$PG_SYSROOT" != x; then
   CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  if test "$PORTNAME" = "darwin"; then
+    LDFLAGS=`echo "$LDFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  fi
 fi
 
 
diff --git a/configure.ac b/configure.ac
index 5b91c83fd0..a82cbbc147 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2326,7 +2326,6 @@ if test "$with_readline" = yes; then
 else
   link_test_func=exit
 fi
-
 if test "$PORTNAME" = "darwin"; then
   PGAC_PROG_CC_LDFLAGS_OPT([-Wl,-dead_strip_dylibs], $link_test_func)
 elif test "$PORTNAME" = "openbsd"; then
@@ -2362,6 +2361,9 @@ AC_SUBST(PG_VERSION_NUM)
 # we've finished all configure checks that depend on CPPFLAGS.
 if test x"$PG_SYSROOT" != x; then
   CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  if test "$PORTNAME" = "darwin"; then
+    LDFLAGS=`echo "$LDFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
+  fi
 fi
 AC_SUBST(PG_SYSROOT)
 
diff --git a/src/template/darwin b/src/template/darwin
index f4d4e9d7cf..83d20a8cdd 100644
--- a/src/template/darwin
+++ b/src/template/darwin
@@ -11,6 +11,8 @@ fi
 if test x"$PG_SYSROOT" != x"" ; then
   if test -d "$PG_SYSROOT" ; then
     CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
+    # Prevent undefined symbols errors for weak linked symbols.
+    LDFLAGS="-isysroot $PG_SYSROOT $LDFLAGS"
   else
     PG_SYSROOT=""
   fi
-- 
2.29.2




pgsql-hackers by date:

Previous
From: "tsunakawa.takay@fujitsu.com"
Date:
Subject: RE: Disable WAL logging to speed up data loading
Next
From: Michael Paquier
Date:
Subject: Re: scram-sha-256 broken with FIPS and OpenSSL 1.0.2