|
2 | 2 |
|
3 | 3 | set -ex
|
4 | 4 |
|
5 |
| -# Two critical steps are required here to get this working: |
| 5 | +# A few steps are necessary to get this build working which makes it slightly |
| 6 | +# nonstandard compared to most other builds. |
6 | 7 | #
|
7 |
| -# * First, the Rust standard library needs to be compiled. The default version |
8 |
| -# is not compatible with atomics so we need to compile a version, with xargo, |
9 |
| -# that is compatible. |
| 8 | +# * First, the Rust standard library needs to be recompiled with atomics |
| 9 | +# enabled. to do that we use Cargo's unstable `-Zbuild-std` feature. |
10 | 10 | #
|
11 |
| -# * Next we need to compile everything with the `atomics` feature enabled, |
12 |
| -# ensuring that LLVM will generate atomic instructions and such. |
13 |
| -RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' \ |
14 |
| - xargo build --target wasm32-unknown-unknown --release |
| 11 | +# * Next we need to compile everything with the `atomics` and `bulk-memory` |
| 12 | +# features enabled, ensuring that LLVM will generate atomic instructions, |
| 13 | +# shared memory, passive segments, etc. |
| 14 | +# |
| 15 | +# * Finally, `-Zbuild-std` is still in development, and one of its downsides |
| 16 | +# right now is rust-lang/wg-cargo-std-aware#47 where using `rust-lld` doesn't |
| 17 | +# work by default, which the wasm target uses. To work around that we find it |
| 18 | +# and put it in PATH |
| 19 | + |
| 20 | +PATH=$PATH:$(dirname $(find $(rustc --print sysroot) -name 'rust-lld')) \ |
| 21 | + RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' \ |
| 22 | + cargo build --target wasm32-unknown-unknown --release -Z build-std -Z timings=html |
15 | 23 |
|
16 | 24 | # Note the usage of `--no-modules` here which is used to create an output which
|
17 | 25 | # is usable from Web Workers. We notably can't use `--target bundler` since
|
|
0 commit comments