-
Notifications
You must be signed in to change notification settings - Fork 77
Support custom host SDK (aka. SDKROOT
)
#266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@adam-fowler Are you able to reproduce the CI error? I didn't think this has touched the behavior if no custom SDK is set, and cannot reproduce in my environments (Windows/5.6.1 & macOS/5.6) either. |
I can't see why this should fail during CI. Running tests locally works fine. Can you merge in latest changes as it is very hard to see which changes are specific to this PR. |
@adam-fowler Do you have time to review this now? |
So as I understand it you have added a new setting With this PR plus the two prior PRs we now have settings |
What is the point of setting SDKROOT env variable and also including |
Could you point out where I may be missing? It feels like any I intentionally want to make:
|
BTW |
Which commands are we talking about here? |
Considering compiling a Swift package on macOS without Xcode (wish this could happen, but just imagine) for iOS. We need to explicitly set the host SDK, or the manifest won’t compile. And we also need to set the target SDK, or the target cannot be supported. So finally it becomes:
Maybe compiling for Android on Windows is easier to imagine:
|
Host SDK is never decided by CLI options. There’re only two sources: |
So what are the reasons you might want to make the "host" sdk configurable? If it is just to compile |
If you don’t need to cross-compile, you’re recommended to set host SDK instead of custom SDK. The latter should be used explicitly for cross-compilation. Also, setting |
The "host" SDK is explicitly set already (when you install Xcode, and as I understand it SDKROOT is set when installing Swift on Windows, I may be wrong there).
So does that mean you only use |
You can have multiple macOS SDKs in parallel. macOS SDKs are standalone and you can extract older or newer SDKs from other versions of Xcode if you want.
At least when compiling to another triple (eg. a custom minimal OS version). I don’t think there should be a second usage. Maybe we should hide it for now, and wait until custom target support? |
So on macOS what do we gain from setting SDKROOT when we can already set the path to the swift compiler? The only thing I can think of is xctest. |
On macOS toolchain and SDK is not tied so closely. Using alternative toolchain doesn’t affect the SDK (thanks to ABI stability). You always need to set SDKROOT if you want to use an SDK outside your current Xcode installation. |
XCTest on macOS is part of the toolchain. Because it is found using |
But can't you use |
|
@adam-fowler Any review? Better get this in 0.5.0 |
BTW, plugins in SwiftPM 5.6+ will also stick to host SDK. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general this looks fine. I'm not sure about the terminology host SDK. I don't remember seeing it anywhere else. Given people who are changing this will know it as SDKROOT call it that.
I'm not including this in 0.5.0 though. As I don't want to rush it in.
@@ -198,17 +198,22 @@ export class SwiftToolchain { | |||
return path.join(stdout.trimEnd(), "usr", "bin"); | |||
} | |||
case "win32": { | |||
// look up runtime library directory for XCTest alternatively | |||
const fallbackPath = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this change it is unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just moved here from L207-209
If you're not including this for 0.5.0, I'll split this pitch into two parts (fixing up target SDK & adding host SDK) and left the former merged first. The current behavior of custom target SDK has some mistakes that need to be addressed. |
This terminology is derived from "host toolchain" in SwiftPM source code. I don't know where |
Given that SwiftPM uses the terminology "destination" to describe the target, I'll update |
host toolchain is a different thing from host sdk |
There is a clear relationship between destination toolchain — destination SDK — destination target triple. Similarly the logic can be applied to host. |
Now that #305 is merged, can we close this |
This PR differentiates host SDK and target SDK, and adds support for setting custom host SDK through "Advanced" configuration.