- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit3934543
committed
Improve our heuristic for selecting PG_SYSROOT on macOS.
In cases where Xcode is newer than the underlying macOS version,asking xcodebuild for the SDK path will produce a pointer to theSDK shipped with Xcode, which may end up building code that doesnot work on the underlying macOS version. It appears that insuch cases, xcodebuild's answer also fails to match the defaultbehavior of Apple's compiler: assuming one has installed Xcode's"command line tools", there will be an SDK for the OS's own versionin /Library/Developer/CommandLineTools, and the compiler willdefault to using that. This is all pretty poorly documented,but experimentation suggests that "xcrun --show-sdk-path" givesthe sysroot path that the compiler is actually using, at leastin some cases. Hence, try that first, but revert to xcodebuildif xcrun fails (in very old Xcode, it is missing or lacks the--show-sdk-path switch).Also, "xcrun --show-sdk-path" may give a path that is valid but lacksany OS version identifier. We don't really want that, since mostof the motivation for wiring -isysroot into the build flags at allis to ensure that all parts of a PG installation are built againstthe same SDK, even when considering extensions built later and/or ona different machine. Insist on finding "N.N" in the directory namebefore accepting the result. (Adding "--sdk macosx" to the xcruncall seems to produce the same answer as xcodebuild, but usuallymore quickly because it's cached, so we also try that as a fallback.)The core reason why we don't want to use Xcode's default SDK in caseslike this is that Apple's technology for introducing new syscallsdoes not play nice with Autoconf: for example, configure will thinkthat preadv/pwritev exist when using a Big Sur SDK, even when buildingon an older macOS version where they don't exist. It'd be nice tohave a better solution to that problem, but this patch doesn't attemptto fix that.Per report from Sergey Shinderuk. Back-patch to all supported versions.Discussion:https://postgr.es/m/ed3b8e5d-0da8-6ebd-fd1c-e0ac80a4b204@postgrespro.ru1 parent2d19f13 commit3934543
1 file changed
+19
-3
lines changedLines changed: 19 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
6 |
| - | |
| 6 | + | |
7 | 7 |
| |
8 |
| - | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
9 | 25 |
| |
10 |
| - | |
| 26 | + | |
11 | 27 |
| |
12 | 28 |
| |
13 | 29 |
| |
|
0 commit comments
Comments
(0)