Skip to content

Commit 14cbb4b

Browse files
committed
Add regression test for a spurious import
1 parent dbb0fe9 commit 14cbb4b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
-include ../../run-make-fulldeps/tools.mk
2+
3+
# only-wasm32-bare
4+
5+
all:
6+
$(RUSTC) main.rs -C overflow-checks=yes -C panic=abort -C lto -C opt-level=z --target wasm32-unknown-unknown
7+
$(NODE) verify.js $(TMPDIR)/main.wasm
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#![crate_type = "cdylib"]
2+
#![no_std]
3+
4+
#[panic_handler]
5+
fn my_panic(_info: &core::panic::PanicInfo) -> ! {
6+
loop {}
7+
}
8+
9+
#[no_mangle]
10+
pub fn multer(a: i128, b: i128) -> i128 {
11+
// Trigger usage of the __multi3 compiler intrinsic which then leads to an imported
12+
// panic function in case of a bug. We verify that no imports exist in our verifier.
13+
a * b
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const fs = require('fs');
2+
const process = require('process');
3+
const assert = require('assert');
4+
const buffer = fs.readFileSync(process.argv[2]);
5+
6+
let m = new WebAssembly.Module(buffer);
7+
let imports = WebAssembly.Module.imports(m);
8+
console.log('imports', imports);
9+
assert.strictEqual(imports.length, 0);

0 commit comments

Comments
 (0)