Radar · Rust · Archive · Week 15 · Apr 6 – 12, 2026
Changes to WebAssembly targets and handling undefined symbols
Worth knowingtooling
- What changed
- The Rust team updated the WebAssembly targets and introduced new handling for undefined symbols.
- Production impact
- The source does not say.
- Try it
- Compile a crate for
wasm32-unknown-unknownand observe the compiler’s behavior when an undefined symbol is referenced. - Source
- blog.rust-lang.org/2026/04/04/changes-to-webassembly-targets-and-handling-undefined-symbols/
Understand it, then run it
Rust WebAssembly binaries are built by a tool called wasm-ld. Until now, the Rust compiler always told wasm-ld to ignore any symbols that were not defined in the code. That flag is called --allow-undefined. The change removes that flag, so now the compiler will error if a symbol is missing, just like on other platforms.
Run it now
// This program demonstrates that extern blocks must be marked unsafe
// in Rust 1.98.1 (edition 2024). The change to WebAssembly targets
// removes the --allow-undefined flag, so any extern function that
// is not linked will cause a compile‑time error unless it is
// explicitly marked unsafe. The following code compiles and
// prints a message, showing the correct usage.
fn main() {
// Define an external C function. The block must be unsafe.
unsafe extern "C" {
fn js_log(n: u32);
}
// We don't actually call js_log here, but the compiler
// accepts the definition because it is marked unsafe.
println!("Extern function declared safely.");
}
What it printed when we ran it on Rust 1.98.1 (edition 2024)
Extern function declared safely.
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed