Stream: rust-toolchain

Topic: Wasm linker bug?


view this post on Zulip Andriy Berestovskyy (May 20 2025 at 19:58):

Hey folks,
While compiling a wasm32 canister on ICP, I bumped into a linking error which boils down to this simple repro:

#[unsafe(export_name = "name with spaces")]
pub fn name() {}

Compiling it with Rust 1.84-1.87 both for wasm32-unknown-unknown and x86_64 gives the syntax error in VERSION script error.

Here is the repro: https://github.com/berestovskyy/linker-bug

I also found two workarounds:

  1. Specifying the target directly in the command line: cargo build --target=wasm32-unknown-unknown. This does not work though on the latest Rust nightly... :(
  2. Removing spaces from the exported function (not a real workaround for the ICP, but listing it here for completeness).

The nightly produces a more specific ; expected, but got with error:

Compilation log on 1.89.0-nightly (47c911e9e 2025-05-14)

Does this mean that the exports with spaces soon won't be supported by the toolchain?

A repro for `wasm32` linker bug. Contribute to berestovskyy/linker-bug development by creating an account on GitHub.

view this post on Zulip Alex Crichton (May 20 2025 at 21:11):

The error message you've linked here looks like it's for compiling to native, e.g. "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" is in the arguments, so are you sure this is project compiled to wasm?

view this post on Zulip Andriy Berestovskyy (May 20 2025 at 21:28):

Apologies, I think I confused rust-toolchain.toml (targets to install) and .cargo/config.toml (target to build). That's why adding an explicit target was fixing the issue...


Last updated: Dec 06 2025 at 05:03 UTC