Make Swift work on Windows 7

I'm having problems running an executable on Windows 7, specifically @compnerd's Hello World example using these instructions. I have no problems compiling it, but when I try to run it the program just hangs indefinitely. I'm using VS 2019 with the latest Swift toolchain (from 15th october).

Inspired by this post, I'm attaching the output from WinDebugger:

I know that @compnerd doesn't test Swift on Windows 7, but is there anything the community can do to get Swift working on Windows 7? Outside of just learning Swift, I have absolutely no experience with how a language works or the inner workings of a compiler. I am however willing to help in any way I can with testing and debugging.

CC @compnerd (and thanks for your great work in making Swift run on Windows)

1 Like

I really am doubtful that you can get a fully working Swift environment on Windows 7. The primary reason for that is that there are places where the newer APIs are in use. If you are truly interested in trying to reduce the Windows 10 requirement, I would say you should do it in incremental steps - first get it working on Vista, then on 7.

However, it will be interesting, as AF_UNIX was unsupported until RS2 (Creator's Update), so you definitely will not be able to support that. Symbolic links were unsupported until RS1 I believe, which would mean that portions of Foundation would be unavailable.

The RS5 requirement was chosen not only because it is the current LTSC release but because it has additional kernel level support to enable the full functionality.

As to the attached screenshot, it seems to be hitting a breakpoint really early - in the loader trying to map a data directory. I would suggest that you take a look at the headers and identify what it is unhappy about. It might be easiest to do this by looking at the parameter to the RtlImageDirectoryEntryToData. In particular, formal argument 1 and formal argument 3 are interesting (image base and directory entry index respectively).


Just so that I'm understanding you correctly; Even if I somehow resolve the issue I'm still going to have an uphill battle getting Swift to work on Win 7? And I will never be able to use the full Foundation framework?

How about future language features like Result Builders, Concurrency, C++ interop etc.? Do you know if they are/will be designed to work on Win 7 with no extra steps needed, or is there an off-chance that one has to do some extra work to get those features to work?

It seems that I´m in way deeper than I thought, and that it's going to take someone who is way more knowledgeable than me to properly get it to work. I'll debug according to you last paragraph, but since i'm completely new to these things I'm taking a stab in the dark. I'll let you know if I find anything useful, thanks again for your help!

Wasn't Vista release earlier than 7, which would make Vista a target that's harder to support than 7? Were you referring to 8 here instead of Vista?


Yes; the desired progression here would be Windows 8 -> Windows 7.

I imagine so as there are a lot of implicit assumptions about Windows 10.

I don't see a good path. I think, theoretically, if you were to write a file system driver to emulate the symbolic links, you might be able to do it, but its definitely going to make it more complicated to use the full Foundation framework.

Difficult to say - but for the C++ interop, I can easily imagine extra steps required there as there is no ABI stability for C++, and so you would need to deal with the ABI differences and the lower C++ standard.

Additionally, IIRC, ucrt was introduced in Windows 8, but was incomplete, so you will likely have to deal with the C runtime differences as well. Fortunately, I just removed the MSVCRT module, so you should be able to at least reclaim that as you would need MSVCRT support and to disable the use of ucrt module from the Swift stdlib as well.

I understand. It seems that I have to look for another solution than Swift for Win 7 then. Thanks for your time and I hope the Swift story can become just as successful on Windows as it is on Darwin.

1 Like

I’m curious how rust is providing windows 7+ support with MinGW and MSVC. Can the Swift toolchain follow something similar?

1 Like
Terms of Service

Privacy Policy

Cookie Policy