<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"><<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>></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>> 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'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's toolchian.<br>Right click 'allinone' solution in Solution Explorer and select 'Re-target the solution'. <br>(I'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 < 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 < 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 < 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 < llvm.patch<br>cd ..</div><div><br></div><div>mklink /J "%swift_source_dir%/llvm/<wbr>tools/clang" "%swift_source_dir%/clang"<br>mklink /J "%swift_source_dir%/llvm/<wbr>tools/compiler-rt" "%swift_source_dir%/compiler-<wbr>rt"</div><div><br></div><div># Build cmark</div><div><br></div><div>mkdir "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64"<br>pushd "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64"<br>cmake -G "Ninja" -DCMAKE_BUILD_TYPE=<wbr>RelWithDebInfo "%swift_source_dir%/cmark"<br>popd<br>cmake --build "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64/" -- -v</div><div><br></div><div># Build LLVM/clang/compiler-rt</div><div><br></div><div>mkdir "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64"<br>pushd "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64"<br>cmake -G "Ninja"^<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="/bigobj /DCRT_HAS_128BIT"^<br> -DCMAKE_CXX_FLAGS="/bigobj /DCRT_HAS_128BIT" ^<br> "%swift_source_dir%/llvm"<br>popd<br>cmake --build "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64" -- -v</div><div><br></div><div># Build swift</div><div><br></div><div>xcopy /s /i "%VCToolsInstallDir%\include" "%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>visualc"<br>copy "%swift_source_dir%\swift\<wbr>stdlib\public\Platform\<wbr>visualc.modulemap" "%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>visualc\module.modulemap"<br>xcopy /s /i "%UniversalCRTSdkDir%\Include\<wbr>%UCRTVersion%\ucrt" "%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>ucrt"<br>copy "%swift_source_dir%\swift\<wbr>stdlib\public\Platform\ucrt.<wbr>modulemap" "%swift_source_dir%\build\<wbr>Ninja-RelWithDebInfo\modules\<wbr>ucrt\module.modulemap"</div><div><br></div><div>mkdir "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>windows-amd64"<br>pushd "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>windows-amd64"<br>cmake -G "Ninja"^<br> -DCMAKE_BUILD_TYPE=<wbr>RelWithDebInfo^<br> -DCMAKE_C_COMPILER="%swift_<wbr>source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64/bin/clang-cl.exe"^<br> -DCMAKE_C_FLAGS="-fms-<wbr>compatibility-version=19.00 /Z7"^<br> -DCMAKE_CXX_COMPILER="%swift_<wbr>source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64/bin/clang-cl.exe"^<br> -DCMAKE_CXX_FLAGS="-fms-<wbr>compatibility-version=19.00 /Z7"^<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>"%swift_source_dir%/cmark"^<br> -DSWIFT_PATH_TO_CMARK_BUILD="<wbr>%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/cmark-<wbr>windows-amd64"^<br> -DSWIFT_CMARK_LIBRARY_DIR="%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/cmark-windows-<wbr>amd64/src"^<br> -DSWIFT_PATH_TO_LLVM_SOURCE="<wbr>%swift_source_dir%/llvm"^<br> -DSWIFT_PATH_TO_LLVM_BUILD="%<wbr>swift_source_dir%/build/Ninja-<wbr>RelWithDebInfo/llvm-windows-<wbr>amd64"^<br> -DSWIFT_PATH_TO_CLANG_SOURCE=<wbr>"%swift_source_dir%/llvm/<wbr>tools/clang"^<br> -DSWIFT_PATH_TO_CLANG_BUILD="<wbr>%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/llvm-<wbr>windows-amd64"^<br> -DSWIFT_RUNTIME_SWIFT_LINK_<wbr>FLAGS="%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"^<br> -DSWIFT_EXPERIMENTAL_EXTRA_<wbr>REGEXP_FLAGS="(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"^<br> -DICU_UC_LIB_NAME="icuuc"^<br> -DICU_UC_LIBRARY_DIRS="%<wbr>swift_source_dir%/icu/lib64"^<br> -DICU_UC_INCLUDE_DIRS="%<wbr>swift_source_dir%/icu/include"<wbr>^<br> -DICU_I18N_LIB_NAME="icuin"^<br> -DICU_I18N_LIBRARY_DIRS="%<wbr>swift_source_dir%/icu/lib64"^<br> -DICU_I18N_INCLUDE_DIRS="%<wbr>swift_source_dir%/icu/include"<wbr>^<br> "%swift_source_dir%/swift"<br>popd<br>cmake --build "%swift_source_dir%/build/<wbr>Ninja-RelWithDebInfo/swift-<wbr>windows-amd64" -- -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"><<a href="mailto:ewmailing@gmail.com" target="_blank">ewmailing@gmail.com</a>></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 <<a href="mailto:swift-dev@swift.org" target="_blank">swift-dev@swift.org</a>> wrote:<br>
> Hi,<br>
><br>
> I'm interested in running Swift on Windows.<br>
><br>
> I found the document to build the Swift compiler for Windows (<br>
> <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>
> I managed to build it with MSVC, but the resulting compiler could not<br>
> generate executables run properly.<br>
> (The executables seem to crash during initializing Swift's runtime<br>
> systems.)<br>
><br>
> Are there someone who can build the compiler works properly on Windows with<br>
> master branch or at least 4.x branches?<br>
> 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>
> on 3.x branch.<br>
><br>
> Thank you,<br>
> Kazuki Ohara<br>
><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>