summaryrefslogtreecommitdiffstats
path: root/src/test/run-make/wasm-symbols-not-imported
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/run-make/wasm-symbols-not-imported')
-rw-r--r--src/test/run-make/wasm-symbols-not-imported/Makefile13
-rw-r--r--src/test/run-make/wasm-symbols-not-imported/foo.rs14
-rw-r--r--src/test/run-make/wasm-symbols-not-imported/verify-no-imports.js10
3 files changed, 37 insertions, 0 deletions
diff --git a/src/test/run-make/wasm-symbols-not-imported/Makefile b/src/test/run-make/wasm-symbols-not-imported/Makefile
new file mode 100644
index 000000000..7a923375c
--- /dev/null
+++ b/src/test/run-make/wasm-symbols-not-imported/Makefile
@@ -0,0 +1,13 @@
+-include ../../run-make-fulldeps/tools.mk
+
+# only-wasm32-bare
+
+all:
+ $(RUSTC) foo.rs --target wasm32-unknown-unknown
+ $(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
+ $(RUSTC) foo.rs --target wasm32-unknown-unknown -C lto
+ $(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
+ $(RUSTC) foo.rs --target wasm32-unknown-unknown -O
+ $(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
+ $(RUSTC) foo.rs --target wasm32-unknown-unknown -O -C lto
+ $(NODE) verify-no-imports.js $(TMPDIR)/foo.wasm
diff --git a/src/test/run-make/wasm-symbols-not-imported/foo.rs b/src/test/run-make/wasm-symbols-not-imported/foo.rs
new file mode 100644
index 000000000..b25bdc980
--- /dev/null
+++ b/src/test/run-make/wasm-symbols-not-imported/foo.rs
@@ -0,0 +1,14 @@
+#![crate_type = "cdylib"]
+#![no_std]
+
+use core::panic::PanicInfo;
+
+#[no_mangle]
+pub extern fn foo() {
+ panic!()
+}
+
+#[panic_handler]
+fn panic(_info: &PanicInfo) -> ! {
+ loop {}
+}
diff --git a/src/test/run-make/wasm-symbols-not-imported/verify-no-imports.js b/src/test/run-make/wasm-symbols-not-imported/verify-no-imports.js
new file mode 100644
index 000000000..90e3df1d9
--- /dev/null
+++ b/src/test/run-make/wasm-symbols-not-imported/verify-no-imports.js
@@ -0,0 +1,10 @@
+const fs = require('fs');
+const process = require('process');
+const assert = require('assert');
+const buffer = fs.readFileSync(process.argv[2]);
+
+let m = new WebAssembly.Module(buffer);
+let list = WebAssembly.Module.imports(m);
+console.log('imports', list);
+if (list.length !== 0)
+ throw new Error("there are some imports");