|
4 | 4 | # Requires: |
5 | 5 | # rustup target add wasm32-unknown-unknown |
6 | 6 | # cargo install wasm-pack --version 0.14.0 |
7 | | -# CI sets RUSTUP_TOOLCHAIN=1.83.0 so committed output is reproducible at the MSRV. |
| 7 | +# CI sets RUSTUP_TOOLCHAIN=1.83.0. The committed bytes are canonical on the |
| 8 | +# Linux/amd64 release platform; other host architectures may emit valid but |
| 9 | +# byte-different optimized Wasm. |
8 | 10 | # |
9 | | -# NOTE: RUSTFLAGS is cleared on purpose. A global `target-cpu` (e.g. the common |
| 11 | +# NOTE: RUSTFLAGS is replaced on purpose. A global `target-cpu` (e.g. the common |
10 | 12 | # `~/.cargo/config.toml` with rustflags = ["-C","target-cpu=native"]) resolves to a |
11 | | -# host CPU that is invalid for wasm32 and makes the wasm-bindgen step fail with |
12 | | -# "failed to find intrinsics to enable `clone_ref`". Clearing it avoids that. |
| 13 | +# host CPU that is invalid for wasm32. Remapping the checkout and Cargo registry |
| 14 | +# also prevents macOS/Linux absolute paths from leaking into the committed Wasm. |
13 | 15 | set -eu |
14 | 16 | cd "$(dirname "$0")/.." |
15 | | -RUSTFLAGS="" wasm-pack build crates/receipt-wasm \ |
| 17 | +repo_root=$(pwd) |
| 18 | +cargo_home=${CARGO_HOME:-"$HOME/.cargo"} |
| 19 | +# Populate the registry source directory before deriving canonical remaps. This |
| 20 | +# matters in a fresh CI home where the loop below would otherwise see no crates. |
| 21 | +RUSTFLAGS="" cargo fetch --manifest-path crates/receipt-wasm/Cargo.toml --locked |
| 22 | +separator=$(printf '\037') |
| 23 | +encoded_flags="--remap-path-prefix=$repo_root=/workspace${separator}--remap-path-prefix=$cargo_home=/cargo" |
| 24 | +for registry_source in "$cargo_home"/registry/src/*; do |
| 25 | + [ -d "$registry_source" ] || continue |
| 26 | + encoded_flags="${encoded_flags}${separator}--remap-path-prefix=$registry_source=/cargo/registry/src/index" |
| 27 | +done |
| 28 | +RUSTFLAGS="" CARGO_ENCODED_RUSTFLAGS="$encoded_flags" \ |
| 29 | + wasm-pack build crates/receipt-wasm \ |
16 | 30 | --target web \ |
17 | 31 | --out-dir ../../web/verify/pkg \ |
18 | 32 | --out-name rosalind_verify |
|
0 commit comments