You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Patch *.sdk paths from pkgConfig files to the current SDK (#6772)
This fixes#6439 by replacing all `*.sdk` paths obtained from pkgConfigs
with the current SDK.
### Motivation:
Using Homebrew-packaged libraries such as Cairo in a system library
target on macOS currently causes build failures if the user compiles the
Swift package with an Xcode toolchain (see
[`swift-systemlib-demo`](https://github.com/fwcd/swift-systemlib-demo/tree/bb30a9ce6205a503ad85fc112b0e60a4c3a450c4)
and its CI builds for a minimal example), the build output often looks
similar to this:
```
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.0.sdk/usr/include/ffi/module.modulemap:1:8: error: redefinition of module 'FFI'
module FFI [system] [extern_c] {
^
/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi/module.modulemap:1:8: note: previously defined here
module FFI [system] [extern_c] {
```
The problem is that Homebrew's pre-compiled libraries sometimes bake the
Command Line Tools-paths
(`/Library/Developer/CommandLineTools/SDKs/...`) into their `pkgConfig`
files, which can clash with the current SDK's headers.
See #6439 for details.
### Modifications:
As per @neonichu's suggestion in
#6439 (comment),
this patches the include (`-I`) and library (`-L`) paths parsed from
pkgConfig files by replacing any `*.sdk` path with the current SDK.
Thus a flag such as
```
-I/Library/Developer/CommandLineTools/SDKs/MacOSX13.sdk/usr/include/ffi
```
would be mapped to
```
-I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
```
when compiling with the macOS 13.3 SDK.
### Result:
The
[`swift-systemlib-demo`](https://github.com/fwcd/swift-systemlib-demo/tree/bb30a9ce6205a503ad85fc112b0e60a4c3a450c4)
package now compiles on macOS.
0 commit comments