-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Pass SDK to Compiler when Cross‐Compiling #2617
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
The head ref may contain hidden characters: "sdg\u2010sdk"
Conversation
We should take the viewpoint that all compilation is cross compilation (this is essentially what Xcode does for Apple platforms). There's no need at all to detect and conditionalize this - just pass |
That is what I thought at first too. But then why was it deliberately removed in the past? The last commit to touch this particular code was a commit that deliberately removed |
It was removed for non-Darwin platforms previously; you'd have to ask @compnerd for more info there. But that seems orthogonal to attempting to conditionalize it as you're proposing in this patch. |
Without some sort of condition, this would be nothing but a revert of that commit (+ a new test). Unless that entire commit was a mistake, |
If you mean when building SPM packages, like SPM itself, natively on an Android host, no, it's not necessary. As for the issue of why it was dropped, I believe it has to do with |
@compnerd's commit might be outdated now since these days you are required to pass the -sdk when compiling for Windows. For example, this is how I was able to compile these examples using CMake:
|
At the point that the change was made, I believe that |
Yes, I also need to pass Do you see any harm in that @buttaface? What happens with your native Android toolchain right now if you compile a package with these extra flags: |
That's fine: it is what the SPM in my Swift 5.1.4 package for Android does, termux/termux-packages#4895, since it predates Saleem removing it. I messed with changing |
Okay then it sounds like we should just revert.
I’ll do it in a separate pull request. |
This reapplies -sdk universally. See swiftlang#2617.
This pull request makes SwiftPM pass
-sdk [wherever]
toswiftc
when cross‐compiling. This used to be the case, but regressed since 5.1.3, breaking Android builds.The implementation here makes two assumptions that I would like confirmation on:
-sdk
is necessary for all cross‐compilation, not just for Android. @compnerd-sdk
is not necessary for Android to build itself. @buttafaceIf either turns out to be incorrect, the precise conditions can be adjusted accordingly.
Here is the diff this enables to the Android build script. Notice how without this, the SDK must be specified double, once for SwiftPM and once for
swiftc
.You can also see the results of compiling without the redundant flag before and after this change.