Open
Description
Attempting to compile a program with EMCC_CFLAGS="-s ERROR_ON_UNDEFINED_SYMBOLS=0" cargo build --target wasm32-unknown-emscripten --release
results in all extern
functions having unpredictable names, whether or not they have #[no_mangle]
.
I tried this code:
extern "C" {
fn foo() -> f64;
}
fn main() {
println!("{}", unsafe { foo() });
}
I expected to see this happen: A generated .js
loader with a stub in wasmImports["foo"]
.
Instead, this happened: The js loader renames the function to a practically random symbol. In this case:
function _foo() {
abort("missing function: foo")
}
_foo.stub = true;
var wasmImports = {
// .. more
y: _foo,
// .. more
};
Meta
Tested against 1.83.0 and latest nightly.
rustc --version --verbose
:
rustc 1.83.0 (90b35a623 2024-11-26)
binary: rustc
commit-hash: 90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf
commit-date: 2024-11-26
host: aarch64-apple-darwin
release: 1.83.0
LLVM version: 19.1.1