2024-03-27 21:55:09 +00:00
|
|
|
//@ only-wasm32-wasip1
|
2024-03-06 20:39:07 +00:00
|
|
|
|
|
|
|
use std::path::Path;
|
|
|
|
|
2024-07-17 13:31:38 +00:00
|
|
|
use run_make_support::{rfs, rustc, wasmparser};
|
2024-07-28 22:13:50 +00:00
|
|
|
|
2024-03-06 20:39:07 +00:00
|
|
|
fn main() {
|
2024-03-13 21:52:23 +00:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
2024-06-06 19:34:34 +00:00
|
|
|
verify_symbols(Path::new("foo.wasm"));
|
2024-03-13 21:52:23 +00:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").run();
|
2024-06-06 19:34:34 +00:00
|
|
|
verify_symbols(Path::new("foo.wasm"));
|
2024-03-13 21:52:23 +00:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
|
2024-06-06 19:34:34 +00:00
|
|
|
verify_symbols(Path::new("foo.wasm"));
|
2024-03-13 21:52:23 +00:00
|
|
|
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
|
2024-06-06 19:34:34 +00:00
|
|
|
verify_symbols(Path::new("foo.wasm"));
|
2024-03-06 20:39:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn verify_symbols(path: &Path) {
|
|
|
|
eprintln!("verify {path:?}");
|
2024-07-17 12:42:06 +00:00
|
|
|
let file = rfs::read(&path);
|
2024-03-06 20:39:07 +00:00
|
|
|
|
|
|
|
for payload in wasmparser::Parser::new(0).parse_all(&file) {
|
|
|
|
let payload = payload.unwrap();
|
|
|
|
if let wasmparser::Payload::ImportSection(_) = payload {
|
|
|
|
panic!("import section found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|