Skip to content

[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

Merged
merged 5 commits into from
Feb 21, 2018

Conversation

AndrewSB
Copy link
Contributor

@compnerd can you proof read this change?

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
Copy link
Collaborator

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.
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

@troughton troughton Feb 12, 2018

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
Copy link
Contributor

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
Copy link
Contributor

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'.

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
Copy link
Contributor

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..."

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
Copy link
Contributor

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.

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: VisualStudio -> Visual Studio


## 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.
Copy link
Contributor

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?

-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>, \
Copy link
Contributor

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.

@@ -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.
Copy link
Contributor

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."

@troughton
Copy link
Contributor

troughton commented Feb 12, 2018

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.

@AndrewSB
Copy link
Contributor Author

AndrewSB commented Feb 13, 2018

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 👍

@AndrewSB AndrewSB force-pushed the who-needs-a-single-doc branch from b712454 to d4a9def Compare February 13, 2018 01:35
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.
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo: MVSC -> MSVC

Copy link
Collaborator

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."

Copy link
Contributor

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.
Copy link
Member

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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

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.
Copy link
Member

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

- 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
Copy link
Member

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.

- 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"
Copy link
Member

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

Copy link
Contributor Author

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

## 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
Copy link
Member

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.

Copy link
Member

@compnerd compnerd left a 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

Copy link
Collaborator

@xwu xwu left a 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
Copy link
Collaborator

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
Copy link
Collaborator

@xwu xwu Feb 21, 2018

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
Copy link
Collaborator

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
Copy link
Collaborator

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
Copy link
Collaborator

@xwu xwu Feb 21, 2018

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."

export VCToolsInstallDir=".../Microsoft Visual Studio/2017/Community"
```

## 2. Setup `visualc` and `ucrt` modules
Copy link
Collaborator

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).

@@ -0,0 +1,44 @@
# Cross-compiling Swift for Windows with `clang`.
Copy link
Collaborator

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.

```

### 3. Upgrade clang
Install a version of clang with C++ 14 support - the default version of clang
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: semicolon, not dash.

```

### 4. Upgrade CMake
Install the latest version of CMake - Swift uses new CMake features such as
Copy link
Collaborator

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.


## 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
Copy link
Collaborator

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"?

Copy link
Contributor Author

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

@AndrewSB AndrewSB force-pushed the who-needs-a-single-doc branch from 83d19c3 to 6a8b1e2 Compare February 21, 2018 04:33
@AndrewSB
Copy link
Contributor Author

Thanks for the proof read @xwu 👍 responded to one or two of your comments, and accepted the rest

@compnerd
Copy link
Member

@swift-ci please test

@compnerd
Copy link
Member

This is a pretty large improvement, I'm going to merge this, and further improvements can be follow ups I think.

@compnerd compnerd merged commit 03590d1 into swiftlang:master Feb 21, 2018
@AndrewSB AndrewSB deleted the who-needs-a-single-doc branch July 24, 2020 06:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants