From 8f3c7354c73b9e934b4a93f8cbe46caecd50a912 Mon Sep 17 00:00:00 2001 From: Satoshi Qazi Muhammed Date: Mon, 12 Oct 2026 06:17:29 +0400 Subject: [PATCH] Keep build machine paths out of the wasm Panic messages carry source paths, so the 7.5.20 wasm names the home directory it was built in 54 times. Remap the sysroot, the cargo home and the checkout to /rustc, /cargo and /build. --- scripts/build-wasm.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/scripts/build-wasm.sh b/scripts/build-wasm.sh index 7b99b78..cee2196 100755 --- a/scripts/build-wasm.sh +++ b/scripts/build-wasm.sh @@ -16,6 +16,11 @@ DENO_ASM=$DENO_DIR/data.js # build new via wasm-pack echo "*** Building Rust sources" cd $PKG_NAME + +# Panic messages carry source paths. Without this the published wasm names the +# home directory of whoever built it; with it the bytes no longer depend on +# where the toolchain, the registry or the checkout live. +export RUSTFLAGS="${RUSTFLAGS:-} --remap-path-prefix=$(rustc --print sysroot)=/rustc --remap-path-prefix=${CARGO_HOME:-$HOME/.cargo}=/cargo --remap-path-prefix=$PWD=/build" if [ "$RUST_VER" == "stable" ]; then RUSTC_BOOTSTRAP=1 cargo build --target wasm32-unknown-unknown --release -Z build-std=std,panic_abort else