-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[docs][Windows] Add context and split doc into multiple files #14562
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
docs/Windows.md
Outdated
- Release/RelWithDebInfo modes have not been tested and may not be supported. | ||
- Windows support for Swift is very much a work in progress and may not work on your system. | ||
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers. | ||
NOTE: There is a limitation to building with MVSC: The Swift Runtime can't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General comments:
Spelling: “separate,” not “seperate.”
Spelling: “Visual Studio,” not “VisualStudio.”
Style for written text is “Swift runtime” and “Swift standard library,” not “Swift Runtime” and “stdlib.”
docs/Windows.md
Outdated
@@ -1,216 +1,29 @@ | |||
# Getting Started with Swift on Windows | |||
|
|||
## clang (cross-compiling) | |||
This document summarizes the state of Swift on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this comment adds anything to the reader.
docs/Windows.md
Outdated
export UniversalCRTSdkDir=".../Windows Kits/10" | ||
export VCToolsInstallDir=".../Microsoft Visual Studio/2017/Community" | ||
``` | ||
Currently there are 3 supported ways to build Swift for Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's clearer to spell out 'three' here in full.
docs/Windows.md
Outdated
`${VCToolsInstallDir}/include`. The `ucrt.modulemap` located at | ||
`swift/stdlib/public/Platform/ucrt.modulemap` needs to be copied into | ||
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt`. | ||
1. To cross-compile Swift for Windows from another host using `clang`, see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea of cross-compiling isn't particularly clear if you're not familiar with it, so it might be good to be more explicit here. Something like "to cross-compile Swift for Windows targets from a different host operating system", and maybe add a comment like "Windows Subsystem for Linux provides a convenient way to do this".
You do get into this in a bit more detail later, though, so up to you whether you agree for here.
docs/Windows.md
Outdated
```bash | ||
--extra-cmake-options=-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE,-DCMAKE_AR=<path to llvm-ar>,-DCMAKE_RANLIB=<path to llvm-ranlib>,-DSWIFT_SDKS=WINDOWS,-DSWIFT_WINDOWS_ICU_I18N_INCLUDE=<path to ICU i18n includes>,-DSWIFT_WINDOWS_ICU_UC_INCLUDE=<path to ICU UC includes>,-DSWIFT_WINDOWS_ICU_I18N_LIB=<path to ICU i18n lib>,-DSWIFT_WINDOWS_ICU_UC_LIB=<path to ICU UC lib> | ||
``` | ||
1. To build on Windows using Microsoft Visual Studio Code (MVSC), see [Building |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MSVC = Microsoft Visual Studio Compiler - Visual Studio Code is a different tool.
docs/Windows.md
Outdated
- Windows support for Swift is very much a work in progress and may not work on your system. | ||
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers. | ||
NOTE: There is a limitation to building with MVSC: The Swift Runtime can't be | ||
built. So though it's possible to build the compiler and stdlib, and then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: The first 'So though' should be 'Although', and there should be a comma, not a full stop, before the second 'so'.
docs/WindowsBuild.md
Outdated
1. Using Microsoft Visual Studio Code (MVSC) | ||
|
||
There is a limitation to building MVSC, the Swift Runtime can't be | ||
built. So though it's possible to build the compiler and the stdlib, and use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"There is a limitation to building MVSC, the Swift Runtime can't be built." -> "The Swift runtime can't be built using MSVC; although it's possible to build..."
docs/WindowsBuild.md
Outdated
There is a limitation to building MVSC, the Swift Runtime can't be | ||
built. So though it's possible to build the compiler and the stdlib, and use | ||
built products to compile a Swift program, it won't be possible to run the | ||
binary without seperately obtaining the Swift Runtime. So the `clang-cl` method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again: don't start the sentence with 'so'; if you want to do something like this, start with 'therefore' or 'as such'.
With that said, I'd move this sentence up to the start of the paragraph: "Using clang-cl
is recommended over MSVC for building on Windows.", and then you go into the reasons why.
docs/WindowsBuild.md
Outdated
cmake --build "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja" | ||
``` | ||
|
||
- To create a VisualStudio project, you'll need to change the generator and, if you have a 64 bit processor, specify the generator platform. Note that you may get multiple build errors compiling the `swift` project due to an MSBuild limitation that file paths cannot exceed 260 characters. These can be ignored, as they occur after the build when writing the last build status to a file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: VisualStudio -> Visual Studio
docs/WindowsBuild.md
Outdated
|
||
## Clang-cl | ||
|
||
Follow the instructions for MSVC, but add the following lines to each CMake configuration command. `Clang-cl` 4.0.1 has been tested. You can remove the `SWIFT_BUILD_DYNAMIC_SDK_OVERLAY=FALSE` definition, as overlays are supported with `clang-cl`, as it supports modules. The `Z7` flag is required to produce PDB files that MSVC's `link.exe` can read, and also enables proper stack traces. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is me editing my own change from a while back, but while you're here, could you change the last part of the sentence from ", and also enables proper stack traces." to " and enables proper stack traces." without the comma at the start?
docs/WindowsCrossCompile.md
Outdated
-DSWIFT_SDKS=WINDOWS, \ | ||
-DSWIFT_WINDOWS_ICU_I18N_INCLUDE=<path to ICU i18n includes>, \ | ||
-DSWIFT_WINDOWS_ICU_UC_INCLUDE=<path to ICU UC includes>, \ | ||
-DSWIFT_WINDOWS_ICU_I18N_LIB=<path to ICU i18n lib>, \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These lines are outdated - I've been meaning to correct it for a while. The flags are now -DSWIFT_WINDOWS_ICU_I18N
and -DSWIFT_WINDOWS_ICU_UC
without the _LIB
.
docs/WindowsSubsystemForLinux.md
Outdated
@@ -0,0 +1,52 @@ | |||
# Windows Subsystem for Linux (WSL) | |||
- Note that all compiled Swift binaries are only executable within Bash on Windows and are Ubuntu, not Windows, executables. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be useful here to clarify that we're talking about WSL in a native environment - something like "As well as being used as a cross-compile environment, Windows Subsystem for Linux can natively build and run Ubuntu executables."
I've gone through and added some minor editing and style comments. On the whole, though, thank you for doing this; it should help to make things a lot clearer. I'll add a link here to my incomplete tutorial on how to use WSL for cross-compilation. I was hoping to finish fixing the final few build issues (e.g. around static linking) and submit that tutorial as a PR once the process was fairly smooth, but I unfortunately haven't had time yet; if any of that's useful for you to copy or adapt feel free to. If not, I'll finish it up myself once the compile issues have been completely sorted out. |
Thanks @xwu and @troughton 😄 I'll integrate these suggestions! @troughton: right now I'm just working on getting builds working with clang-cl, but that doc looks really useful for cross compiling. Once it's ready, make a Pull Request targeting WindowsCrossCompile.md 👍 |
b712454
to
d4a9def
Compare
docs/Windows.md
Outdated
@@ -1,216 +1,32 @@ | |||
# Getting Started with Swift on Windows | |||
|
|||
## clang (cross-compiling) | |||
This document summarizes the state of Swift on Windows. One can build and run | |||
Swift natively, or through the Windows Subsystem for Linux. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the fact that this document summarizes the state of Swift on Windows is implicit.
docs/Windows.md
Outdated
```bash | ||
--extra-cmake-options=-DSWIFT_BUILD_RUNTIME_WITH_HOST_COMPILER=FALSE,-DCMAKE_AR=<path to llvm-ar>,-DCMAKE_RANLIB=<path to llvm-ranlib>,-DSWIFT_SDKS=WINDOWS,-DSWIFT_WINDOWS_ICU_I18N_INCLUDE=<path to ICU i18n includes>,-DSWIFT_WINDOWS_ICU_UC_INCLUDE=<path to ICU UC includes>,-DSWIFT_WINDOWS_ICU_I18N_LIB=<path to ICU i18n lib>,-DSWIFT_WINDOWS_ICU_UC_LIB=<path to ICU UC lib> | ||
``` | ||
1. To build on Windows using the Microsoft Visual Studio Compiler (MVSC), see |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: MVSC -> MSVC
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and it stands for "Microsoft Visual C++"--not "Microsoft Visual Studio Compiler."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that @AndrewSB - I was mistaken about the name and should’ve double checked.
docs/Windows.md
Outdated
- Release/RelWithDebInfo modes have not been tested and may not be supported. | ||
- Windows support for Swift is very much a work in progress and may not work on your system. | ||
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers. | ||
Using `clang-cl` is recommended over MVSC for building Swift on Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: MVSC -> MSVC
docs/Windows.md
Outdated
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers. | ||
Using `clang-cl` is recommended over MVSC for building Swift on Windows. | ||
Although it is possible to build the compiler and the standard library with | ||
MVSC, and use those built products to compile a Swift program, it won't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and here
docs/WindowsBuild.md
Outdated
possible to run the binary without seperately obtaining the Swift runtime. On | ||
the other hand, `clang-cl` is able to build the runtime, which makes it | ||
possible to build and run all the components required for Swift natively on | ||
Windows. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: MVSC -> MSVC twice at lease
docs/WindowsBuild.md
Outdated
- Make sure to include `Programming Languages|Visual C++` and `Windows and Web | ||
Development|Universal Windows App Development|Windows SDK` in your | ||
installation. | ||
- Windows SDK 10.0.10240 was tested. Some later versions (e.g. 10.0.14393) are |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what compiler-rt has to do with this. compiler-rt definitely should be okay with 14393.
docs/WindowsBuild.md
Outdated
- While the commands here use MSVC to build, using clang-cl is recommended (see | ||
the **Clang-cl** section below). | ||
```cmd | ||
mkdir "%swift_source_dir%/build/Ninja-DebugAssert/swift-windows-amd64/ninja" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the extra ninja directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doing this in a separate formatting PR, I have a list of 3-4 stylistic changes like this
docs/WindowsCrossCompile.md
Outdated
## 1. Setup Visual Studio Environment Variables | ||
Building for Windows requires that the Visual Studio environment variables are | ||
setup similar to the values on Windows. The following assumes that | ||
`WINKIT_ROOT` points to the path where the Windows 10 SDK is available and that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WINKIT_ROOT
and VC_ROOT
are no longer used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a few comments strewn about
d4a9def
to
9305156
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Just a few copyedits.
docs/Windows.md
Outdated
`${VCToolsInstallDir}/include`. The `ucrt.modulemap` located at | ||
`swift/stdlib/public/Platform/ucrt.modulemap` needs to be copied into | ||
`${UniversalCRTSdkDir}/Include/${UCRTVersion}/ucrt`. | ||
1. To cross-compile Swift for Windows from another host Operating System (using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, minor nit: could you lowercase "Operating System" [sic]?
docs/Windows.md
Outdated
- Using the latest Visual Studio version is recommended. Swift may fail to build with older C++ compilers. | ||
`clang-cl` is recommended over MSVC for building Swift on Windows. | ||
Although it is possible to build the compiler and the standard library with | ||
MSVC, and use those built products to compile a Swift program, it won't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: no comma after "MSVC"; you can add "to" (as in, "and to use") if you think it makes the sentence flow.
docs/Windows.md
Outdated
``` | ||
On the [Windows Subsystem for | ||
Linux](https://docs.microsoft.com/en-us/windows/wsl/about), it's possible to | ||
build and run Swift in a Linux-like enviroment, on Windows. See [the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo.
# Building Swift on Windows | ||
|
||
This document describes how to build Swift for Windows natively. See [the | ||
Windows doc](./Windows.md) for more about what is possible with Swift on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: "Getting Started with Swift on Windows" is the name of that document, not "the Windows doc."
|
||
`clang-cl` is recommended over MSVC for building Swift on Windows. | ||
Although it is possible to build the compiler and the standard library with | ||
MSVC, and use those built products to compile a Swift program, it won't be |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here about comma before "and."
docs/WindowsCrossCompile.md
Outdated
export VCToolsInstallDir=".../Microsoft Visual Studio/2017/Community" | ||
``` | ||
|
||
## 2. Setup `visualc` and `ucrt` modules |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and here (also, sentence vs. title case).
docs/WindowsCrossCompile.md
Outdated
@@ -0,0 +1,44 @@ | |||
# Cross-compiling Swift for Windows with `clang`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency: Sentence ending in period or title case heading without period? It seems the latter choice fits with the rest of the document.
docs/WindowsSubsystemForLinux.md
Outdated
``` | ||
|
||
### 3. Upgrade clang | ||
Install a version of clang with C++ 14 support - the default version of clang |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: semicolon, not dash.
docs/WindowsSubsystemForLinux.md
Outdated
``` | ||
|
||
### 4. Upgrade CMake | ||
Install the latest version of CMake - Swift uses new CMake features such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto here about semicolon versus dash.
docs/WindowsCrossCompile.md
Outdated
|
||
## 3. Configure the runtime to be built with the just built clang | ||
Ensure that we use the tools from the just built LLVM and clang tools to build | ||
the Windows SDK. You will need to pass a few extra options to cmake via the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency: "clang" or "Clang"? "cmake" or "CMake"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the standard we should go for is clang
and CMake
83d19c3
to
6a8b1e2
Compare
Thanks for the proof read @xwu 👍 responded to one or two of your comments, and accepted the rest |
@swift-ci please test |
This is a pretty large improvement, I'm going to merge this, and further improvements can be follow ups I think. |
@compnerd can you proof read this change?