State of Standard Library/Runtime Compilation on Windows

Hi all, and particularly Saleem, Hugh, and Han,

I've been recently trying to build the Swift compiler, runtime, and core libraries on Windows against the MSVC runtime from master and have been running into some difficulties. I've managed to get Clang and swiftc built (and I hope to submit pull requests over the weekend with the fixes to enable this), but I've been unable to get the runtime and core libraries to build and link correctly.

My understanding is that this is due to dllimport difficulties when linking the runtime into swiftCore as opposed to against any of the other supporting libraries, as discussed on this list a while ago [topic: swift (ABI) and Windows]. It seems as though changes have been made to the source pertaining to import/export linkage since that discussion (commit 3105c6e), but I'm not sure as to the impact of those changes on the Windows build.

I've attempted cross-compiling from macOS and have run into issues with Mac-specific invocations being passed through to lld-link (which could perhaps be addressed by diving into the CMake configurations for LLVM/Clang but which might cause issues if I want to upstream my changes). Setting CMAKE_SYSTEM_NAME to Windows would likely address this specific issues but raise others, as it appears the Swift configuration assumes that cross-compiling for Windows happens with CMAKE_SYSTEM_NAME unchanged from the build machine.

I've also looked into the MSVC specific instructions at tinysun212 (Han Sang-jin) ยท GitHub, but they seem somewhat incomplete and out of date; for instance, swiftRuntime doesn't seem to be built as a separate library anymore (although I may be mistaken that it ever was).

As a secondary problem, there's also an open issue with regards to the Swift calling convention on Windows (SR-4302) that seems to be on hold; Saleem gave a pointer to a temporary solution but I've been unable to figure out how to implement it.

If any of what I've stated here is incorrect or misinformed, please let me know. I'm willing to do what I can to help the porting effort and possibly eventually Swift development as a whole; my specific aim here is that I'm working on a Swift application that I'd like to bring cross-platform. Unfortunately, I have little experience or knowledge of the Microsoft development stack, so I may need some specific pointers or else to leave the more intricate parts to more experienced minds.

Thomas Roughton