-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Update docs for Bash on Ubuntu on Windows #5671
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
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Getting Started with Swift on Windows | ||
|
||
## MSVC | ||
To be filled in. | ||
|
||
## Windows Subsystem for Linux (WSL) | ||
- Note that all compiled Swift binaries are only executable within Bash on Windows and are Ubunutu, not Windows, executables. | ||
- Make sure to run all commands from Bash, or the project won't compile. | ||
|
||
### 1. Install WSL | ||
Install and run the latest version of [Bash on Ubuntu on Windows](https://msdn.microsoft.com/en-gb/commandline/wsl/about) installed on your PC. | ||
``` | ||
bash | ||
``` | ||
|
||
### 2. Install dependencies | ||
Install the developer dependencies needed to compile the Swift project. These are identical to the Ubuntu dependencies, with the addition of `make`. | ||
```bash | ||
sudo apt-get install git make cmake ninja-build clang python uuid-dev libicu-dev icu-devtools libbsd-dev libedit-dev libxml2-dev libsqlite3-dev swig libpython-dev libncurses5-dev pkg-config libblocksruntime-dev libcurl4-openssl-dev | ||
``` | ||
|
||
### 3. Upgrade clang | ||
Install a version of clang with C++ 14 support - the default version of clang on WSL results in linker errors during compilation. | ||
```bash | ||
sudo apt-get install clang-3.6 | ||
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-3.6 100 | ||
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-3.6 100 | ||
``` | ||
|
||
### 4. Upgrade CMake | ||
Install the latest version of CMake - Swift uses new CMake features such as `IN_LIST` and won't build without these features. | ||
```bash | ||
wget http://www.cmake.org/files/v3.5/cmake-3.6.2.tar.gz | ||
tar xf cmake-3.6.2.tar.gz | ||
cd cmake-3.6.2 | ||
./configure | ||
make | ||
sudo make install | ||
sudo update-alternatives --install /usr/bin/cmake cmake /usr/local/bin/cmake 1 --force | ||
cmake --version # This should print 3.6.2 | ||
``` | ||
|
||
### 6. Clone and build the Swift project | ||
```bash | ||
mkdir swift-source | ||
cd swift-source | ||
git clone https://github.com/apple/swift.git | ||
./swift/utils/update-checkout --clone | ||
./swift/utils/build-script -r | ||
``` | ||
### 7. Hello, Windows (Subsystem for Linux) | ||
```bash | ||
cd ./build/Ninja-RelWithDebInfoAssert/swift-linux-x86_64/bin # This path may depend on your build configuration | ||
echo 'print("Hello, Windows")' >> test.swift | ||
swiftc test.swift | ||
./test # Hello, Windows | ||
``` |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 like how step three explains why a user needs to upgrade Clang. Could you explain here that the version of CMake included by default on WSL is too old to build Swift, and that at the time of this writing 3.4.3 or greater is required?