[swift-build-dev] swiftpm macOS target override

Keith Smiley k at keith.so
Tue Sep 20 16:44:02 CDT 2016


Hey everyone,

I noticed today that currently it doesn't seem possible to build to a macOS
target with a deployment target greater than 10.10 with swiftpm, since 10.10 is
currently hardcoded in the swiftpm source[0].

This means that right now if you attempt to do something like:

$ swift build --verbose -Xswiftc -target -Xswiftc x86_64-apple-macosx10.11

You'll notice that this target is not sent to the first invocation of swiftc
(I'm not sure if this is a problem or not):

```
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc --driver-mode=swift -I /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm -L /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/pm -lPackageDescription -target x86_64-apple-macosx10.10 ...
```

And you'll see that the 10.11 target specification is overridden with the
default value when sent to swift-build-tool:

```
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-build-tool -f ... -v /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc ... -target x86_64-apple-macosx10.11 -target x86_64-apple-macosx10.10 ...
```

I have a few questions about this:

- In the long term what's the plan for moving this out of being hard coded in
  swiftpm? If there is one, are there some starter tasks I could grab?
- In the short term would it make sense for us to reorder the user's args vs the
  default args in the few[1] uses[2] of these hardcoded args?

Lastly if there has been any discussion about this previously I'd love to see it!

[0]: https://github.com/apple/swift-package-manager/blob/57c5be1db1c1e12e089dff02241ffbce5722fb0e/Sources/Commands/UserToolchain.swift#L34-L39
[1]: https://github.com/apple/swift-package-manager/blob/64a4183e83f41e0c54791b03b86ab17f95fb93d4/Sources/Build/describe().swift#L41
[2]: https://github.com/apple/swift-package-manager/blob/64a4183e83f41e0c54791b03b86ab17f95fb93d4/Sources/Build/describe().swift#L76


Thanks for reading!

--
Keith Smiley



More information about the swift-build-dev mailing list