fix(make): wasm copies the module it just built, and CI tests the Go host

The remap sat in target.wasm32-wasip1.rustflags, which cargo drops whole once
RUSTFLAGS is set: RUSTFLAGS=-Dwarnings make wasm wrote a module with five
/Users/z/.cargo paths in it. It now goes in CARGO_ENCODED_RUSTFLAGS, which
outranks every other source, and that build gives 9d28969b again. The build
names --target-dir target, so a CARGO_TARGET_DIR no longer sends it elsewhere
while an older module is copied. wasm needs prepare, as build and test do, and
rust-toolchain.toml lists wasm32-wasip1, so rustup installs it.

The Makefile said the bytes are the same wherever they are built. They are the
same on one kind of host, whatever the directories. Across hosts they are not:
cargo hashes the host into every crate that has a build script or uses a proc
macro, and this Mac, Linux arm64 and Linux x86_64 build 9d28969b, 2b40ba79 and
5648efc6, code sections and all. So CI cannot compare its build with the
committed one byte for byte. It runs the Go tests on the committed module, and
again on the one it builds from the crates beside it.

Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
2026-09-19 05:45:01 -07:00
co-authored by Hanzo Dev
parent 197122fe64
commit 6d9fa24d24
3 changed files with 35 additions and 8 deletions
+19 -8
View File
@@ -42,16 +42,27 @@ test: prepare
# socket, clock or random source. A change that grows that list has given the
# loop an effect of its own.
#
# The copy is committed, so it is built to be the same bytes wherever it is
# built: no DWARF, which spells out the build directory, and the cargo home
# written as /cargo in the panic locations the dependencies carry. The name
# section stays, so a trap still says which function it stopped in.
# The copy is committed, so no path of the machine that built it goes in: no
# DWARF, which spells out the build directory, and the cargo home written as
# /cargo in the panic locations the dependencies carry. Two builds on one kind
# of host are then the same bytes, whatever their directories. Two kinds of
# host are not: cargo hashes the host into every crate that has a build script
# or uses a proc macro, and into every crate built on one, and the module
# differs with those hashes, code and all. macOS arm64, Linux arm64 and Linux
# x86_64 each build a different one.
# The name section stays, so a trap still says which function it stopped in.
#
# The remap goes in CARGO_ENCODED_RUSTFLAGS because cargo takes that over every
# other source of rustflags; any other source is dropped whole the moment a
# RUSTFLAGS is set, remap and all. The target directory is named too:
# CARGO_TARGET_DIR would send the build elsewhere, and the copy would be
# whatever an older build left here.
CARGO_HOME ?= $(HOME)/.cargo
wasm:
@$(CARGO) build --locked --release --target wasm32-wasip1 -p dev-ffi \
wasm: prepare
@CARGO_ENCODED_RUSTFLAGS='--remap-path-prefix=$(CARGO_HOME)=/cargo' \
$(CARGO) build --locked --release --target wasm32-wasip1 --target-dir target -p dev-ffi \
--config 'profile.release.debug=false' \
--config 'profile.release.strip="debuginfo"' \
--config 'target.wasm32-wasip1.rustflags=["--remap-path-prefix=$(CARGO_HOME)=/cargo"]'
--config 'profile.release.strip="debuginfo"'
@install -m 644 target/wasm32-wasip1/release/dev.wasm go/dev.wasm
## test-upstream: run the upstream suite against the pinned submodule
+15
View File
@@ -70,6 +70,21 @@ test:
./target/debug/dev --version
./target/debug/dev --help >/dev/null
# go/ is the Go host, and it embeds go/dev.wasm: crates/protocol, core and
# ffi built for wasm and committed. Its tests run on that module, which is
# what a Go build importing the package gets, and again on one built here
# from the crates beside it, which is the core the next `make wasm` commits.
# The two are not compared byte for byte: cargo hashes the build host into
# the module, so one built on this linux-amd64 runner is never the bytes of
# one built on a Mac.
- name: go
run: |
set -euo pipefail
export PATH="$HOME/.cargo/bin:$PATH"
(cd go && GOWORK=off go test -race ./...)
make wasm
cd go && GOWORK=off go test -race ./...
- name: test
run: |
set -euo pipefail
+1
View File
@@ -1,3 +1,4 @@
[toolchain]
channel = "1.95.0"
profile = "minimal"
targets = ["wasm32-wasip1"]