-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesO-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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.
Jake-Shadle, repi, driftregion, nmrshll, rambip and 1 more
Metadata
Metadata
Assignees
Labels
A-linkageArea: linking into static, shared libraries and binariesArea: linking into static, shared libraries and binariesO-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.