Re: pg_preadv() and pg_pwritev()
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Sergey Shinderuk <s.shinderuk@postgrespro.ru>
Cc: Thomas Munro <thomas.munro@gmail.com>,
pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2021-01-14T22:13:45Z
Lists: pgsql-hackers
I borrowed my wife's Mac, which is still on Catalina and up to now never had Xcode on it, and found some very interesting things. Step 1: download/install Xcode 12.3, open it, agree to license, wait for it to finish "installing components". At this point, /Library/Developer/CommandLineTools doesn't exist, and we have the following outputs from various probe commands: % xcrun --show-sdk-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk % xcrun --sdk macosx --show-sdk-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk % xcodebuild -version -sdk macosx Path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk Also, cc -v reports -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk Unsurprisingly, Xcode 12.3 itself only contains % ls -l /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs total 0 drwxr-xr-x 5 root wheel 160 Nov 30 07:27 DriverKit20.2.sdk drwxr-xr-x 7 root wheel 224 Nov 30 07:27 MacOSX.sdk lrwxr-xr-x 1 root wheel 10 Jan 14 15:57 MacOSX11.1.sdk -> MacOSX.sdk Step 2: install command line tools (I used "xcode-select --install" to fire this off, rather than the Xcode menu item). Now I have % ls -l /Library/Developer/CommandLineTools/SDKs total 0 lrwxr-xr-x 1 root wheel 14 Jan 14 16:42 MacOSX.sdk -> MacOSX11.1.sdk drwxr-xr-x 8 root wheel 256 Jul 9 2020 MacOSX10.15.sdk drwxr-xr-x 7 root wheel 224 Nov 30 07:33 MacOSX11.1.sdk which is pretty interesting in itself, because the same directory on my recently-updated-to-Big-Sur Macs does NOT have the 11.1 SDK. I wonder what determines which versions get installed here. More interesting yet: % xcrun --show-sdk-path /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk % xcrun --sdk macosx --show-sdk-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk % xcodebuild -version -sdk macosx Path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk and cc -v reports -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk So apparently, "xcrun --show-sdk-path" (without any -sdk option) is the most authoritative guide to the compiler's default sysroot. However, googling turns up various people reporting that "xcrun --show-sdk-path" returns an empty string for them, and our last major investigation into this [1] found that there are some system states where the compiler appears to have no default sysroot, which I bet is the same thing. I do not at this point have a recipe to reproduce such a state, but we'd be fools to imagine it's no longer possible. My guess about it is that Apple's processes for updating the default sysroot during system updates are just plain buggy, with various corner cases that have ill-understood causes. 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. Thoughts? regards, tom lane [1] https://www.postgresql.org/message-id/flat/20840.1537850987%40sss.pgh.pa.us
Commits
-
Improve our heuristic for selecting PG_SYSROOT on macOS.
- 3934543c2bb0 9.5.25 landed
- fc6d08b27a33 9.6.21 landed
- 5fa060c8f593 10.16 landed
- 046c8facecee 11.11 landed
- f5d044eaeff0 12.6 landed
- f44ae4db5fec 13.2 landed
- 4823621db312 14.0 landed
-
Move our p{read,write}v replacements into their own files.
- 0d56acfbaa79 14.0 landed
-
Don't use elog() in src/port/pwrite.c.
- df10ac625c16 14.0 landed
-
Use vectored I/O to fill new WAL segments.
- ce6a71fa5300 14.0 landed
-
Provide pg_preadv() and pg_pwritev().
- 13a021f3e8c9 14.0 landed