|
1 | 1 | # How to build toolchain
|
2 | 2 |
|
| 3 | +This document describes how to build the toolchain for WebAssembly. |
| 4 | +This is just a quick guide, so if you want to know more about the toolchain, it might be good entry point to read [continuous integration scripts](https://github.com/swiftwasm/swift/blob/swiftwasm/.github/workflows/build-toolchain.yml). |
| 5 | +Or you can ask questions in GitHub issues or SwiftWasm Discord server (see [the official website](https://swiftwasm.org) for the link). |
| 6 | + |
3 | 7 | ## 1. Checkout the project source code.
|
4 | 8 |
|
5 | 9 | ```sh
|
6 | 10 | $ mkdir swiftwasm-source
|
7 | 11 | $ cd swiftwasm-source
|
8 | 12 | $ git clone https://github.com/swiftwasm/swift.git
|
9 |
| -$ ./swift/utils/update-checkout --scheme wasm --clone |
| 13 | +$ ./swift/utils/update-checkout --clone --scheme wasm |
10 | 14 | ```
|
11 | 15 |
|
12 | 16 | ## 2. Install required dependencies
|
13 | 17 |
|
14 |
| -Before building Swift, please install required dependencies. |
| 18 | +1. [Please follow the upstream instruction](https://github.com/apple/swift/blob/main/docs/HowToGuides/GettingStarted.md#installing-dependencies) |
| 19 | +2. Download WebAssembly specific build toolchain |
15 | 20 |
|
16 | 21 | ```sh
|
17 |
| -# On macOS |
18 |
| -$ brew install cmake ninja llvm sccache wasmer |
19 |
| -$ ./utils/webassembly/macos/install-dependencies.sh |
20 |
| -# On Linux |
21 |
| -$ ./utils/webassembly/linux/install-dependencies.sh |
| 22 | +$ ./swift/utils/webassembly/install-build-sdk.sh |
22 | 23 | ```
|
23 | 24 |
|
24 |
| -## 3. Build using custom preset options |
| 25 | +3. (If you want to run test suite) Install [`Wasmer`](https://wasmer.io/) |
25 | 26 |
|
26 |
| -We support both Linux and macOS to build Swift. You need to select the preset name, `sccache` path and LLVM tools directory. |
| 27 | +## 3. Build the toolchain |
27 | 28 |
|
| 29 | +`./swift/utils/webassembly/build-toolchain.sh` will build: |
28 | 30 |
|
29 |
| -```sh |
30 |
| -# On macOS |
31 |
| -$ ./utils/build-script \ |
32 |
| - --preset=webassembly-macos-target \ |
33 |
| - --preset-file ./utils/webassembly/build-presets.ini \ |
34 |
| - SOURCE_PATH=$(dirname $(pwd)) \ |
35 |
| - LLVM_BIN_DIR=/usr/local/opt/llvm/bin \ |
36 |
| - C_CXX_LAUNCHER=$(which sccache) |
37 |
| -# On Linux |
38 |
| -$ ./utils/build-script \ |
39 |
| - --preset=webassembly-linux-target \ |
40 |
| - --preset-file ./utils/webassembly/build-presets.ini \ |
41 |
| - SOURCE_PATH=$(dirname $(pwd)) \ |
42 |
| - LLVM_BIN_DIR=/usr/local/opt/llvm/bin \ |
43 |
| - C_CXX_LAUNCHER=$(which sccache) |
44 |
| -``` |
| 31 | +1. Swift compiler that can compile Swift code to WebAssembly support |
| 32 | +2. Swift standard library and core libraries for WebAssembly |
45 | 33 |
|
46 |
| -Or if you want to build whole toolchain, please use `./utils/webassembly/build-toolchain.sh`. This script builds compiler, Swift Standard Library for host environment (e.g. macOS or Linux) and target environment (`wasm32-unknown-wasi`), Foundation and other packages. So it takes longer time than the above script. |
47 | 34 |
|
48 |
| -```bash |
49 |
| -$ ./utils/webassembly/build-toolchain.sh |
| 35 | +## Build on Docker |
| 36 | + |
| 37 | +You can also build the toolchain on Docker image used in CI. |
| 38 | + |
| 39 | +```sh |
| 40 | +$ docker volume create oss-swift-package |
| 41 | +$ docker run --name swiftwasm-ci-buildbot \ |
| 42 | + -dit \ |
| 43 | + -w /home/build-user/ \ |
| 44 | + -v $PWD/swift:/home/build-user/swift \ |
| 45 | + -v oss-swift-package:/home/build-user \ |
| 46 | + ghcr.io/swiftwasm/swift-ci:main-ubuntu-20.04 |
| 47 | +$ docker exec swiftwasm-ci-buildbot ./swift/utils/webassembly/ci.sh |
| 48 | +$ docker cp swiftwasm-ci-buildbot:/home/build-user/swift-wasm-DEVELOPMENT-SNAPSHOT-*-ubuntu-20.04.tar.gz . |
50 | 49 | ```
|
51 | 50 |
|
52 |
| -If you want to get more information about build system, please feel free to ask @kateinoigakukun on Twitter or GitHub. |
0 commit comments