Skip to content

Commit 486e6f8

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 4166fb3 commit 486e6f8

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

configure

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7508,7 +7508,7 @@ $as_echo "$perl_useshrplib" >&6; }
75087508
perl_includedir="$perl_archlibexp"
75097509
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
75107510
if test x"$PG_SYSROOT" != x"" ; then
7511-
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
7511+
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
75127512
perl_includedir="$PG_SYSROOT$perl_archlibexp"
75137513
fi
75147514
fi
@@ -14680,7 +14680,12 @@ eval TCL_LIBS=\"$TCL_LIBS\"
1468014680
eval TCL_LIB_SPEC=\"$TCL_LIB_SPEC\"
1468114681
eval TCL_SHARED_BUILD=\"$TCL_SHARED_BUILD\"
1468214682

14683-
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
14683+
# Some macOS versions report an include spec that uses -iwithsysroot.
14684+
# We don't really want to use -isysroot, so translate that if we can.
14685+
if test x"$PG_SYSROOT" != x"" ; then
14686+
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
14687+
fi
14688+
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
1468414689
ac_save_CPPFLAGS=$CPPFLAGS
1468514690
CPPFLAGS="$TCL_INCLUDE_SPEC $CPPFLAGS"
1468614691
ac_fn_c_check_header_mongrel "$LINENO" "tcl.h" "ac_cv_header_tcl_h" "$ac_includes_default"

configure.in

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -919,7 +919,7 @@ if test "$with_perl" = yes; then
919919
perl_includedir="$perl_archlibexp"
920920
# ... but on some macOS versions, we must look under $PG_SYSROOT instead
921921
if test x"$PG_SYSROOT" != x"" ; then
922-
if test -d "$PG_SYSROOT$perl_archlibexp" ; then
922+
if test -f "$PG_SYSROOT$perl_archlibexp/CORE/perl.h" ; then
923923
perl_includedir="$PG_SYSROOT$perl_archlibexp"
924924
fi
925925
fi
@@ -1933,6 +1933,11 @@ if test "$with_tcl" = yes; then
19331933
PGAC_EVAL_TCLCONFIGSH([$TCL_CONFIG_SH],
19341934
[TCL_INCLUDE_SPEC,TCL_LIB_FILE,TCL_LIBS,TCL_LIB_SPEC,TCL_SHARED_BUILD])
19351935
AC_SUBST(TCL_SHLIB_LD_LIBS)dnl don't want to double-evaluate that one
1936+
# Some macOS versions report an include spec that uses -iwithsysroot.
1937+
# We don't really want to use -isysroot, so translate that if we can.
1938+
if test x"$PG_SYSROOT" != x"" ; then
1939+
TCL_INCLUDE_SPEC="`echo "$TCL_INCLUDE_SPEC" | sed "s|-iwithsysroot */|-I $PG_SYSROOT/|"`"
1940+
fi
19361941
# now that we have TCL_INCLUDE_SPEC, we can check for <tcl.h>
19371942
ac_save_CPPFLAGS=$CPPFLAGS
19381943
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)