Try to reduce CI times with a Rust *.wat parser (#1332)
This commit moves the cranelift tests and tools from the `wabt` crate on crates.io (which compiles the wabt C++ codebase) to the `wat` crate on crates.io which is a Rust parser for the `*.wat` format. This was motivated by me noticing that release builds on Windows are ~5 minutes longer than Linux builds, and local timing graphs showed that `wabt-sys` was by far the longest build step in the build process. This commit changes the `clif-util` binary where the `--enable-simd` flag is no longer respected with the text format as input, since the `wat` crate has no feature gating. This was already sort of not respected, though, since `--enable-simd` wasn't consulted for binary inputs which `clif-util` supports as well. If this isn't ok though then it should be ok to close this PR!
This commit is contained in:
committed by
Andrew Brown
parent
582e7942f8
commit
3a13f79b66
@@ -21,7 +21,7 @@ serde = { version = "1.0.94", features = ["derive"], optional = true }
|
||||
thiserror = "1.0.4"
|
||||
|
||||
[dev-dependencies]
|
||||
wabt = "0.9.1"
|
||||
wat = "1.0.7"
|
||||
target-lexicon = "0.10"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -10,7 +10,6 @@ use std::io::prelude::*;
|
||||
use std::path::Path;
|
||||
use std::str::FromStr;
|
||||
use target_lexicon::triple;
|
||||
use wabt::{wat2wasm_with_features, Features, Wat2Wasm};
|
||||
|
||||
#[test]
|
||||
fn testsuite() {
|
||||
@@ -47,15 +46,14 @@ fn use_fallthrough_return() {
|
||||
|
||||
#[test]
|
||||
fn use_name_section() {
|
||||
let wat = r#"
|
||||
let data = wat::parse_str(
|
||||
r#"
|
||||
(module $module_name
|
||||
(func $func_name (local $loc_name i32)
|
||||
)
|
||||
)"#;
|
||||
let data = Wat2Wasm::new()
|
||||
.write_debug_names(true)
|
||||
.convert(wat)
|
||||
.unwrap_or_else(|e| panic!("error converting wat to wasm: {:?}", e));
|
||||
)"#,
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
let flags = Flags::new(settings::builder());
|
||||
let triple = triple!("riscv64");
|
||||
@@ -79,23 +77,13 @@ fn read_file(path: &Path) -> io::Result<Vec<u8>> {
|
||||
}
|
||||
|
||||
fn read_module(path: &Path) -> Vec<u8> {
|
||||
let mut features = Features::new();
|
||||
features.enable_all();
|
||||
match path.extension() {
|
||||
None => {
|
||||
panic!("the file extension is not wasm or wat");
|
||||
}
|
||||
Some(ext) => match ext.to_str() {
|
||||
Some("wasm") => read_file(path).expect("error reading wasm file"),
|
||||
Some("wat") => {
|
||||
let wat = read_file(path).expect("error reading wat file");
|
||||
match wat2wasm_with_features(&wat, features) {
|
||||
Ok(wasm) => wasm,
|
||||
Err(e) => {
|
||||
panic!("error converting wat to wasm: {:?}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some("wat") => wat::parse_file(path).expect("failed to parse wat"),
|
||||
None | Some(&_) => panic!("the file extension for {:?} is not wasm or wat", path),
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user