From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sergey Shinderuk <s.shinderuk@postgrespro.ru>
Cc: Thomas Munro <thomas.munro@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: Re: pg_preadv() and pg_pwritev()
Date: Thu, 14 Jan 2021 20:45:06 -0500
Message-ID: <1621321.1610675106@sss.pgh.pa.us> (raw)
In-Reply-To: <dc9aa033-ad66-d078-ceec-6b5a9de9c401@postgrespro.ru>
References: <CA+hUKGJA+u-220VONeoREBXJ9P3S94Y7J+kqCnTYmahvZJwM=g@mail.gmail.com>
<20201220224040.evr5pduibvm6dze5@alap3.anarazel.de>
<CA+hUKG+TCoareSYcAu05yaMh9eUck6Hd8FQZt5VEvotNs3YOMQ@mail.gmail.com>
<CA+hUKGJ8Ww_fjzUzthdxUF6W3JQ3r=a1hWX7Fcfq9uEndZ_+GQ@mail.gmail.com>
<CA+hUKGL9XFxM0ZO8ZADYJepSmjywknhnDkKSEttfmn2j9fg0BQ@mail.gmail.com>
<ed3b8e5d-0da8-6ebd-fd1c-e0ac80a4b204@postgrespro.ru>
<CA+hUKG+L573j4=XWv6S+r-687Yxn0FyXhtObH9_P-Nu_atL2pQ@mail.gmail.com>
<448b3cb5-0ba0-6dc5-63c7-789e4eebc40b@postgrespro.ru>
<1283127.1610554395@sss.pgh.pa.us>
<1286060.1610558607@sss.pgh.pa.us>
<1297389.1610562046@sss.pgh.pa.us>
<1341608.1610580122@sss.pgh.pa.us>
<c2e08e38-e4bd-780d-62df-4a33b537b75e@postgrespro.ru>
<d90658e6-490e-db57-cd64-98868abe79cd@postgrespro.ru>
<1410650.1610638974@sss.pgh.pa.us>
<b2586af5-866f-8290-f068-046fbd1a01b8@postgrespro.ru>
<1418166.1610647514@sss.pgh.pa.u! s>
<1419199.1610649100@sss.pgh.pa.us>
<1612230.1610662425@sss.pgh.pa.us>
<dc9aa033-ad66-d078-ceec-6b5! a9de9c401@postgrespro.ru>
Sergey Shinderuk <s.shinderuk@postgrespro.ru> writes:
> On 15.01.2021 01:13, Tom Lane wrote:
>> Also, after re-reading [1] I am not at all excited about trying to
>> remove the -isysroot switches from our *FLAGS. What I propose to do
>> is keep that, but improve our mechanism for choosing a default value
>> for PG_SYSROOT. It looks like first trying "xcrun --show-sdk-path",
>> and falling back to "xcodebuild -version -sdk macosx Path" if that
>> doesn't yield a valid path, is more likely to give a working build
>> than relying entirely on xcodebuild. Maybe there's a case for trying
>> "xcrun --sdk macosx --show-sdk-path" in between; in my tests that
>> seemed noticeably faster than invoking xcodebuild, and I've not yet
>> seen a case where it gave a different answer.
> I spent quite some time trying to understand / reverse engineer the
> logic behind xcrun's default SDK selection.
Yeah, I wasted a fair amount of time on that too, going so far as
to ktrace xcrun (as I gather you did too). I'm not any more
enlightened than you are about exactly how it's making the choice.
> Oh, that's weird! Nevertheless I like you suggestion to call "xcrun"
> from "configure".
Anyway, after re-reading the previous thread, something I like about
the current behavior is that it tends to produce a version-numbered
sysroot path, ie something ending in "MacOSX11.1.sdk" or whatever.
One of the hazards we're trying to avoid is some parts of a PG
installation being built against one SDK version while other parts are
built against another. The typical behavior of "xcrun --show-sdk-path"
seems to be to produce a path ending in "MacOSX.sdk", which defeats that.
So I think we should accept the path only if it contains a version number,
and otherwise move on to the other probe commands.
Hence, I propose the attached. This works as far as I can tell
to fix the problem you're seeing.
regards, tom lane
Attachments:fix-sysroot-selection.patch (text/x-diff, 1.6K) downloaddiff --git a/src/template/darwin b/src/template/darwinindex 32414d21a9..0c890482fe 100644--- a/src/template/darwin+++ b/src/template/darwin@@ -3,11 +3,26 @@
# Note: Darwin is the original code name for macOS, also known as OS X.
# We still use "darwin" as the port name, partly because config.guess does.
-# Select where system include files should be sought.+# Select where system include files should be sought, if user didn't say.
if test x"$PG_SYSROOT" = x"" ; then
- PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`+ # This is far more complicated than it ought to be. We first ask+ # "xcrun --show-sdk-path", which seems to match the default -isysroot+ # setting of Apple's compilers. However, that may produce no result or+ # a result that is not version-specific (i.e., just ".../SDKs/MacOSX.sdk").+ # Having a version-specific sysroot seems desirable, so if there are not+ # digits in the result string, try "xcrun --sdk macosx --show-sdk-path";+ # and if that still doesn't work, fall back to asking xcodebuild.+ PG_SYSROOT=`xcrun --show-sdk-path 2>/dev/null`+ if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9]' >/dev/null ; then : okay+ else+ PG_SYSROOT=`xcrun --sdk macosx --show-sdk-path 2>/dev/null`+ if expr x"$PG_SYSROOT" : '.*[0-9]\.[0-9]' >/dev/null ; then : okay+ else+ PG_SYSROOT=`xcodebuild -version -sdk macosx Path 2>/dev/null`+ fi+ fi
fi
-# Old xcodebuild versions may produce garbage, so validate the result.+# Validate the result: if it doesn't point at a directory, ignore it.
if test x"$PG_SYSROOT" != x"" ; then
if test -d "$PG_SYSROOT" ; then
CPPFLAGS="-isysroot $PG_SYSROOT $CPPFLAGS"
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, s.shinderuk@postgrespro.ru, thomas.munro@gmail.com
Subject: Re: pg_preadv() and pg_pwritev()
In-Reply-To: <1621321.1610675106@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox