<div dir="ltr"><div>Hi Eric,</div><div><br></div><div>&gt; Do you mind elaborating on how you got it built with MSVC?</div><div><br></div><div>Sure. I succeeded to build LLVM, clang and Swift compiler with the tag of swift-4.0.2-RELEASE.<br>LLVM and clang seem to work okay and Swift compiler can compile swift sources but the generated exectables crash.</div><div>Here&#39;s my procedure. This is based on <a href="https://github.com/apple/swift/blob/master/docs/Windows.md">https://github.com/apple/swift/blob/master/docs/Windows.md</a>.</div><div><br></div><div># Prerequisite</div><div><br></div><div>* Visaul Stduio 2017<br>* CMake<br>* ninja<br>* Python 2.7 (not Python 3)<br>* Git for Windows<br>Append Cmake, ninja, Python 2.7 and git to your PATH.<br></div><div><br></div><div>I assume your working direcotry is C:\swift.</div><div><br></div><div># ICU</div><div><br></div><div>Download <a href="http://download.icu-project.org/files/icu4c/60.2/icu4c-60_2-src.zip">http://download.icu-project.org/files/icu4c/60.2/icu4c-60_2-src.zip</a> and extract to C:\swift\icu.<br>Open C:\swift\icu\source\allinone.sln with Visual Studio.<br>This file is for Visaul Stduio 2015, so we need convert the project files to use Visual Studio 2017&#39;s toolchian.<br>Right click &#39;allinone&#39; solution in Solution Explorer and select &#39;Re-target the solution&#39;. <br>(I&#39;m not using the English version of Visual Stduio, so the actual representation may differ.)<br>Then change the configuration to Release, x64 and build it.</div><div><br></div><div># Checkout sources</div><div><br></div><div>Open x64 Native Tools Command Prompt of Visual Studio 2017, checkout the repositories and apply the attached patches with this mail.</div><div><br></div><div>VsDevCmd -arch=amd64<br>set swift_source_dir=c:\swift<br>cd \<br>mkdir swift<br>cd swift</div><div><br></div><div>git clone <a href="https://github.com/apple/swift-cmark.git">https://github.com/apple/swift-cmark.git</a><br>mv swift-cmark cmark<br>git checkout swift-4.0.2-RELEASE<br>cd ..</div><div><br></div><div>git clone <a href="https://github.com/apple/swift.git">https://github.com/apple/swift.git</a><br>cd swift<br>git checkout swift-4.0.2-RELEASE<br>patch -p1 &lt; swift.patch<br>cd ..</div><div><br></div><div>git clone <a href="https://github.com/apple/swift-clang.git">https://github.com/apple/swift-clang.git</a><br>move swift-clang clang<br>cd clang<br>git checkout swift-4.0.2-RELEASE<br>patch -p1 &lt; clang.patch<br>cd ..</div><div><br></div><div>git clone <a href="https://github.com/apple/swift-compiler-rt.git">https://github.com/apple/swift-compiler-rt.git</a><br>move swift-compiler-rt compiler-rt<br>cd compiler-rt<br>git checkout swift-4.0.2-RELEASE<br>patch -p1 &lt; compiler-rt.patch<br>cd ..</div><div><br></div><div>git clone <a href="https://github.com/apple/swift-llvm.git">https://github.com/apple/swift-llvm.git</a><br>move swift-llvm llvm<br>cd llvm<br>git checkout swift-4.0.2-RELEASE<br>patch -p1 &lt; llvm.patch<br>cd ..</div><div><br></div><div>mklink /J &quot;%swift_source_dir%/llvm/tools/clang&quot; &quot;%swift_source_dir%/clang&quot;<br>mklink /J &quot;%swift_source_dir%/llvm/tools/compiler-rt&quot; &quot;%swift_source_dir%/compiler-rt&quot;</div><div><br></div><div># Build cmark</div><div><br></div><div>mkdir &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/cmark-windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/cmark-windows-amd64&quot;<br>cmake -G &quot;Ninja&quot; -DCMAKE_BUILD_TYPE=RelWithDebInfo &quot;%swift_source_dir%/cmark&quot;<br>popd<br>cmake --build &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/cmark-windows-amd64/&quot; -- -v</div><div><br></div><div># Build LLVM/clang/compiler-rt</div><div><br></div><div>mkdir &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64&quot;<br>cmake -G &quot;Ninja&quot;^<br> -DCMAKE_BUILD_TYPE=RelWithDebInfo^<br> -DLLVM_ENABLE_ASSERTIONS=TRUE^<br> -DLLVM_TOOL_COMPILER_RT_BUILD=TRUE^<br> -DLLVM_BUILD_EXTERNAL_COMPILER_RT=TRUE^<br> -DCMAKE_C_FLAGS=&quot;/bigobj /DCRT_HAS_128BIT&quot;^<br> -DCMAKE_CXX_FLAGS=&quot;/bigobj /DCRT_HAS_128BIT&quot; ^<br> &quot;%swift_source_dir%/llvm&quot;<br>popd<br>cmake --build &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64&quot; -- -v</div><div><br></div><div># Build swift</div><div><br></div><div>xcopy /s /i &quot;%VCToolsInstallDir%\include&quot; &quot;%swift_source_dir%\build\Ninja-RelWithDebInfo\modules\visualc&quot;<br>copy &quot;%swift_source_dir%\swift\stdlib\public\Platform\visualc.modulemap&quot; &quot;%swift_source_dir%\build\Ninja-RelWithDebInfo\modules\visualc\module.modulemap&quot;<br>xcopy /s /i &quot;%UniversalCRTSdkDir%\Include\%UCRTVersion%\ucrt&quot; &quot;%swift_source_dir%\build\Ninja-RelWithDebInfo\modules\ucrt&quot;<br>copy &quot;%swift_source_dir%\swift\stdlib\public\Platform\ucrt.modulemap&quot; &quot;%swift_source_dir%\build\Ninja-RelWithDebInfo\modules\ucrt\module.modulemap&quot;</div><div><br></div><div>mkdir &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/swift-windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/swift-windows-amd64&quot;<br>cmake -G &quot;Ninja&quot;^<br> -DCMAKE_BUILD_TYPE=RelWithDebInfo^<br> -DCMAKE_C_COMPILER=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64/bin/clang-cl.exe&quot;^<br> -DCMAKE_C_FLAGS=&quot;-fms-compatibility-version=19.00 /Z7&quot;^<br> -DCMAKE_CXX_COMPILER=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64/bin/clang-cl.exe&quot;^<br> -DCMAKE_CXX_FLAGS=&quot;-fms-compatibility-version=19.00 /Z7&quot;^<br> -DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE^<br> -DSWIFT_INCLUDE_DOCS=FALSE^<br> -DSWIFT_INCLUDE_TESTS=FALSE^<br> -DSWIFT_PATH_TO_CMARK_SOURCE=&quot;%swift_source_dir%/cmark&quot;^<br> -DSWIFT_PATH_TO_CMARK_BUILD=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/cmark-windows-amd64&quot;^<br> -DSWIFT_CMARK_LIBRARY_DIR=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/cmark-windows-amd64/src&quot;^<br> -DSWIFT_PATH_TO_LLVM_SOURCE=&quot;%swift_source_dir%/llvm&quot;^<br> -DSWIFT_PATH_TO_LLVM_BUILD=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64&quot;^<br> -DSWIFT_PATH_TO_CLANG_SOURCE=&quot;%swift_source_dir%/llvm/tools/clang&quot;^<br> -DSWIFT_PATH_TO_CLANG_BUILD=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64&quot;^<br> -DSWIFT_RUNTIME_SWIFT_LINK_FLAGS=&quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/llvm-windows-amd64/lib/clang/4.0.0/lib/windows/clang_rt.builtins-x86_64.lib&quot;^<br> -DSWIFT_EXPERIMENTAL_EXTRA_REGEXP_FLAGS=&quot;(MSVCRT|SwiftPrivateLibcExtras);-I%swift_source_dir%/build/Ninja-RelWithDebInfo/modules/visualc;(MSVCRT|SwiftPrivateLibcExtras);-I%swift_source_dir%/build/Ninja-RelWithDebInfo/modules/ucrt&quot;^<br> -DICU_UC_LIB_NAME=&quot;icuuc&quot;^<br> -DICU_UC_LIBRARY_DIRS=&quot;%swift_source_dir%/icu/lib64&quot;^<br> -DICU_UC_INCLUDE_DIRS=&quot;%swift_source_dir%/icu/include&quot;^<br> -DICU_I18N_LIB_NAME=&quot;icuin&quot;^<br> -DICU_I18N_LIBRARY_DIRS=&quot;%swift_source_dir%/icu/lib64&quot;^<br> -DICU_I18N_INCLUDE_DIRS=&quot;%swift_source_dir%/icu/include&quot;^<br> &quot;%swift_source_dir%/swift&quot;<br>popd<br>cmake --build &quot;%swift_source_dir%/build/Ninja-RelWithDebInfo/swift-windows-amd64&quot; -- -v</div><div><br></div><div>I hope your success!</div><div><br></div><div>Kazuki<br></div><div></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-18 10:18 GMT+09:00 Eric Wing <span dir="ltr">&lt;<a href="mailto:ewmailing@gmail.com" target="_blank">ewmailing@gmail.com</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 12/14/17, Kazuki Ohara via swift-dev &lt;<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I&#39;m interested in running Swift on Windows.<br>
&gt;<br>
&gt; I found the document to build the Swift compiler for Windows (<br>
&gt; <a href="https://github.com/apple/swift/blob/master/docs/Windows.md" target="_blank" rel="noreferrer">https://github.com/apple/<wbr>swift/blob/master/docs/<wbr>Windows.md</a>) and tried it.<br>
&gt; I managed to build it with MSVC, but the resulting compiler could not<br>
&gt; generate executables run properly.<br>
&gt; (The executables seem to crash during initializing Swift&#39;s runtime<br>
&gt; systems.)<br>
&gt;<br>
&gt; Are there someone who can build the compiler works properly on Windows with<br>
&gt; master branch or at least 4.x branches?<br>
&gt; I found <a href="https://github.com/tinysun212/swift-windows" target="_blank" rel="noreferrer">https://github.com/tinysun212/<wbr>swift-windows</a>, but this seems to be<br>
&gt; on 3.x branch.<br>
&gt;<br>
&gt; Thank you,<br>
&gt; Kazuki Ohara<br>
&gt;<br>
<br>
Do you mind elaborating on how you got it built with MSVC? I posted<br>
like a month ago to the Swift list that I was unable to even get past<br>
building the LLVM stage due to compile errors.<br>
<br>
Thanks,<br>
Eric<br>
</blockquote></div><br></div>