Re: pg_preadv() and pg_pwritev() - Mailing list pgsql-hackers

From Tom Lane
Subject Re: pg_preadv() and pg_pwritev()
Date
Msg-id 1418166.1610647514@sss.pgh.pa.us
Whole thread Raw
In response to Re: pg_preadv() and pg_pwritev()  (Sergey Shinderuk <s.shinderuk@postgrespro.ru>)
Responses Re: pg_preadv() and pg_pwritev()  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: pg_preadv() and pg_pwritev()  (Sergey Shinderuk <s.shinderuk@postgrespro.ru>)
List pgsql-hackers
Sergey Shinderuk <s.shinderuk@postgrespro.ru> writes:
> On 14.01.2021 18:42, Tom Lane wrote:
>>> I noticed that "cc" invoked from command line uses:
>>> -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

>> Hm, how did you determine that exactly?

> % cc -v tmp.c
> ...
> -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk

Okay, interesting.  On my Catalina machine, I see

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk

which is also a 10.15 SDK, since I haven't upgraded Xcode past 12.0.
I wonder if that would change if I did upgrade (but I don't plan to
risk it, since this is my only remaining Catalina install).

After considerable playing around, I'm guessing that the reason
-no_weak_imports doesn't help is that it rejects calls that are
marked as weak references on the *calling* side.  Since AC_CHECK_FUNCS
doesn't bother to #include the relevant header file, the compiler
doesn't know that preadv() ought to be marked as a weak reference.
Then, when the test program gets linked against the stub libc that's
provided by the SDK, there is a version of preadv() there so no link
failure occurs.  (There are way more moving parts in this weak-reference
thing than I'd realized.)

It seems like the more productive approach would be to try to identify
the right sysroot to use.  I wonder if there is some less messy way
to find out the compiler's default sysroot than to scrape it out of
-v output.

Another thing I've been realizing while poking at this is that we
might not need to set -isysroot explicitly at all, which would then
lead to the compiler using its default sysroot automatically.
In some experimentation, it seems like what we need PG_SYSROOT for
is just for configure to be able to find tclConfig.sh and the Perl
header files.  So at this point I'm tempted to try ripping that
out altogether.  If you remove the lines in src/template/darwin
that inject PG_SYSROOT into CPPFLAGS and LDFLAGS, do things
work for you?

            regards, tom lane



pgsql-hackers by date:

Previous
From: Surafel Temesgen
Date:
Subject: Re: WIP: System Versioned Temporal Table
Next
From: Tom Lane
Date:
Subject: Re: pg_preadv() and pg_pwritev()