mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
Preserve the function table explicitly (#1970)
The main gc pass of unused items in wasm-bindgen was accidentally removing the function table because we weren't properly rooting it in the auxiliary section which has a few ways that imports can reference the function table via intrinsics and closures. Closes #1967
This commit is contained in:
@ -334,3 +334,21 @@ $",
|
||||
)?);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn function_table_preserved() {
|
||||
let (mut cmd, _out_dir) = Project::new("function_table_preserved")
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn bar() {
|
||||
Closure::wrap(Box::new(|| {}) as Box<dyn Fn()>);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.wasm_bindgen("");
|
||||
cmd.assert().success();
|
||||
}
|
||||
|
Reference in New Issue
Block a user