Skip to content

Commit df1d749

Browse files
committed
Yet further rethinking of build changes for macOS Mojave.
The solution arrived at in commit e74dd00 presumes that the compiler has a suitable default -isysroot setting ... but further experience shows that in many combinations of macOS version, XCode version, Xcode command line tools version, and phase of the moon, Apple's compiler will *not* supply a default -isysroot value. We could potentially go back to the approach used in commit 68fc227, but I don't have a lot of faith in the reliability or life expectancy of that either. Let's just revert to the approach already shipped in 11.0, namely specifying an -isysroot switch globally. As a partial response to the concerns raised by Jakob Egger, adjust the contents of Makefile.global to look like CPPFLAGS = -isysroot $(PG_SYSROOT) ... PG_SYSROOT = /path/to/sysroot This allows overriding the sysroot path at build time in a relatively painless way. Add documentation to installation.sgml about how to use the PG_SYSROOT option. I also took the opportunity to document how to work around macOS's "System Integrity Protection" feature. As before, back-patch to all supported versions. Discussion: https://postgr.es/m/20840.1537850987@sss.pgh.pa.us
1 parent fd6449a commit df1d749

File tree

5 files changed

+75
-3
lines changed

5 files changed

+75
-3
lines changed

configure

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ ac_includes_default="\
627627

628628
ac_subst_vars='LTLIBOBJS
629629
vpath_build
630+
PG_SYSROOT
630631
PG_VERSION_NUM
631632
PROVE
632633
FOP
@@ -18836,6 +18837,15 @@ _ACEOF
1883618837

1883718838

1883818839

18840+
# If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not
18841+
# literally, so that it's possible to override it at build time using
18842+
# a command like "make ... PG_SYSROOT=path". This has to be done after
18843+
# we've finished all configure checks that depend on CPPFLAGS.
18844+
if test x"$PG_SYSROOT" != x; then
18845+
CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
18846+
fi
18847+
18848+
1883918849

1884018850
# Begin output steps
1884118851

configure.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2359,6 +2359,15 @@ $AWK '{printf "%d%04d", $1, $2}'`"]
23592359
AC_DEFINE_UNQUOTED(PG_VERSION_NUM, $PG_VERSION_NUM, [PostgreSQL version as a number])
23602360
AC_SUBST(PG_VERSION_NUM)
23612361

2362+
# If we are inserting PG_SYSROOT into CPPFLAGS, do so symbolically not
2363+
# literally, so that it's possible to override it at build time using
2364+
# a command like "make ... PG_SYSROOT=path". This has to be done after
2365+
# we've finished all configure checks that depend on CPPFLAGS.
2366+
if test x"$PG_SYSROOT" != x; then
2367+
CPPFLAGS=`echo "$CPPFLAGS" | sed -e "s| $PG_SYSROOT | \\\$(PG_SYSROOT) |"`
2368+
fi
2369+
AC_SUBST(PG_SYSROOT)
2370+
23622371

23632372
# Begin output steps
23642373

doc/src/sgml/installation.sgml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2513,6 +2513,57 @@ PHSS_30849 s700_800 u2comp/be/plugin library Patch
25132513
</para>
25142514
</sect2>
25152515

2516+
<sect2 id="installation-notes-macos">
2517+
<title>macOS</title>
2518+
2519+
<indexterm zone="installation-notes-macos">
2520+
<primary>macOS</primary>
2521+
<secondary>installation on</secondary>
2522+
</indexterm>
2523+
2524+
<para>
2525+
On recent <productname>macOS</productname> releases, it's necessary to
2526+
embed the <quote>sysroot</quote> path in the include switches used to
2527+
find some system header files. This results in the outputs of
2528+
the <application>configure</application> script varying depending on
2529+
which SDK version was used during <application>configure</application>.
2530+
That shouldn't pose any problem in simple scenarios, but if you are
2531+
trying to do something like building an extension on a different machine
2532+
than the server code was built on, you may need to force use of a
2533+
different sysroot path. To do that, set <varname>PG_SYSROOT</varname>,
2534+
for example
2535+
<programlisting>
2536+
make PG_SYSROOT=<replaceable>/desired/path</replaceable> all
2537+
</programlisting>
2538+
To find out the appropriate path on your machine, run
2539+
<programlisting>
2540+
xcodebuild -version -sdk macosx Path
2541+
</programlisting>
2542+
Note that building an extension using a different sysroot version than
2543+
was used to build the core server is not really recommended; in the
2544+
worst case it could result in hard-to-debug ABI inconsistencies.
2545+
</para>
2546+
2547+
<para>
2548+
You can also select a non-default sysroot path when configuring, by
2549+
specifying <varname>PG_SYSROOT</varname>
2550+
to <application>configure</application>:
2551+
<programlisting>
2552+
./configure ... PG_SYSROOT=<replaceable>/desired/path</replaceable>
2553+
</programlisting>
2554+
</para>
2555+
2556+
<para>
2557+
<productname>macOS</productname>'s <quote>System Integrity
2558+
Protection</quote> (SIP) feature breaks <literal>make check</literal>,
2559+
because it prevents passing the needed setting
2560+
of <literal>DYLD_LIBRARY_PATH</literal> down to the executables being
2561+
tested. You can work around that by doing <literal>make
2562+
install</literal> before <literal>make check</literal>.
2563+
Most Postgres developers just turn off SIP, though.
2564+
</para>
2565+
</sect2>
2566+
25162567
<sect2 id="installation-notes-mingw">
25172568
<title>MinGW/Native Windows</title>
25182569

src/Makefile.global.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ BITCODE_CXXFLAGS = @BITCODE_CXXFLAGS@
241241

242242
CPP = @CPP@
243243
CPPFLAGS = @CPPFLAGS@
244+
PG_SYSROOT = @PG_SYSROOT@
244245

245246
override CPPFLAGS := $(ICU_CFLAGS) $(CPPFLAGS)
246247

src/template/darwin

Lines changed: 4 additions & 3 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-
# Some configure tests require explicit knowledge of where the Xcode "sysroot"
7-
# is. We try to avoid having this leak into configure's results, though.
6+
# Select where system include files should be sought.
87
if test x"$PG_SYSROOT" = x"" ; then
98
PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`
109
fi
1110
# Old xcodebuild versions may produce garbage, so validate the result.
1211
if test x"$PG_SYSROOT" != x"" ; then
13-
if test \! -d "$PG_SYSROOT" ; then
12+
if test -d "$PG_SYSROOT" ; then
13+
CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
14+
else
1415
PG_SYSROOT=""
1516
fi
1617
fi

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy