Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1a69f73

Browse files
committed
Back off using -isysroot on Darwin.
Rethink the solution applied in commit 5e22171 to get PL/Tcl to build on macOS Mojave. I feared that adding -isysroot globally might have undesirable consequences, and sure enough Jakob Egger reported one: it complicates building extensions with a different Xcode version than was used for the core server. (I find that a risky proposition in general, but apparently it works most of the time, so we shouldn't break it if we don't have to.) We'd already adopted the solution for PL/Perl of inserting the sysroot path directly into the -I switches used to find Perl's headers, and we can do the same thing for PL/Tcl by changing the -iwithsysroot switch that Apple's tclConfig.sh reports. This restricts the risks to PL/Perl and PL/Tcl themselves and directly-dependent extensions, which is a lot more pleasing in general than a global -isysroot switch. Along the way, tighten the test to see if we need to inject the sysroot path into $perl_includedir, as I'd speculated about upthread but not gotten round to doing. As before, back-patch to all supported versions. Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
1 parent 49a1c22 commit 1a69f73

File tree

3 files changed

+17
-6
lines changed

3 files changed

+17
-6
lines changed

configure

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9552,7 +9552,7 @@ PL/Perl." "$LINENO" 5
95529552
perl_includedir="$perl_archlibexp"
95539553
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
95549554
if test x"$PG_SYSROOT" != x"" ; then
9555-
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
9555+
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
95569556
perl_includedir="$PG_SYSROOT$perl_archlibexp"
95579557
fi
95589558
fi
@@ -18135,6 +18135,11 @@ eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\"
1813518135
as_fn_error $? "cannot build PL/Tcl because Tcl is not a shared library
1813618136
Use --without-tcl to disable building PL/Tcl." "$LINENO" 5
1813718137
fi
18138+
# Some macOS versions report an include spec that uses -iwithsysroot.
18139+
# We don't really want to use -isysroot, so translate that if we can.
18140+
if test x"$PG_SYSROOT" != x"" ; then
18141+
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
18142+
fi
1813818143
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
1813918144
ac_save_CPPFLAGS=$CPPFLAGS
1814018145
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"

configure.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ PL/Perl.])
10371037
perl_includedir="$perl_archlibexp"
10381038
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
10391039
if test x"$PG_SYSROOT" != x"" ; then
1040-
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
1040+
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
10411041
perl_includedir="$PG_SYSROOT$perl_archlibexp"
10421042
fi
10431043
fi
@@ -2213,6 +2213,11 @@ if test "$with_tcl" = yes; then
22132213
AC_MSG_ERROR([cannot build PL/Tcl because Tcl is not a shared library
22142214
Use --without-tcl to disable building PL/Tcl.])
22152215
fi
2216+
# Some macOS versions report an include spec that uses -iwithsysroot.
2217+
# We don't really want to use -isysroot, so translate that if we can.
2218+
if test x"$PG_SYSROOT" != x"" ; then
2219+
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
2220+
fi
22162221
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
22172222
ac_save_CPPFLAGS=$CPPFLAGS
22182223
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"

src/template/darwin

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
# Note: Darwin is the original code name for macOS, also known as OS X.
44
# We still use "darwin" as the port name, partly because config.guess does.
55

6-
# Select where system include files should be sought.
6+
# Select where some include files should be sought.
7+
# We may eventually be forced to use "-isysroot" with this value,
8+
# but for now, it only affects Perl and Tcl include files.
79
if test x"$PG_SYSROOT" = x"" ; then
810
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
911
fi
12+
# Old xcodebuild versions may produce garbage, so validate the result.
1013
if test x"$PG_SYSROOT" != x"" ; then
11-
if test -d "$PG_SYSROOT" ; then
12-
CPPFLAGS="$CPPFLAGS -isysroot $PG_SYSROOT"
13-
else
14+
if test \! -d "$PG_SYSROOT" ; then
1415
PG_SYSROOT=""
1516
fi
1617
fi

0 commit comments

Comments
 (0)