`rust-lld -flavor wasm` SIGSEGVs when building for `wasm32v1-none`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
I'm building a rather complicated WASM library (pure Rust) inside a Docker container. I've used the GitHub CI to run this Docker container from many hosts (ubuntu-latest, macos-latest, macos-15-intel, windows-latest), and curiously, I've noted a spurious SIGSEGV only from the macos-15-intel host. Unfortunately, I have no idea the root cause, though I can identify what I changed recently (the SIGSEGVs starting just yesterday).
The Dockerfile is (with some minimizations):
# rust:1.91.1-alpine as of December 4th, 2025 (GMT)
FROM --platform=linux/amd64 rust@sha256:84f263251b0ada72c1913d82a824d47be15a607f3faf015d8bdae48db544cdf2 AS builder
RUN rustup target add wasm32v1-none
ADD ...
RUN cargo build --release -p serai-runtime --no-default-features
The build script for the crate then invokes the WASM build itself ensuring a clean environment and some specific flags are passed. The resulting command is approximately:
RUSTFLAGS="-C link-arg=--mllvm=-mcpu=mvp -C link-arg=--mllvm=-mattr=+mutable-globals" # https://github.com/rust-lang/rust/issues/145491
RUSTFLAGS="$RUSTFLAGS -C link-arg=--export-table"
RUSTFLAGS="$RUSTFLAGS -C overflow-checks=true -C panic=abort"
RUSTFLAGS="$RUSTFLAGS -C symbol-mangling-version=v0 -C embed-bitcode=false -C linker-plugin-lto=true"
RUSTFLAGS="$RUSTFLAGS -C debug-assertions=false -C codegen-units=1 -C opt-level=3"
RUSTFLAGS="$RUSTFLAGS -C debuginfo=none -C strip=symbols"
CARGO_INCREMENTAL=false
cargo rustc --package serai-runtime --target wasm32v1-none --crate-type cdylib --no-default-features --release
where I recently added opt-level=3 debuginfo=none and CARGO_INCREMENTAL=false.
The CI has now failed twice with:
error: linking with `rust-lld` failed: signal: 11 (SIGSEGV) (core dumped)
note: "rust-lld" "-flavor" "wasm" "--export=__heap_base" "--export=__data_end" "-z" "stack-size=1048576" "--stack-first" "--allow-undefined" "--no-demangle" "--no-entry" "<2 object files omitted>" "/serai/target/release/build/serai-runtime-be5c2ccf51c8c3f4/out/target/wasm32v1-none/release/deps/{...}.rlib" "<sysroot>/lib/rustlib/wasm32v1-none/lib/{liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "--lto-O3" "-L" "<sysroot>/lib/rustlib/wasm32v1-none/lib/self-contained" "-o" "/serai/target/release/build/serai-runtime-be5c2ccf51c8c3f4/out/target/wasm32v1-none/release/deps/serai_runtime.wasm" "--gc-sections" "--no-entry" "-O3" "--strip-all" "--mllvm=-mcpu=mvp" "--mllvm=-mattr=+mutable-globals" "--export-table"
Please note I minimized a long list of --export and deps/{}.rlib. For the full log, I can cite this GitHub CI: https://github.com/serai-dex/serai/actions/runs/20412702194/job/58652019711
I'm hopeful I've ran into some incompatible/nonsensical linker options, which if I fix on my end, results in this SIGSEGV no longer appearing. I understand, even with the minimal presentation of the issue and cites to my full methodology, if this is too far removed from the root problem to be reasonably diagnosable otherwise. While there are many configurations, I don't believe any unacceptable or too out there however... I also do see my Dockerfile is specifying 1.91.1, so I'll try updating that and see if the problem disappears.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with orchestration/runtime/Dockerfile and substrate/runtime/build.rs, then reproduce the cargo rustc wasm32v1-none command from the linked CI log. Compare the recently added opt-level=3, debuginfo=none, and CARGO_INCREMENTAL=false settings with the linker flags; done means isolating the configuration that triggers the rust-lld SIGSEGV or confirming it persists with the updated toolchain.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, rust, wasm
- Domain
- build-system, compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100