Swift via MSYS2/MinGW-w64?

I'm one of the volunteer package maintainers for MSYS2's MinGW-w64 ecosystem and I've been interested for a little while in packaging the Swift environment. Apparently support for Windows 10 exists and I saw that UCRT is a requirement. For the past week, the MSYS2 team has started a repo for UCRT and it got me wondering if building a Swift toolchain might work with it?

I'm not sure where I would begin. The Github mentions the use of sccache which I made a package for, but are there any other dependencies I'd need to set up before trying to build Swift itself? Windows build instructions aren't exactly easy to come by.

Some documentation for building is in docs/WindowsBuild.md and docs/WindowsCrossCompile.md . The main use case for sccache is that if you're building multiple times, you can save some time. It's not strictly necessary.

cc @compnerd

I doubt that building with MinGW would work out of the box. There was a significant amount of work that went into the build to ensure that everything was built natively. MinGW diverges in a number of ways (e.g. "auto-import" data patching and the BFD linker is known to not work well enough for Swift, though I know that Martin Storjo has done the work to add MinGW support to lld). If you are trying to simply replace the ucrt DLL, yes, that might work. Otherwise, I fear that this will largely require reviving the old MinGW port.

An important point to remember is that the differences do delve deep enough that the MinGW build and native windows builds will be fundamentally incompatible. Substituting x86_64-unknown-windows-gnu for x86_64-unknown-windows-msvc will not be compatible. i686 MSVC is known to not build, but you should be able to get that to work with MinGW though - the difference is that you would have the missing symbol via "libgcc" (it can be libgcc or compiler-rt).

If there are missing pieces in swift/WindowsBuild.md at main · apple/swift · GitHub, please let me know, I definitely would like to keep that up to date.

Terms of Service

Privacy Policy

Cookie Policy