Closed
Description
opened on Dec 20, 2019
Repro https://github.com/EmbarkStudios/missing-symbols rustc 1.40.0 (73528e339 2019-12-16)
// lib.rs
#[no_mangle]
#[used]
pub static FOO: u64 = 4242;
cargo build --release --target wasm32-unknown-unknown
, the resulting wasm file doesn't have the symbol FOO
.
(module
(table (;0;) 1 1 funcref)
(memory (;0;) 16)
(global (;0;) (mut i32) (i32.const 1048576))
(global (;1;) i32 (i32.const 1048576))
(global (;2;) i32 (i32.const 1048576))
(export "memory" (memory 0))
(export "__data_end" (global 1))
(export "__heap_base" (global 2)))
But if we compile with -C link-dead-code
, the symbol is correctly exported in the wasm file.
RUSTFLAGS="-C link-dead-code" cargo build --release --target wasm32-unknown-unknown
(module
(table (;0;) 1 1 funcref)
(memory (;0;) 17)
(global (;0;) (mut i32) (i32.const 1048576))
(global (;1;) i32 (i32.const 1048584))
(global (;2;) i32 (i32.const 1048584))
(global (;3;) i32 (i32.const 1048576))
(export "memory" (memory 0))
(export "__data_end" (global 1))
(export "__heap_base" (global 2))
(export "FOO" (global 3))
(data (;0;) (i32.const 1048576) "\92\10\00\00\00\00\00\00"))
Expected behavior: Public static variables should get exported by default.
We believe this is a regression from 1.39.0.
rustup override set 1.39.0
cargo build --release --target wasm32-unknown-unknown
Does correctly export static variables.
Activity