Skip to content

Commit

Permalink
Switch to Cargo's -Zbuild-std for building libstd (#1796)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
alexcrichton committed Sep 26, 2019
1 parent 6b31777 commit 025b1d8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 13 deletions.
4 changes: 1 addition & 3 deletions azure-pipelines.yml
Expand Up @@ -211,13 +211,11 @@ jobs:
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly-2019-08-27
toolchain: nightly-2019-09-26
# Temporarily disable sccache because it is failing on CI.
# - template: ci/azure-install-sccache.yml
- script: rustup component add rust-src
displayName: "install rust-src"
- script: cargo install xargo
displayName: "install xargo"
- script: |
set -e
sed -i 's/python/#python/' examples/raytrace-parallel/build.sh
Expand Down
2 changes: 0 additions & 2 deletions examples/raytrace-parallel/Xargo.toml

This file was deleted.

24 changes: 16 additions & 8 deletions examples/raytrace-parallel/build.sh
Expand Up @@ -2,16 +2,24 @@

set -ex

# Two critical steps are required here to get this working:
# A few steps are necessary to get this build working which makes it slightly
# nonstandard compared to most other builds.
#
# * First, the Rust standard library needs to be compiled. The default version
# is not compatible with atomics so we need to compile a version, with xargo,
# that is compatible.
# * First, the Rust standard library needs to be recompiled with atomics
# enabled. to do that we use Cargo's unstable `-Zbuild-std` feature.
#
# * Next we need to compile everything with the `atomics` feature enabled,
# ensuring that LLVM will generate atomic instructions and such.
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' \
xargo build --target wasm32-unknown-unknown --release
# * Next we need to compile everything with the `atomics` and `bulk-memory`
# features enabled, ensuring that LLVM will generate atomic instructions,
# shared memory, passive segments, etc.
#
# * Finally, `-Zbuild-std` is still in development, and one of its downsides
# right now is rust-lang/wg-cargo-std-aware#47 where using `rust-lld` doesn't
# work by default, which the wasm target uses. To work around that we find it
# and put it in PATH

PATH=$PATH:$(dirname $(find $(rustc --print sysroot) -name 'rust-lld')) \
RUSTFLAGS='-C target-feature=+atomics,+bulk-memory' \
cargo build --target wasm32-unknown-unknown --release -Z build-std -Z timings=html

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

0 comments on commit 025b1d8

Please sign in to comment.