-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
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
Add Darwin support for Swift #37473
Comments
/me subscribes JIC |
Haven't gotten to this yet. Will move to 19.03. |
@matthewbauer Is this still something you want to do for 19.03? |
I think it's best to move it to 19.09 for now. It's not a huge priority and looks a little bit harder than I originally thought. |
Turns out newer versions of |
This is going to become a blocker for us at some point later this year too. |
This comment was marked as outdated.
This comment was marked as outdated.
I was making an attempt at this, but it's very much on-the-side. I don't actually use Swift nor know much about compiler toolchains. Got a decent part of the build going. May look into this a bit more later: stephank@2b035ef |
I marked this as stale due to inactivity. → More info |
I've picked this up again, and am making good progress. Also attempting to upgrade Swift to 5.6.2, and will attempt to fix the currently broken build on Linux as well. |
I realized it's been 3 weeks since I gave an update on this, but I'm still making progress. :) My first attempt was to simply iterate on the existing build to see if I could get it working on Darwin. I spent a good amount of time fighting Swift's I discovered a little late that In both cases I also worked on wrapping the compiler. I'm applying For now I'm working on this new approach on Linux, because the hardware is cheaper to rent. (I have GH Sponsors setup if anyone wants to pitch in with these costs, wink wink) The hope is it'll translate more easily to Darwin, or at least be easier to debug and iterate on. Current stage I'm at (on Linux) is that I have a working Nix build of swiftpm via CMake and can use that to build swiftpm itself outside Nix. I want to make a simple swift2nix like solution to complete the bootstrap by building swiftpm with swiftpm. I found 2 existing swift2nix tools, but they appear to be either outdated, or using It's difficult to share or PR anything at this point, because few things are set in stone. I frequently force push to branches, but that can also change:
So making good progress all in all, but more work than expected. 🙂 |
@stephank are you aware of https://opencollective.com/nix-macos? Also make sure you're not being blocked by our ancient SDK. An optional binary version of SDK11 was merged not too long ago. |
I wasn't! Will look into it.
Yes, it already depends on that, because Swift needs at least 10.15. I started working the day after it was merged. 🙂 |
Two weeks passed, another update: Domen Kožar was kind enough to reimburse the hardware costs via OpenCollective, so that’s great! My time is still my own so far, and I believe I’ve been at this for 2 to 3 days a week for almost two months now. So, bigger effort than expected! I wrote a small bash + jq tool ‘swiftpm2nix’ (to avoid ‘swift2nix’, because there are already two of those) that generates a Nix expression for fetching project dependencies, and a configurePhase snippet that prepares everything for I also added a small setup-hook, so that Using these integrations, I was also able to package other toolchain components: swift-docc, sourcekit-lsp, swift-driver. I’m now tackling issues on Darwin again. I first ran into #181485. This took some debugging, because I was not immediately using the right search terms and trying my own hand at fixing it. After that, I ran into an assertion failure in The reason I went down this path was because I was trying to introduce LLVM >=12 into the build, because Swift uses I was still seeing link errors related to Next, I discovered I’m now at a point where it looks like ObjC interop is using Swift modules that may be binary-only in the macOS SDK, and figuring out what to do with those. |
Sorry for the lack of updates, but there is now a PR: #189977 I was able to get the Swift compiler itself working on Darwin shortly after the last update, but then spent a lot of time tweaking installation details and issues with SwiftPM. There is a lot of Darwin-specific logic in the whole toolchain. So status is that we're able to build basic (CLI) stuff on all platforms using SwiftPM, but I've not yet got it to build a simple SwiftUI app. |
Yes, CLI-based apps should definitely work. Some of the tools from the Swift toolchain itself are Swift CLI apps, like swiftpm and sourcekit-lsp, and they work fine. We should be able to build Cocoa stuff too! I tested a very basic SwiftUI app, and we should also be able to move forward with the Swift components in mpv, for example. There's a follow up PR (to master) that further upgrades to Swift 5.7.3, and fixes using Swift in a Nix shell (or other dev env): #213936 Beyond that, we just have to tackle issues as we go. For example, we did end up finding a compilation issue in the Perfect web framework (cachix/devenv#312 (comment)). So far, that's the only one I know of. But I think we're good to close this issue? |
Yes, thank you so much for your work @stephank! |
Swift should support macOS/iOS correctly. Currently, it's disabled for Darwin stdenvs.
/cc @NixOS/darwin-maintainers
The text was updated successfully, but these errors were encountered: