PG vs macOS Mojave

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: PG vs macOS Mojave
Date: 2018-09-25 04:49:47
Message-ID: 20840.1537850987@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Well, macOS 10.14 (Mojave) is out, so I installed it on a spare machine,
and naturally the first thing I tried was to build PG with it. Our
core code seems fine, but:

* --with-perl fails in configure, complaining that it can't find perl.h.

* --with-tcl fails in configure, complaining that it can't find
tclConfig.sh. Furthermore, the historical workaround for that
(--with-tclconfig=/System/Library/Frameworks/Tcl.framework) doesn't fix it.

After some investigation, it seems that Apple has been busy moving
header files (not libraries) under SDK-specific "sysroot" directories,
with the expectation that you'd compile using "-isysroot $SYSROOT".
There's some mention of that here, for example:

https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/cross_development/Configuring/configuring.html#//apple_ref/doc/uid/10000163i-CH1-SW7

The sysroot seems to contain only headers; stuff you need at runtime,
such as shared libraries, is still where it used to be.

The recommended way to get the appropriate sysroot path seems to be

SYSROOT=`xcodebuild -version -sdk macosx Path`

Attached is a draft patch to fix things up. The core ideas are

(1) Stop assuming that the Perl headers and library are necessarily
in the same place; create a perl_includedir variable to represent the
path to the former.

(2) Tweak src/template/darwin to inject the appropriate -isysroot
option into CPPFLAGS.

(3) Remove the need to manually specify the path to tclConfig.sh,
which has gotten even more painful than before because now it's
somewhere under the sysroot. You can still specify --with-tclconfig
if you really want to, but it's not necessary anymore to build pltcl
under recent macOS.

Note that (3) alone is not sufficient to fix pltcl; we must do (2)
as well because tclConfig.sh now reports the Tcl include flags as
TCL_INCLUDE_SPEC = -iwithsysroot /System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers
so unless we also set -isysroot this doesn't work.

It's a bit scary to be adding -isysroot globally. I thought
briefly about using it only while building pltcl, but that seems
even more dangerous: if there were any discrepancies between the
headers in the sysroot and those in the normal include directories,
building pltcl with different headers from the rest of the system
would surely be disastrous. In any case, I suspect that the handwriting
is on the wall, and before very much longer it's going to be impossible
to build meaningful code on macOS without -isysroot anyway.

I've tested this on all the macOS versions I have at hand, and it
doesn't seem to break anything. Only part (1) could possibly
affect other platforms, and that seems safe enough.

I'd like to commit and backpatch this, because otherwise longfin
is going to start falling over when I upgrade its host to Mojave.

Thoughts?

regards, tom lane

Attachment Content-Type Size
fixups-for-mojave-1.patch text/x-diff 5.5 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-09-25 05:09:04 Re: New function pg_stat_statements_reset_query() to reset statistics of a specific query
Previous Message Michael Paquier 2018-09-25 04:43:46 Re: when set track_commit_timestamp on, database system abort startup