<div dir="ltr"><div>There was small mistake.</div><div>Wrong: <span style="text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;direction:ltr;float:none;background-color:transparent">set swift_source_dir=c:\swift</span></div><div>Correct: <span style="text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;direction:ltr;float:none;background-color:transparent">set swift_source_dir=c:/swift</span></div><div><span style="text-align:left;color:rgb(34,34,34);text-transform:none;text-indent:0px;letter-spacing:normal;font-family:arial,sans-serif;font-size:14px;font-style:normal;font-variant:normal;font-weight:400;text-decoration:none;word-spacing:0px;display:inline;white-space:normal;direction:ltr;float:none;background-color:transparent"><br></span></div><div>Thanks,</div><div>Kazuki</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-12-19 2:00 GMT+09:00 Kazuki Ohara via swift-dev <span dir="ltr">&lt;<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>&gt;</span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">https://github.com/apple/<wbr>swift/blob/master/docs/<wbr>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" target="_blank">http://download.icu-project.<wbr>org/files/icu4c/60.2/icu4c-60_<wbr>2-src.zip</a> and extract to C:\swift\icu.<br>Open C:\swift\icu\source\allinone.<wbr>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" target="_blank">https://github.com/apple/<wbr>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" target="_blank">https://github.com/apple/<wbr>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" target="_blank">https://github.com/apple/<wbr>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" target="_blank">https://github.com/apple/<wbr>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" target="_blank">https://github.com/apple/<wbr>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/<wbr>tools/clang&quot; &quot;%swift_source_dir%/clang&quot;<br>mklink /J &quot;%swift_source_dir%/llvm/<wbr>tools/compiler-rt&quot; &quot;%swift_source_dir%/compiler-<wbr>rt&quot;</div><div><br></div><div># Build cmark</div><div><br></div><div>mkdir &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64&quot;<br>cmake -G &quot;Ninja&quot; -DCMAKE_BUILD_TYPE=<wbr>RelWithDebInfo &quot;%swift_source_dir%/cmark&quot;<br>popd<br>cmake --build &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>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/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64&quot;<br>cmake -G &quot;Ninja&quot;^<br> -DCMAKE_BUILD_TYPE=<wbr>RelWithDebInfo^<br> -DLLVM_ENABLE_ASSERTIONS=<wbr>TRUE^<br> -DLLVM_TOOL_COMPILER_RT_<wbr>BUILD=TRUE^<br> -DLLVM_BUILD_EXTERNAL_<wbr>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/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>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\<wbr>Ninja-RelWithDebInfo\modules\<wbr>visualc&quot;<br>copy &quot;%swift_source_dir%\swift\<wbr>stdlib\public\Platform\<wbr>visualc.modulemap&quot; &quot;%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>visualc\module.modulemap&quot;<br>xcopy /s /i &quot;%UniversalCRTSdkDir%\Include\<wbr>%UCRTVersion%\ucrt&quot; &quot;%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>ucrt&quot;<br>copy &quot;%swift_source_dir%\swift\<wbr>stdlib\public\Platform\ucrt.<wbr>modulemap&quot; &quot;%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>ucrt\module.modulemap&quot;</div><div><br></div><div>mkdir &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>windows-amd64&quot;<br>pushd &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>windows-amd64&quot;<br>cmake -G &quot;Ninja&quot;^<br> -DCMAKE_BUILD_TYPE=<wbr>RelWithDebInfo^<br> -DCMAKE_C_COMPILER=&quot;%swift_<wbr>source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64/bin/clang-cl.exe&quot;^<br> -DCMAKE_C_FLAGS=&quot;-fms-<wbr>compatibility-version=19.00 /Z7&quot;^<br> -DCMAKE_CXX_COMPILER=&quot;%swift_<wbr>source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64/bin/clang-cl.exe&quot;^<br> -DCMAKE_CXX_FLAGS=&quot;-fms-<wbr>compatibility-version=19.00 /Z7&quot;^<br> -DSWIFT_BUILD_RUNTIME_WITH_<wbr>HOST_COMPILER=FALSE^<br> -DSWIFT_INCLUDE_DOCS=FALSE^<br> -DSWIFT_INCLUDE_TESTS=FALSE^<br> -DSWIFT_PATH_TO_CMARK_SOURCE=<wbr>&quot;%swift_source_dir%/cmark&quot;^<br> -DSWIFT_PATH_TO_CMARK_BUILD=&quot;<wbr>%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64&quot;^<br> -DSWIFT_CMARK_LIBRARY_DIR=&quot;%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/cmark-windows-<wbr>amd64/src&quot;^<br> -DSWIFT_PATH_TO_LLVM_SOURCE=&quot;<wbr>%swift_source_dir%/llvm&quot;^<br> -DSWIFT_PATH_TO_LLVM_BUILD=&quot;%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64&quot;^<br> -DSWIFT_PATH_TO_CLANG_SOURCE=<wbr>&quot;%swift_source_dir%/llvm/<wbr>tools/clang&quot;^<br> -DSWIFT_PATH_TO_CLANG_BUILD=&quot;<wbr>%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64&quot;^<br> -DSWIFT_RUNTIME_SWIFT_LINK_<wbr>FLAGS=&quot;%swift_source_dir%/<wbr>build/Ninja-RelWithDebInfo/<wbr>llvm-windows-amd64/lib/clang/<wbr>4.0.0/lib/windows/clang_rt.<wbr>builtins-x86_64.lib&quot;^<br> -DSWIFT_EXPERIMENTAL_EXTRA_<wbr>REGEXP_FLAGS=&quot;(MSVCRT|<wbr>SwiftPrivateLibcExtras);-I%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/modules/<wbr>visualc;(MSVCRT|<wbr>SwiftPrivateLibcExtras);-I%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/modules/ucrt&quot;^<br> -DICU_UC_LIB_NAME=&quot;icuuc&quot;^<br> -DICU_UC_LIBRARY_DIRS=&quot;%<wbr>swift_source_dir%/icu/lib64&quot;^<br> -DICU_UC_INCLUDE_DIRS=&quot;%<wbr>swift_source_dir%/icu/include&quot;<wbr>^<br> -DICU_I18N_LIB_NAME=&quot;icuin&quot;^<br> -DICU_I18N_LIBRARY_DIRS=&quot;%<wbr>swift_source_dir%/icu/lib64&quot;^<br> -DICU_I18N_INCLUDE_DIRS=&quot;%<wbr>swift_source_dir%/icu/include&quot;<wbr>^<br> &quot;%swift_source_dir%/swift&quot;<br>popd<br>cmake --build &quot;%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>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" target="_blank">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/swift<wbr>/blob/master/docs/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>
<br>______________________________<wbr>_________________<br>
swift-dev mailing list<br>
<a href="mailto:swift-dev@swift.org">swift-dev@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-dev" target="_blank" rel="noreferrer">https://lists.swift.org/<wbr>mailman/listinfo/swift-dev</a><br>
<br></blockquote></div><br></div>