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:
Alex Crichton
2020-01-21 13:02:13 -06:00
committed by GitHub
parent bb066e68a5
commit c5c7acc766
5 changed files with 33 additions and 1 deletions

View File

@ -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();
}