Skip to content

Commit 025b1d8

Browse files
authored
Switch to Cargo's -Zbuild-std for building libstd (#1796)
This commit switches away from `xargo` to using `-Zbuild-std` to building the standard library for the raytrace-parallel example (which needs to rebuild std with new target features).
1 parent 6b31777 commit 025b1d8

File tree

3 files changed

+17
-13
lines changed

3 files changed

+17
-13
lines changed

azure-pipelines.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,11 @@ jobs:
211211
steps:
212212
- template: ci/azure-install-rust.yml
213213
parameters:
214-
toolchain: nightly-2019-08-27
214+
toolchain: nightly-2019-09-26
215215
# Temporarily disable sccache because it is failing on CI.
216216
# - template: ci/azure-install-sccache.yml
217217
- script: rustup component add rust-src
218218
displayName: "install rust-src"
219-
- script: cargo install xargo
220-
displayName: "install xargo"
221219
- script: |
222220
set -e
223221
sed -i 's/python/#python/' examples/raytrace-parallel/build.sh

examples/raytrace-parallel/Xargo.toml

-2
This file was deleted.

examples/raytrace-parallel/build.sh

+16-8
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
set -ex
44

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.
67
#
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.
1010
#
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
1523

1624
# Note the usage of `--no-modules` here which is used to create an output which
1725
# is usable from Web Workers. We notably can't use `--target bundler` since

0 commit comments

Comments
 (0)