Update to clap 3.* (#4082)
* Update to clap 3.0 This commit migrates all CLI commands internally used in this project from structopt/clap2 to clap 3. The intent here is to ensure that we're using maintained versions of the dependencies as structopt and clap 2 are less maintained nowadays. Most transitions were pretty straightforward and mostly dealing with structopt/clap3 differences. * Fix a number of `cargo deny` errors This commit fixes a few errors around duplicate dependencies which arose from the prior update to clap3. This also uses a new feature in `deny.toml`, `skip-tree`, which allows having a bit more targeted ignores for skips of duplicate version checks. This showed a few more locations in Wasmtime itself where we could update some dependencies.
This commit is contained in:
148
Cargo.lock
generated
148
Cargo.lock
generated
@@ -396,13 +396,48 @@ version = "2.34.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a0610544180c38b88101fecf2dd634b174a62eef6946f84dfc6a7127512b381c"
|
||||
dependencies = [
|
||||
"ansi_term",
|
||||
"atty",
|
||||
"bitflags",
|
||||
"strsim",
|
||||
"textwrap 0.11.0",
|
||||
"unicode-width",
|
||||
"vec_map",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7c167e37342afc5f33fd87bbc870cedd020d2a6dffa05d45ccd9241fbdd146db"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"clap_lex",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"strsim",
|
||||
"termcolor",
|
||||
"textwrap 0.15.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_lex"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "189ddd3b5d32a70b35e7686054371742a937b0d99128e76dde6340210e966669"
|
||||
dependencies = [
|
||||
"os_str_bytes",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -643,7 +678,7 @@ dependencies = [
|
||||
name = "cranelift-serde"
|
||||
version = "0.84.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"clap 3.1.12",
|
||||
"cranelift-codegen",
|
||||
"cranelift-reader",
|
||||
"serde_json",
|
||||
@@ -656,6 +691,7 @@ dependencies = [
|
||||
"anyhow",
|
||||
"capstone",
|
||||
"cfg-if",
|
||||
"clap 3.1.12",
|
||||
"cranelift",
|
||||
"cranelift-codegen",
|
||||
"cranelift-entity",
|
||||
@@ -675,7 +711,6 @@ dependencies = [
|
||||
"log",
|
||||
"pretty_env_logger",
|
||||
"rayon",
|
||||
"structopt",
|
||||
"target-lexicon",
|
||||
"termcolor",
|
||||
"thiserror",
|
||||
@@ -718,7 +753,7 @@ checksum = "1604dafd25fba2fe2d5895a9da139f8dc9b319a5fe5354ca137cbbce4e178d10"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"cast",
|
||||
"clap",
|
||||
"clap 2.34.0",
|
||||
"criterion-plot",
|
||||
"csv",
|
||||
"itertools",
|
||||
@@ -1037,19 +1072,6 @@ dependencies = [
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a19187fea3ac7e84da7dacf48de0c45d63c6a76f9490dae389aead16c243fce3"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"humantime 2.1.0",
|
||||
"log",
|
||||
"regex",
|
||||
"termcolor",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "env_logger"
|
||||
version = "0.9.0"
|
||||
@@ -1282,12 +1304,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
|
||||
dependencies = [
|
||||
"unicode-segmentation",
|
||||
]
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
@@ -1438,10 +1457,10 @@ dependencies = [
|
||||
name = "islec"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap 3.1.12",
|
||||
"cranelift-isle",
|
||||
"env_logger 0.8.4",
|
||||
"env_logger 0.9.0",
|
||||
"miette",
|
||||
"structopt",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1909,6 +1928,12 @@ dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
|
||||
[[package]]
|
||||
name = "owo-colors"
|
||||
version = "3.4.0"
|
||||
@@ -2639,33 +2664,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.8.0"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
|
||||
|
||||
[[package]]
|
||||
name = "structopt"
|
||||
version = "0.3.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c6b5c64445ba8094a6ab0c3cd2ad323e07171012d9c98b0b15651daf1787a10"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"lazy_static",
|
||||
"structopt-derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "structopt-derive"
|
||||
version = "0.4.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
@@ -2824,6 +2825,12 @@ dependencies = [
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.15.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
@@ -2975,12 +2982,6 @@ dependencies = [
|
||||
"regex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-segmentation"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7e8820f5d777f6224dc4be3632222971ac30164d4a258d595640799554ebfd99"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-width"
|
||||
version = "0.1.9"
|
||||
@@ -3031,12 +3032,6 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d"
|
||||
|
||||
[[package]]
|
||||
name = "vec_map"
|
||||
version = "0.8.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.4"
|
||||
@@ -3367,7 +3362,7 @@ version = "0.19.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cap-std",
|
||||
"env_logger 0.8.4",
|
||||
"env_logger 0.9.0",
|
||||
"once_cell",
|
||||
"wasi-cap-std-sync",
|
||||
"wasmtime",
|
||||
@@ -3413,8 +3408,9 @@ version = "0.37.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"async-trait",
|
||||
"clap 3.1.12",
|
||||
"criterion",
|
||||
"env_logger 0.8.4",
|
||||
"env_logger 0.9.0",
|
||||
"file-per-thread-logger",
|
||||
"filecheck",
|
||||
"humantime 2.1.0",
|
||||
@@ -3428,7 +3424,6 @@ dependencies = [
|
||||
"pretty_env_logger",
|
||||
"rayon",
|
||||
"rustix",
|
||||
"structopt",
|
||||
"target-lexicon",
|
||||
"tempfile",
|
||||
"test-programs",
|
||||
@@ -3444,7 +3439,7 @@ dependencies = [
|
||||
"wasmtime-wasi-crypto",
|
||||
"wasmtime-wasi-nn",
|
||||
"wasmtime-wast",
|
||||
"wast 39.0.0",
|
||||
"wast 40.0.0",
|
||||
"wat",
|
||||
"winapi",
|
||||
]
|
||||
@@ -3519,7 +3514,7 @@ version = "0.19.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arbitrary",
|
||||
"env_logger 0.8.4",
|
||||
"env_logger 0.9.0",
|
||||
"log",
|
||||
"rand 0.8.5",
|
||||
"rayon",
|
||||
@@ -3658,17 +3653,6 @@ dependencies = [
|
||||
"leb128",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wast"
|
||||
version = "39.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9bbbd53432b267421186feee3e52436531fa69a7cfee9403f5204352df3dd05"
|
||||
dependencies = [
|
||||
"leb128",
|
||||
"memchr",
|
||||
"unicode-width",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wast"
|
||||
version = "40.0.0"
|
||||
@@ -3755,7 +3739,7 @@ dependencies = [
|
||||
name = "wiggle-test"
|
||||
version = "0.21.0"
|
||||
dependencies = [
|
||||
"env_logger 0.8.4",
|
||||
"env_logger 0.9.0",
|
||||
"proptest",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
|
||||
@@ -29,7 +29,7 @@ wasmtime-wast = { path = "crates/wast", version = "=0.37.0" }
|
||||
wasmtime-wasi = { path = "crates/wasi", version = "0.37.0" }
|
||||
wasmtime-wasi-crypto = { path = "crates/wasi-crypto", version = "0.37.0", optional = true }
|
||||
wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "0.37.0", optional = true }
|
||||
structopt = { version = "0.3.5", features = ["color", "suggestions"] }
|
||||
clap = { version = "3.1.12", features = ["color", "suggestions", "derive"] }
|
||||
anyhow = "1.0.19"
|
||||
target-lexicon = { version = "0.12.0", default-features = false }
|
||||
pretty_env_logger = "0.4.0"
|
||||
@@ -47,7 +47,7 @@ rustix = "0.33.7"
|
||||
[dev-dependencies]
|
||||
# depend again on wasmtime to activate its default features for tests
|
||||
wasmtime = { path = "crates/wasmtime", version = "0.37.0" }
|
||||
env_logger = "0.8.1"
|
||||
env_logger = "0.9.0"
|
||||
filecheck = "0.5.0"
|
||||
more-asserts = "0.2.1"
|
||||
tempfile = "3.1.0"
|
||||
@@ -55,7 +55,7 @@ test-programs = { path = "crates/test-programs" }
|
||||
wasmtime-runtime = { path = "crates/runtime" }
|
||||
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
|
||||
tracing-subscriber = "0.3.1"
|
||||
wast = "39.0.0"
|
||||
wast = "40.0.0"
|
||||
criterion = "0.3.4"
|
||||
num_cpus = "1.13.0"
|
||||
winapi = { version = "0.3.9", features = ['memoryapi'] }
|
||||
|
||||
@@ -41,7 +41,7 @@ indicatif = "0.13.0"
|
||||
thiserror = "1.0.15"
|
||||
walkdir = "2.2"
|
||||
anyhow = "1.0.32"
|
||||
structopt = "0.3.17"
|
||||
clap = { version = "3.1.12", features = ["derive"] }
|
||||
|
||||
[features]
|
||||
default = ["disas", "wasm", "cranelift-codegen/all-arch", "souper-harvest"]
|
||||
|
||||
@@ -8,6 +8,6 @@ publish = false
|
||||
|
||||
[dependencies]
|
||||
cranelift-isle = { version = "*", path = "../isle/" }
|
||||
env_logger = { version = "0.8", default-features = false }
|
||||
env_logger = { version = "0.9", default-features = false }
|
||||
miette = { version = "3.0.0", features = ["fancy"] }
|
||||
structopt = "0.3.23"
|
||||
clap = { version = "3.1.12", features = ["derive"] }
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use clap::Parser;
|
||||
use cranelift_isle::{compile, lexer, parser};
|
||||
use miette::{Context, IntoDiagnostic, Result};
|
||||
use std::{
|
||||
@@ -5,17 +6,16 @@ use std::{
|
||||
io::{self, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
struct Opts {
|
||||
/// The output file to write the generated Rust code to. `stdout` is used if
|
||||
/// this is not given.
|
||||
#[structopt(short, long, parse(from_os_str))]
|
||||
#[clap(short, long)]
|
||||
output: Option<PathBuf>,
|
||||
|
||||
/// The input ISLE DSL source files.
|
||||
#[structopt(parse(from_os_str), required(true))]
|
||||
#[clap(required = true)]
|
||||
inputs: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ fn main() -> Result<()> {
|
||||
)
|
||||
}));
|
||||
|
||||
let opts = Opts::from_args();
|
||||
let opts = Opts::parse();
|
||||
|
||||
let lexer = lexer::Lexer::from_files(opts.inputs)?;
|
||||
let defs = parser::parse(lexer)?;
|
||||
|
||||
@@ -14,7 +14,7 @@ name = "clif-json"
|
||||
path = "src/clif-json.rs"
|
||||
|
||||
[dependencies]
|
||||
clap = "2.32.0"
|
||||
clap = { version = "3.1.12", features = ["derive"] }
|
||||
serde_json = "1.0.26"
|
||||
cranelift-codegen = { path = "../codegen", version = "0.84.0", features = ["enable-serde"] }
|
||||
cranelift-reader = { path = "../reader", version = "0.84.0" }
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
)
|
||||
)]
|
||||
|
||||
use clap::{App, Arg, SubCommand};
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::ir::Function;
|
||||
use cranelift_reader::parse_functions;
|
||||
use std::fs::File;
|
||||
@@ -54,50 +54,40 @@ fn call_de(file: &File) -> Result<(), String> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let matches = App::new("Cranelift JSON serializer/deserializer utility")
|
||||
.subcommand(
|
||||
SubCommand::with_name("serialize")
|
||||
.display_order(1)
|
||||
.about("Serializes Cranelift IR into JSON.")
|
||||
.arg(Arg::with_name("pretty").short("p").help("pretty json"))
|
||||
.arg(
|
||||
Arg::with_name("FILE")
|
||||
.required(true)
|
||||
.value_name("FILE")
|
||||
.help("Input file for serialization"),
|
||||
),
|
||||
)
|
||||
.subcommand(
|
||||
SubCommand::with_name("deserialize")
|
||||
.about("Deserializes Cranelift IR into JSON.")
|
||||
.arg(
|
||||
Arg::with_name("FILE")
|
||||
.required(true)
|
||||
.value_name("FILE")
|
||||
.help("Input file for deserialization"),
|
||||
),
|
||||
)
|
||||
.get_matches();
|
||||
/// Cranelift JSON serializer/deserializer utility
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(about)]
|
||||
enum Args {
|
||||
/// Serializes Cranelift IR into JSON
|
||||
Serialize {
|
||||
/// Generate pretty json
|
||||
#[clap(long, short)]
|
||||
pretty: bool,
|
||||
|
||||
let res_serde = match matches.subcommand() {
|
||||
("serialize", Some(m)) => {
|
||||
let mut file =
|
||||
File::open(m.value_of("FILE").unwrap()).expect("Unable to open the file");
|
||||
/// Input file for serialization
|
||||
file: String,
|
||||
},
|
||||
/// Deserializes Cranelift IR into JSON
|
||||
Deserialize {
|
||||
/// Input file for deserialization
|
||||
file: String,
|
||||
},
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let res_serde = match Args::parse() {
|
||||
Args::Serialize { pretty, file } => {
|
||||
let mut contents = String::new();
|
||||
let mut file = File::open(file).expect("Unable to open the file");
|
||||
file.read_to_string(&mut contents)
|
||||
.expect("Unable to read the file");
|
||||
|
||||
match m.occurrences_of("pretty") {
|
||||
0 => call_ser(&contents, false),
|
||||
_ => call_ser(&contents, true),
|
||||
call_ser(&contents, pretty)
|
||||
}
|
||||
}
|
||||
("deserialize", Some(m)) => {
|
||||
let file = File::open(m.value_of("FILE").unwrap()).expect("Unable to open the file");
|
||||
Args::Deserialize { file } => {
|
||||
let file = File::open(file).expect("Unable to open the file");
|
||||
call_de(&file)
|
||||
}
|
||||
_ => Err("Invalid subcommand.".to_string()),
|
||||
};
|
||||
|
||||
if let Err(mut msg) = res_serde {
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use crate::utils::{parse_sets_and_triple, read_to_string};
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::cursor::{Cursor, FuncCursor};
|
||||
use cranelift_codegen::flowgraph::ControlFlowGraph;
|
||||
use cranelift_codegen::ir::types::{F32, F64};
|
||||
@@ -16,24 +17,22 @@ use cranelift_reader::{parse_test, ParseOptions};
|
||||
use indicatif::{ProgressBar, ProgressDrawTarget, ProgressStyle};
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// Reduce size of clif file causing panic during compilation.
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(parse(from_os_str))]
|
||||
file: PathBuf,
|
||||
|
||||
/// Configure Cranelift settings
|
||||
#[structopt(long("set"))]
|
||||
#[clap(long = "set")]
|
||||
settings: Vec<String>,
|
||||
|
||||
/// Specify the target architecture.
|
||||
target: String,
|
||||
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -5,19 +5,19 @@
|
||||
|
||||
use crate::utils::read_to_string;
|
||||
use anyhow::{Context, Result};
|
||||
use clap::Parser;
|
||||
use cranelift_reader::parse_functions;
|
||||
use std::path::{Path, PathBuf};
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// Outputs .clif file
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify input file(s) to be used. Use '-' for stdin.
|
||||
#[structopt(required(true), parse(from_os_str))]
|
||||
#[clap(required = true)]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
)
|
||||
)]
|
||||
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::dbg::LOG_FILENAME_PREFIX;
|
||||
use std::{option::Option, path::PathBuf};
|
||||
use structopt::StructOpt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod bugpoint;
|
||||
mod cat;
|
||||
@@ -40,7 +40,7 @@ fn handle_debug_flag(debug: bool) {
|
||||
}
|
||||
|
||||
/// Cranelift code generator utility.
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
enum Commands {
|
||||
Test(TestOptions),
|
||||
Run(run::Options),
|
||||
@@ -63,58 +63,57 @@ enum Commands {
|
||||
}
|
||||
|
||||
/// Run Cranelift tests
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
struct TestOptions {
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
|
||||
/// Print pass timing report for test
|
||||
#[structopt(short = "T")]
|
||||
#[clap(short = 'T')]
|
||||
time_passes: bool,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short = 'd')]
|
||||
debug: bool,
|
||||
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(required(true), parse(from_os_str))]
|
||||
#[clap(required = true)]
|
||||
files: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
/// Run specified pass(es) on an input file.
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
struct PassOptions {
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
|
||||
/// Print pass timing report for test
|
||||
#[structopt(short = "T")]
|
||||
#[clap(short = 'T')]
|
||||
time_passes: bool,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(parse(from_os_str))]
|
||||
file: PathBuf,
|
||||
|
||||
/// Specify the target architecture.
|
||||
target: String,
|
||||
|
||||
/// Specify pass(es) to be run on the input file
|
||||
#[structopt(required(true))]
|
||||
#[clap(required = true)]
|
||||
passes: Vec<String>,
|
||||
}
|
||||
|
||||
/// (Compiled without support for this subcommand)
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
struct CompiledWithoutSupportOptions {}
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
match Commands::from_args() {
|
||||
match Commands::parse() {
|
||||
Commands::Cat(c) => cat::run(&c)?,
|
||||
Commands::Run(r) => run::run(&r)?,
|
||||
Commands::Interpret(i) => interpret::run(&i)?,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use crate::disasm::print_all;
|
||||
use crate::utils::{parse_sets_and_triple, read_to_string};
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::print_errors::pretty_error;
|
||||
use cranelift_codegen::settings::FlagsOrIsa;
|
||||
use cranelift_codegen::timing;
|
||||
@@ -10,37 +11,35 @@ use cranelift_codegen::Context;
|
||||
use cranelift_reader::{parse_test, ParseOptions};
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// Compiles Cranelift IR into target language
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Print the resulting Cranelift IR
|
||||
#[structopt(short("p"))]
|
||||
#[clap(short)]
|
||||
print: bool,
|
||||
|
||||
/// Print pass timing report
|
||||
#[structopt(short("T"))]
|
||||
#[clap(short = 'T')]
|
||||
report_times: bool,
|
||||
|
||||
/// Print machine code disassembly
|
||||
#[structopt(short("D"), long("disasm"))]
|
||||
#[clap(short = 'D', long)]
|
||||
disasm: bool,
|
||||
|
||||
/// Configure Cranelift settings
|
||||
#[structopt(long("set"))]
|
||||
#[clap(long = "set")]
|
||||
settings: Vec<String>,
|
||||
|
||||
/// Specify the Cranelift target
|
||||
#[structopt(long("target"))]
|
||||
#[clap(long = "target")]
|
||||
target: String,
|
||||
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(parse(from_os_str))]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
//! CLI tool to interpret Cranelift IR files.
|
||||
|
||||
use crate::utils::iterate_files;
|
||||
use clap::Parser;
|
||||
use cranelift_interpreter::environment::FunctionStore;
|
||||
use cranelift_interpreter::interpreter::{Interpreter, InterpreterState};
|
||||
use cranelift_interpreter::step::ControlFlow;
|
||||
use cranelift_reader::{parse_run_command, parse_test, ParseError, ParseOptions};
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, io};
|
||||
use structopt::StructOpt;
|
||||
use thiserror::Error;
|
||||
|
||||
/// Interpret clif code
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(required(true), parse(from_os_str))]
|
||||
#[clap(required = true)]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -5,20 +5,20 @@
|
||||
|
||||
use crate::utils::read_to_string;
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::cfg_printer::CFGPrinter;
|
||||
use cranelift_reader::parse_functions;
|
||||
use std::path::{Path, PathBuf};
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// Prints out cfg in GraphViz Dot format
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(required(true), parse(from_os_str))]
|
||||
#[clap(required = true)]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,27 +2,27 @@
|
||||
|
||||
use crate::utils::{iterate_files, read_to_string};
|
||||
use anyhow::Result;
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::isa::{CallConv, TargetIsa};
|
||||
use cranelift_filetests::SingleFunctionCompiler;
|
||||
use cranelift_native::builder as host_isa_builder;
|
||||
use cranelift_reader::{parse_run_command, parse_test, Details, IsaSpec, ParseOptions};
|
||||
use std::path::{Path, PathBuf};
|
||||
use structopt::StructOpt;
|
||||
use target_lexicon::Triple;
|
||||
|
||||
/// Execute clif code and verify with test expressions
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(required(true), parse(from_os_str))]
|
||||
#[clap(required = true)]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::utils::parse_sets_and_triple;
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::Context;
|
||||
use cranelift_wasm::{DummyEnvironment, ReturnMode};
|
||||
use rayon::iter::{IntoParallelIterator, ParallelIterator};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{fs, io};
|
||||
use structopt::StructOpt;
|
||||
|
||||
static WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6D];
|
||||
|
||||
@@ -13,22 +13,21 @@ static WASM_MAGIC: &[u8] = &[0x00, 0x61, 0x73, 0x6D];
|
||||
///
|
||||
/// Candidates are emitted in Souper's text format:
|
||||
/// <https://github.com/google/souper>
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(parse(from_os_str))]
|
||||
input: PathBuf,
|
||||
|
||||
/// Specify the output file to be used. Use '-' for stdout.
|
||||
#[structopt(short("o"), long("output"), default_value("-"), parse(from_os_str))]
|
||||
#[clap(short, long, default_value("-"))]
|
||||
output: PathBuf,
|
||||
|
||||
/// Configure Cranelift settings
|
||||
#[structopt(long("set"))]
|
||||
#[clap(long = "set")]
|
||||
settings: Vec<String>,
|
||||
|
||||
/// Specify the Cranelift target
|
||||
#[structopt(long("target"))]
|
||||
#[clap(long = "target")]
|
||||
target: String,
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
use crate::disasm::print_all;
|
||||
use crate::utils::parse_sets_and_triple;
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use cranelift_codegen::ir::DisplayFunctionAnnotations;
|
||||
use cranelift_codegen::print_errors::{pretty_error, pretty_verifier_error};
|
||||
use cranelift_codegen::settings::FlagsOrIsa;
|
||||
@@ -20,7 +21,6 @@ use cranelift_wasm::{translate_module, DummyEnvironment, FuncIndex, ReturnMode};
|
||||
use std::io::Read;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
use termcolor::{Color, ColorChoice, ColorSpec, StandardStream, WriteColor};
|
||||
|
||||
/// For verbose printing: only print if the `$x` expression is true.
|
||||
@@ -61,58 +61,57 @@ macro_rules! vcprint {
|
||||
}
|
||||
|
||||
/// Compiles Wasm binary/text into Cranelift IR and then into target language
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
pub struct Options {
|
||||
/// Be more verbose
|
||||
#[structopt(short = "v", long = "verbose")]
|
||||
#[clap(short, long)]
|
||||
verbose: bool,
|
||||
|
||||
/// Print the resulting Cranelift IR
|
||||
#[structopt(short("p"))]
|
||||
#[clap(short)]
|
||||
print: bool,
|
||||
|
||||
/// Print pass timing report
|
||||
#[structopt(short("T"))]
|
||||
#[clap(short = 'T')]
|
||||
report_times: bool,
|
||||
|
||||
/// Print machine code disassembly
|
||||
#[structopt(short("D"), long("disasm"))]
|
||||
#[clap(short = 'D', long)]
|
||||
disasm: bool,
|
||||
|
||||
/// Configure Cranelift settings
|
||||
#[structopt(long("set"))]
|
||||
#[clap(long = "set")]
|
||||
settings: Vec<String>,
|
||||
|
||||
/// Specify the Cranelift target
|
||||
#[structopt(long("target"))]
|
||||
#[clap(long = "target")]
|
||||
target: String,
|
||||
|
||||
/// Specify an input file to be used. Use '-' for stdin.
|
||||
#[structopt(parse(from_os_str))]
|
||||
files: Vec<PathBuf>,
|
||||
|
||||
/// Enable debug output on stderr/stdout
|
||||
#[structopt(short = "d")]
|
||||
#[clap(short)]
|
||||
debug: bool,
|
||||
|
||||
/// Print bytecode size
|
||||
#[structopt(short("X"))]
|
||||
#[clap(short = 'X')]
|
||||
print_size: bool,
|
||||
|
||||
/// Just decode Wasm into Cranelift IR, don't compile it to native code
|
||||
#[structopt(short("t"))]
|
||||
#[clap(short = 't')]
|
||||
just_decode: bool,
|
||||
|
||||
/// Just checks the correctness of Cranelift IR translated from Wasm
|
||||
#[structopt(short("c"))]
|
||||
#[clap(short = 'c')]
|
||||
check_translation: bool,
|
||||
|
||||
/// Display values' ranges and their locations
|
||||
#[structopt(long("value-ranges"))]
|
||||
#[clap(long = "value-ranges")]
|
||||
value_ranges: bool,
|
||||
|
||||
/// Use colors in output? [options: auto/never/always; default: auto]
|
||||
#[structopt(long("color"), default_value("auto"))]
|
||||
#[clap(long = "color", default_value("auto"))]
|
||||
color: ColorOpt,
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ test = false
|
||||
doctest = false
|
||||
|
||||
[dependencies]
|
||||
env_logger = "0.8"
|
||||
env_logger = "0.9"
|
||||
anyhow = "1.0"
|
||||
once_cell = "1.3"
|
||||
wasmtime = { path = "../wasmtime", default-features = false, features = ['cranelift', 'wasm-backtrace'] }
|
||||
|
||||
@@ -10,7 +10,7 @@ license = "Apache-2.0 WITH LLVM-exception"
|
||||
[dependencies]
|
||||
anyhow = "1.0.22"
|
||||
arbitrary = { version = "1.1.0", features = ["derive"] }
|
||||
env_logger = "0.8.1"
|
||||
env_logger = "0.9.0"
|
||||
log = "0.4.8"
|
||||
rayon = "1.2.1"
|
||||
target-lexicon = "0.12.3"
|
||||
|
||||
@@ -17,7 +17,7 @@ include = ["src/**/*", "README.md", "LICENSE"]
|
||||
witx = { version = "0.9.1", path = "../../wasi-common/WASI/tools/witx" }
|
||||
quote = "1.0"
|
||||
proc-macro2 = "1.0"
|
||||
heck = "0.3"
|
||||
heck = "0.4"
|
||||
anyhow = "1"
|
||||
syn = { version = "1.0", features = ["full"] }
|
||||
shellexpand = "2.0"
|
||||
|
||||
@@ -7,7 +7,7 @@ mod names;
|
||||
mod types;
|
||||
pub mod wasmtime;
|
||||
|
||||
use heck::ShoutySnakeCase;
|
||||
use heck::ToShoutySnakeCase;
|
||||
use lifetimes::anon_lifetime;
|
||||
use proc_macro2::{Literal, TokenStream};
|
||||
use quote::quote;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use escaping::{escape_id, handle_2big_enum_variant, NamingConvention};
|
||||
use heck::{ShoutySnakeCase, SnakeCase};
|
||||
use heck::{ToShoutySnakeCase, ToSnakeCase};
|
||||
use proc_macro2::{Ident, TokenStream};
|
||||
use quote::{format_ident, quote};
|
||||
use witx::{BuiltinType, Id, Type, TypeRef, WasmType};
|
||||
@@ -216,7 +216,7 @@ impl Names {
|
||||
/// variable. `dyn` was promoted to a strict keyword beginning in the 2018 edition.
|
||||
mod escaping {
|
||||
use {
|
||||
heck::{CamelCase, SnakeCase},
|
||||
heck::{ToSnakeCase, ToUpperCamelCase},
|
||||
proc_macro2::Ident,
|
||||
quote::format_ident,
|
||||
witx::Id,
|
||||
@@ -245,7 +245,7 @@ mod escaping {
|
||||
match (conv, id.as_str()) {
|
||||
// For camel-cased identifiers, `Self` is the only potential keyword conflict.
|
||||
(CamelCase, "self") => format_ident!("Self_"),
|
||||
(CamelCase, s) => format_ident!("{}", s.to_camel_case()),
|
||||
(CamelCase, s) => format_ident!("{}", s.to_upper_camel_case()),
|
||||
// Snake-cased identifiers are where the bulk of conflicts can occur.
|
||||
(SnakeCase, s) => {
|
||||
let s = s.to_snake_case();
|
||||
|
||||
@@ -19,7 +19,7 @@ wiggle = { path = "..", features = ["tracing_log"] }
|
||||
thiserror = "1.0"
|
||||
tracing = "0.1.26"
|
||||
tracing-subscriber = "0.3.1"
|
||||
env_logger = "0.8"
|
||||
env_logger = "0.9"
|
||||
|
||||
[badges]
|
||||
maintenance = { status = "actively-developed" }
|
||||
|
||||
22
deny.toml
22
deny.toml
@@ -27,13 +27,17 @@ multiple-versions = "deny"
|
||||
wildcards = "allow"
|
||||
deny = []
|
||||
|
||||
# Skip some multiple-versions checks, until they can be fixed.
|
||||
skip = [
|
||||
{ name = "ansi_term" }, # transitive dependencies only
|
||||
{ name = "env_logger" }, # pretty_env_logger and file-per-thread-logger depend on 0.7
|
||||
{ name = "humantime" }, # caused by env_logger
|
||||
{ name = "wast" }, # old one pulled in by witx
|
||||
{ name = "quick-error" }, # transitive dependencies
|
||||
{ name = "textwrap" }, # `miette` and `clap` depend on different versions
|
||||
{ name = "itoa" }, # `rustix` and `criterion` depend on different versions
|
||||
skip-tree = [
|
||||
# Criterion 0.3 is pretty old at this point and has had an upcoming 0.4 for
|
||||
# a long time. This is a dev-dependency so we don't really mind its
|
||||
# dependency tree, so skip it entirely.
|
||||
{ name = "criterion", depth = 20 },
|
||||
|
||||
# This is maintained externally and we allow it to have duplicate
|
||||
# dependencies relative to Wasmtime's main dependency tree.
|
||||
{ name = "witx", depth = 20 },
|
||||
|
||||
# This is somewhat unmaintained at this point and seems to pull in an old
|
||||
# version of `env_logger`, so ignore it.
|
||||
{ name = "pretty_env_logger", depth = 20 },
|
||||
]
|
||||
|
||||
@@ -4,20 +4,15 @@
|
||||
//! See `wasmtime --help` for usage.
|
||||
|
||||
use anyhow::Result;
|
||||
use structopt::{clap::AppSettings, clap::ErrorKind, StructOpt};
|
||||
use clap::{ErrorKind, Parser};
|
||||
use wasmtime_cli::commands::{
|
||||
CompileCommand, ConfigCommand, RunCommand, SettingsCommand, WastCommand,
|
||||
};
|
||||
|
||||
/// Wasmtime WebAssembly Runtime
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
name = "wasmtime",
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
global_settings = &[
|
||||
AppSettings::VersionlessSubcommands,
|
||||
AppSettings::ColoredHelp
|
||||
],
|
||||
#[derive(Parser)]
|
||||
#[clap(
|
||||
version,
|
||||
after_help = "If a subcommand is not provided, the `run` subcommand will be used.\n\
|
||||
\n\
|
||||
Usage examples:\n\
|
||||
@@ -34,7 +29,7 @@ use wasmtime_cli::commands::{
|
||||
\n \
|
||||
wasmtime example.wasm --invoke add 1 2\n"
|
||||
)]
|
||||
enum WasmtimeApp {
|
||||
enum Wasmtime {
|
||||
// !!! IMPORTANT: if subcommands are added or removed, update `parse_module` in `src/commands/run.rs`. !!!
|
||||
/// Controls Wasmtime configuration settings
|
||||
Config(ConfigCommand),
|
||||
@@ -48,7 +43,7 @@ enum WasmtimeApp {
|
||||
Wast(WastCommand),
|
||||
}
|
||||
|
||||
impl WasmtimeApp {
|
||||
impl Wasmtime {
|
||||
/// Executes the command.
|
||||
pub fn execute(self) -> Result<()> {
|
||||
match self {
|
||||
@@ -62,14 +57,13 @@ impl WasmtimeApp {
|
||||
}
|
||||
|
||||
fn main() -> Result<()> {
|
||||
WasmtimeApp::from_iter_safe(std::env::args())
|
||||
.unwrap_or_else(|e| match e.kind {
|
||||
ErrorKind::HelpDisplayed
|
||||
| ErrorKind::VersionDisplayed
|
||||
| ErrorKind::MissingArgumentOrSubcommand => e.exit(),
|
||||
_ => WasmtimeApp::Run(
|
||||
RunCommand::from_iter_safe(std::env::args()).unwrap_or_else(|_| e.exit()),
|
||||
),
|
||||
Wasmtime::try_parse()
|
||||
.unwrap_or_else(|e| match e.kind() {
|
||||
ErrorKind::DisplayHelp
|
||||
| ErrorKind::DisplayVersion
|
||||
| ErrorKind::MissingSubcommand
|
||||
| ErrorKind::MissingRequiredArgument => e.exit(),
|
||||
_ => Wasmtime::Run(RunCommand::parse()),
|
||||
})
|
||||
.execute()
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
|
||||
use crate::CommonOptions;
|
||||
use anyhow::{bail, Context, Result};
|
||||
use clap::Parser;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use structopt::{clap::AppSettings, StructOpt};
|
||||
use target_lexicon::Triple;
|
||||
use wasmtime::Engine;
|
||||
|
||||
@@ -34,27 +34,26 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
|
||||
/// Compiles a WebAssembly module.
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
#[structopt(
|
||||
name = "compile",
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
setting = AppSettings::ColoredHelp,
|
||||
version,
|
||||
after_help = AFTER_HELP.as_str()
|
||||
)]
|
||||
pub struct CompileCommand {
|
||||
#[structopt(flatten)]
|
||||
#[clap(flatten)]
|
||||
common: CommonOptions,
|
||||
|
||||
/// The target triple; default is the host triple
|
||||
#[structopt(long, value_name = "TARGET")]
|
||||
#[clap(long, value_name = "TARGET")]
|
||||
target: Option<String>,
|
||||
|
||||
/// The path of the output compiled module; defaults to <MODULE>.cwasm
|
||||
#[structopt(short = "o", long, value_name = "OUTPUT", parse(from_os_str))]
|
||||
#[clap(short = 'o', long, value_name = "OUTPUT", parse(from_os_str))]
|
||||
output: Option<PathBuf>,
|
||||
|
||||
/// The path of the WebAssembly to compile
|
||||
#[structopt(index = 1, value_name = "MODULE", parse(from_os_str))]
|
||||
#[clap(index = 1, value_name = "MODULE", parse(from_os_str))]
|
||||
module: PathBuf,
|
||||
}
|
||||
|
||||
@@ -110,7 +109,7 @@ mod test {
|
||||
|
||||
let output_path = NamedTempFile::new()?.into_temp_path();
|
||||
|
||||
let command = CompileCommand::from_iter_safe(vec![
|
||||
let command = CompileCommand::try_parse_from(vec![
|
||||
"compile",
|
||||
"--disable-logging",
|
||||
"-o",
|
||||
@@ -141,7 +140,7 @@ mod test {
|
||||
let output_path = NamedTempFile::new()?.into_temp_path();
|
||||
|
||||
// Set all the x64 flags to make sure they work
|
||||
let command = CompileCommand::from_iter_safe(vec![
|
||||
let command = CompileCommand::try_parse_from(vec![
|
||||
"compile",
|
||||
"--disable-logging",
|
||||
"--cranelift-enable",
|
||||
@@ -190,7 +189,7 @@ mod test {
|
||||
let output_path = NamedTempFile::new()?.into_temp_path();
|
||||
|
||||
// Set all the aarch64 flags to make sure they work
|
||||
let command = CompileCommand::from_iter_safe(vec![
|
||||
let command = CompileCommand::try_parse_from(vec![
|
||||
"compile",
|
||||
"--disable-logging",
|
||||
"--cranelift-enable",
|
||||
@@ -215,7 +214,7 @@ mod test {
|
||||
let output_path = NamedTempFile::new()?.into_temp_path();
|
||||
|
||||
// aarch64 flags should not be supported
|
||||
let command = CompileCommand::from_iter_safe(vec![
|
||||
let command = CompileCommand::try_parse_from(vec![
|
||||
"compile",
|
||||
"--disable-logging",
|
||||
"--cranelift-enable",
|
||||
@@ -251,7 +250,7 @@ mod test {
|
||||
"icelake",
|
||||
"znver1",
|
||||
] {
|
||||
let command = CompileCommand::from_iter_safe(vec![
|
||||
let command = CompileCommand::try_parse_from(vec![
|
||||
"compile",
|
||||
"--disable-logging",
|
||||
"--cranelift-enable",
|
||||
|
||||
@@ -1,35 +1,41 @@
|
||||
//! The module that implements the `wasmtime config` command.
|
||||
|
||||
use anyhow::Result;
|
||||
use structopt::StructOpt;
|
||||
use clap::Parser;
|
||||
|
||||
const CONFIG_NEW_AFTER_HELP: &str =
|
||||
"If no file path is specified, the system configuration file path will be used.";
|
||||
|
||||
/// Controls Wasmtime configuration settings
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "run")]
|
||||
pub enum ConfigCommand {
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "config")]
|
||||
pub struct ConfigCommand {
|
||||
#[clap(subcommand)]
|
||||
subcommand: ConfigSubcommand,
|
||||
}
|
||||
|
||||
#[derive(clap::Subcommand)]
|
||||
enum ConfigSubcommand {
|
||||
/// Creates a new Wasmtime configuration file
|
||||
#[structopt(after_help = CONFIG_NEW_AFTER_HELP)]
|
||||
#[clap(after_help = CONFIG_NEW_AFTER_HELP)]
|
||||
New(ConfigNewCommand),
|
||||
}
|
||||
|
||||
impl ConfigCommand {
|
||||
/// Executes the command.
|
||||
pub fn execute(self) -> Result<()> {
|
||||
match self {
|
||||
Self::New(c) => c.execute(),
|
||||
match self.subcommand {
|
||||
ConfigSubcommand::New(c) => c.execute(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a new Wasmtime configuration file
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "new", after_help = CONFIG_NEW_AFTER_HELP)]
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "new", after_help = CONFIG_NEW_AFTER_HELP)]
|
||||
pub struct ConfigNewCommand {
|
||||
/// The path of the new configuration file
|
||||
#[structopt(index = 1, value_name = "FILE_PATH")]
|
||||
#[clap(index = 1, value_name = "FILE_PATH")]
|
||||
path: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,16 +2,16 @@
|
||||
|
||||
use crate::{CommonOptions, WasiModules};
|
||||
use anyhow::{anyhow, bail, Context as _, Result};
|
||||
use clap::Parser;
|
||||
use std::fs::File;
|
||||
use std::io::Read;
|
||||
use std::thread;
|
||||
use std::time::Duration;
|
||||
use std::{
|
||||
ffi::{OsStr, OsString},
|
||||
ffi::OsStr,
|
||||
path::{Component, Path, PathBuf},
|
||||
process,
|
||||
};
|
||||
use structopt::{clap::AppSettings, StructOpt};
|
||||
use wasmtime::{Engine, Func, Linker, Module, Store, Trap, Val, ValType};
|
||||
use wasmtime_wasi::sync::{ambient_authority, Dir, TcpListener, WasiCtxBuilder};
|
||||
|
||||
@@ -21,11 +21,11 @@ use wasmtime_wasi_nn::WasiNnCtx;
|
||||
#[cfg(feature = "wasi-crypto")]
|
||||
use wasmtime_wasi_crypto::WasiCryptoCtx;
|
||||
|
||||
fn parse_module(s: &OsStr) -> Result<PathBuf, OsString> {
|
||||
fn parse_module(s: &OsStr) -> anyhow::Result<PathBuf> {
|
||||
// Do not accept wasmtime subcommand names as the module name
|
||||
match s.to_str() {
|
||||
Some("help") | Some("config") | Some("run") | Some("wast") | Some("compile") => {
|
||||
Err("module name cannot be the same as a subcommand".into())
|
||||
bail!("module name cannot be the same as a subcommand")
|
||||
}
|
||||
_ => Ok(s.into()),
|
||||
}
|
||||
@@ -72,14 +72,14 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
|
||||
/// Runs a WebAssembly module
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "run", setting = AppSettings::TrailingVarArg, after_help = AFTER_HELP.as_str())]
|
||||
#[derive(Parser)]
|
||||
#[structopt(name = "run", trailing_var_arg = true, after_help = AFTER_HELP.as_str())]
|
||||
pub struct RunCommand {
|
||||
#[structopt(flatten)]
|
||||
#[clap(flatten)]
|
||||
common: CommonOptions,
|
||||
|
||||
/// Allow unknown exports when running commands.
|
||||
#[structopt(long = "allow-unknown-exports")]
|
||||
#[clap(long = "allow-unknown-exports")]
|
||||
allow_unknown_exports: bool,
|
||||
|
||||
/// Allow executing precompiled WebAssembly modules as `*.cwasm` files.
|
||||
@@ -88,16 +88,16 @@ pub struct RunCommand {
|
||||
/// is arbitrary user input. Only `wasmtime`-precompiled modules generated
|
||||
/// via the `wasmtime compile` command or equivalent should be passed as an
|
||||
/// argument with this option specified.
|
||||
#[structopt(long = "allow-precompiled")]
|
||||
#[clap(long = "allow-precompiled")]
|
||||
allow_precompiled: bool,
|
||||
|
||||
/// Inherit environment variables and file descriptors following the
|
||||
/// systemd listen fd specification (UNIX only)
|
||||
#[structopt(long = "listenfd")]
|
||||
#[clap(long = "listenfd")]
|
||||
listenfd: bool,
|
||||
|
||||
/// Grant access to the given TCP listen socket
|
||||
#[structopt(
|
||||
#[clap(
|
||||
long = "tcplisten",
|
||||
number_of_values = 1,
|
||||
value_name = "SOCKET ADDRESS"
|
||||
@@ -105,24 +105,23 @@ pub struct RunCommand {
|
||||
tcplisten: Vec<String>,
|
||||
|
||||
/// Grant access to the given host directory
|
||||
#[structopt(long = "dir", number_of_values = 1, value_name = "DIRECTORY")]
|
||||
#[clap(long = "dir", number_of_values = 1, value_name = "DIRECTORY")]
|
||||
dirs: Vec<String>,
|
||||
|
||||
/// Pass an environment variable to the program
|
||||
#[structopt(long = "env", number_of_values = 1, value_name = "NAME=VAL", parse(try_from_str = parse_env_var))]
|
||||
#[clap(long = "env", number_of_values = 1, value_name = "NAME=VAL", parse(try_from_str = parse_env_var))]
|
||||
vars: Vec<(String, String)>,
|
||||
|
||||
/// The name of the function to run
|
||||
#[structopt(long, value_name = "FUNCTION")]
|
||||
#[clap(long, value_name = "FUNCTION")]
|
||||
invoke: Option<String>,
|
||||
|
||||
/// Grant access to a guest directory mapped as a host directory
|
||||
#[structopt(long = "mapdir", number_of_values = 1, value_name = "GUEST_DIR::HOST_DIR", parse(try_from_str = parse_map_dirs))]
|
||||
#[clap(long = "mapdir", number_of_values = 1, value_name = "GUEST_DIR::HOST_DIR", parse(try_from_str = parse_map_dirs))]
|
||||
map_dirs: Vec<(String, String)>,
|
||||
|
||||
/// The path of the WebAssembly module to run
|
||||
#[structopt(
|
||||
index = 1,
|
||||
#[clap(
|
||||
required = true,
|
||||
value_name = "MODULE",
|
||||
parse(try_from_os_str = parse_module),
|
||||
@@ -130,7 +129,7 @@ pub struct RunCommand {
|
||||
module: PathBuf,
|
||||
|
||||
/// Load the given WebAssembly module before the main module
|
||||
#[structopt(
|
||||
#[clap(
|
||||
long = "preload",
|
||||
number_of_values = 1,
|
||||
value_name = "NAME=MODULE_PATH",
|
||||
@@ -139,7 +138,7 @@ pub struct RunCommand {
|
||||
preloads: Vec<(String, PathBuf)>,
|
||||
|
||||
/// Maximum execution time of wasm code before timing out (1, 2s, 100ms, etc)
|
||||
#[structopt(
|
||||
#[clap(
|
||||
long = "wasm-timeout",
|
||||
value_name = "TIME",
|
||||
parse(try_from_str = parse_dur),
|
||||
@@ -148,7 +147,7 @@ pub struct RunCommand {
|
||||
|
||||
// NOTE: this must come last for trailing varargs
|
||||
/// The arguments to pass to the module
|
||||
#[structopt(value_name = "ARGS")]
|
||||
#[clap(value_name = "ARGS")]
|
||||
module_args: Vec<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
//! The module that implements the `wasmtime settings` command.
|
||||
|
||||
use anyhow::{anyhow, Result};
|
||||
use clap::Parser;
|
||||
use std::collections::BTreeMap;
|
||||
use std::str::FromStr;
|
||||
use structopt::StructOpt;
|
||||
use wasmtime_environ::{FlagValue, Setting, SettingKind};
|
||||
|
||||
/// Displays available Cranelift settings for a target.
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(name = "run")]
|
||||
#[derive(Parser)]
|
||||
#[clap(name = "run")]
|
||||
pub struct SettingsCommand {
|
||||
/// The target triple to get the settings for; defaults to the host triple.
|
||||
#[structopt(long, value_name = "TARGET")]
|
||||
#[clap(long, value_name = "TARGET")]
|
||||
target: Option<String>,
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
use crate::CommonOptions;
|
||||
use anyhow::{Context as _, Result};
|
||||
use clap::Parser;
|
||||
use std::path::PathBuf;
|
||||
use structopt::{clap::AppSettings, StructOpt};
|
||||
use wasmtime::{Engine, Store};
|
||||
use wasmtime_wast::WastContext;
|
||||
|
||||
@@ -14,19 +14,18 @@ lazy_static::lazy_static! {
|
||||
}
|
||||
|
||||
/// Runs a WebAssembly test script file
|
||||
#[derive(StructOpt)]
|
||||
#[structopt(
|
||||
#[derive(Parser)]
|
||||
#[clap(
|
||||
name = "wast",
|
||||
version = env!("CARGO_PKG_VERSION"),
|
||||
setting = AppSettings::ColoredHelp,
|
||||
version,
|
||||
after_help = AFTER_HELP.as_str(),
|
||||
)]
|
||||
pub struct WastCommand {
|
||||
#[structopt(flatten)]
|
||||
#[clap(flatten)]
|
||||
common: CommonOptions,
|
||||
|
||||
/// The path of the WebAssembly test script to run
|
||||
#[structopt(required = true, value_name = "SCRIPT_FILE", parse(from_os_str))]
|
||||
#[clap(required = true, value_name = "SCRIPT_FILE", parse(from_os_str))]
|
||||
scripts: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
|
||||
70
src/lib.rs
70
src/lib.rs
@@ -92,9 +92,9 @@ lazy_static::lazy_static! {
|
||||
pub mod commands;
|
||||
|
||||
use anyhow::{bail, Result};
|
||||
use clap::Parser;
|
||||
use std::collections::HashMap;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
use wasmtime::{Config, ProfilingStrategy};
|
||||
#[cfg(feature = "pooling-allocator")]
|
||||
use wasmtime::{InstanceLimits, PoolingAllocationStrategy};
|
||||
@@ -138,51 +138,51 @@ fn init_file_per_thread_logger(prefix: &'static str) {
|
||||
}
|
||||
|
||||
/// Common options for commands that translate WebAssembly modules
|
||||
#[derive(StructOpt)]
|
||||
#[derive(Parser)]
|
||||
struct CommonOptions {
|
||||
/// Use specified configuration file
|
||||
#[structopt(long, parse(from_os_str), value_name = "CONFIG_PATH")]
|
||||
#[clap(long, parse(from_os_str), value_name = "CONFIG_PATH")]
|
||||
config: Option<PathBuf>,
|
||||
|
||||
/// Disable logging.
|
||||
#[structopt(long, conflicts_with = "log_to_files")]
|
||||
#[clap(long, conflicts_with = "log-to-files")]
|
||||
disable_logging: bool,
|
||||
|
||||
/// Log to per-thread log files instead of stderr.
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
log_to_files: bool,
|
||||
|
||||
/// Generate debug information
|
||||
#[structopt(short = "g")]
|
||||
#[clap(short = 'g')]
|
||||
debug_info: bool,
|
||||
|
||||
/// Disable cache system
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
disable_cache: bool,
|
||||
|
||||
/// Enables or disables WebAssembly features
|
||||
#[structopt(long, value_name = "FEATURE,FEATURE,...", parse(try_from_str = parse_wasm_features))]
|
||||
#[clap(long, value_name = "FEATURE,FEATURE,...", parse(try_from_str = parse_wasm_features))]
|
||||
wasm_features: Option<WasmFeatures>,
|
||||
|
||||
/// Enables or disables WASI modules
|
||||
#[structopt(long, value_name = "MODULE,MODULE,...", parse(try_from_str = parse_wasi_modules))]
|
||||
#[clap(long, value_name = "MODULE,MODULE,...", parse(try_from_str = parse_wasi_modules))]
|
||||
wasi_modules: Option<WasiModules>,
|
||||
|
||||
/// Generate jitdump file (supported on --features=profiling build)
|
||||
#[structopt(long, conflicts_with = "vtune")]
|
||||
#[clap(long, conflicts_with = "vtune")]
|
||||
jitdump: bool,
|
||||
|
||||
/// Generate vtune (supported on --features=vtune build)
|
||||
#[structopt(long, conflicts_with = "jitdump")]
|
||||
#[clap(long, conflicts_with = "jitdump")]
|
||||
vtune: bool,
|
||||
|
||||
/// Run optimization passes on translated functions, on by default
|
||||
#[structopt(short = "O", long)]
|
||||
#[clap(short = 'O', long)]
|
||||
optimize: bool,
|
||||
|
||||
/// Optimization level for generated functions
|
||||
/// Supported levels: 0 (none), 1, 2 (most), or s (size); default is "most"
|
||||
#[structopt(
|
||||
#[clap(
|
||||
long,
|
||||
value_name = "LEVEL",
|
||||
parse(try_from_str = parse_opt_level),
|
||||
@@ -192,12 +192,12 @@ struct CommonOptions {
|
||||
|
||||
/// Set a Cranelift setting to a given value.
|
||||
/// Use `wasmtime settings` to list Cranelift settings for a target.
|
||||
#[structopt(long = "cranelift-set", value_name = "NAME=VALUE", number_of_values = 1, verbatim_doc_comment, parse(try_from_str = parse_cranelift_flag))]
|
||||
#[clap(long = "cranelift-set", value_name = "NAME=VALUE", number_of_values = 1, verbatim_doc_comment, parse(try_from_str = parse_cranelift_flag))]
|
||||
cranelift_set: Vec<(String, String)>,
|
||||
|
||||
/// Enable a Cranelift boolean setting or preset.
|
||||
/// Use `wasmtime settings` to list Cranelift settings for a target.
|
||||
#[structopt(
|
||||
#[clap(
|
||||
long,
|
||||
value_name = "SETTING",
|
||||
number_of_values = 1,
|
||||
@@ -207,27 +207,27 @@ struct CommonOptions {
|
||||
|
||||
/// Maximum size in bytes of wasm memory before it becomes dynamically
|
||||
/// relocatable instead of up-front-reserved.
|
||||
#[structopt(long, value_name = "MAXIMUM")]
|
||||
#[clap(long, value_name = "MAXIMUM")]
|
||||
static_memory_maximum_size: Option<u64>,
|
||||
|
||||
/// Force using a "static" style for all wasm memories.
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
static_memory_forced: bool,
|
||||
|
||||
/// Byte size of the guard region after static memories are allocated.
|
||||
#[structopt(long, value_name = "SIZE")]
|
||||
#[clap(long, value_name = "SIZE")]
|
||||
static_memory_guard_size: Option<u64>,
|
||||
|
||||
/// Byte size of the guard region after dynamic memories are allocated.
|
||||
#[structopt(long, value_name = "SIZE")]
|
||||
#[clap(long, value_name = "SIZE")]
|
||||
dynamic_memory_guard_size: Option<u64>,
|
||||
|
||||
/// Enable Cranelift's internal debug verifier (expensive)
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
enable_cranelift_debug_verifier: bool,
|
||||
|
||||
/// Enable Cranelift's internal NaN canonicalization
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
enable_cranelift_nan_canonicalization: bool,
|
||||
|
||||
/// Enable execution fuel with N units fuel, where execution will trap after
|
||||
@@ -237,29 +237,29 @@ struct CommonOptions {
|
||||
/// such as `nop`, `drop`, `block`, and `loop`, consume 0 units, as any
|
||||
/// execution cost associated with them involves other instructions which do
|
||||
/// consume fuel.
|
||||
#[structopt(long, value_name = "N")]
|
||||
#[clap(long, value_name = "N")]
|
||||
fuel: Option<u64>,
|
||||
|
||||
/// Executing wasm code will yield when a global epoch counter
|
||||
/// changes, allowing for async operation without blocking the
|
||||
/// executor.
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
epoch_interruption: bool,
|
||||
|
||||
/// Disables the on-by-default address map from native code to wasm code.
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
disable_address_map: bool,
|
||||
|
||||
/// Disables the default of attempting to initialize linear memory via a
|
||||
/// copy-on-write mapping.
|
||||
#[cfg(feature = "memory-init-cow")]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
disable_memory_init_cow: bool,
|
||||
|
||||
/// Enables the pooling allocator, in place of the on-demand
|
||||
/// allocator.
|
||||
#[cfg(feature = "pooling-allocator")]
|
||||
#[structopt(long)]
|
||||
#[clap(long)]
|
||||
pooling_allocator: bool,
|
||||
}
|
||||
|
||||
@@ -561,7 +561,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_all_features() -> Result<()> {
|
||||
let options = CommonOptions::from_iter_safe(vec!["foo", "--wasm-features=all"])?;
|
||||
let options = CommonOptions::try_parse_from(vec!["foo", "--wasm-features=all"])?;
|
||||
|
||||
let WasmFeatures {
|
||||
reference_types,
|
||||
@@ -586,7 +586,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_no_features() -> Result<()> {
|
||||
let options = CommonOptions::from_iter_safe(vec!["foo", "--wasm-features=-all"])?;
|
||||
let options = CommonOptions::try_parse_from(vec!["foo", "--wasm-features=-all"])?;
|
||||
|
||||
let WasmFeatures {
|
||||
reference_types,
|
||||
@@ -611,7 +611,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_multiple_features() -> Result<()> {
|
||||
let options = CommonOptions::from_iter_safe(vec![
|
||||
let options = CommonOptions::try_parse_from(vec![
|
||||
"foo",
|
||||
"--wasm-features=-reference-types,simd,multi-memory,memory64",
|
||||
])?;
|
||||
@@ -642,13 +642,13 @@ mod test {
|
||||
#[test]
|
||||
fn $test_name() -> Result<()> {
|
||||
let options =
|
||||
CommonOptions::from_iter_safe(vec!["foo", concat!("--wasm-features=", $flag)])?;
|
||||
CommonOptions::try_parse_from(vec!["foo", concat!("--wasm-features=", $flag)])?;
|
||||
|
||||
let WasmFeatures { $name, .. } = options.wasm_features.unwrap();
|
||||
|
||||
assert_eq!($name, Some(true));
|
||||
|
||||
let options = CommonOptions::from_iter_safe(vec![
|
||||
let options = CommonOptions::try_parse_from(vec![
|
||||
"foo",
|
||||
concat!("--wasm-features=-", $flag),
|
||||
])?;
|
||||
@@ -676,7 +676,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_default_modules() {
|
||||
let options = CommonOptions::from_iter_safe(vec!["foo", "--wasi-modules=default"]).unwrap();
|
||||
let options = CommonOptions::try_parse_from(vec!["foo", "--wasi-modules=default"]).unwrap();
|
||||
assert_eq!(
|
||||
options.wasi_modules.unwrap(),
|
||||
WasiModules {
|
||||
@@ -689,7 +689,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_empty_modules() {
|
||||
let options = CommonOptions::from_iter_safe(vec!["foo", "--wasi-modules="]).unwrap();
|
||||
let options = CommonOptions::try_parse_from(vec!["foo", "--wasi-modules="]).unwrap();
|
||||
assert_eq!(
|
||||
options.wasi_modules.unwrap(),
|
||||
WasiModules {
|
||||
@@ -702,7 +702,7 @@ mod test {
|
||||
|
||||
#[test]
|
||||
fn test_some_modules() {
|
||||
let options = CommonOptions::from_iter_safe(vec![
|
||||
let options = CommonOptions::try_parse_from(vec![
|
||||
"foo",
|
||||
"--wasi-modules=experimental-wasi-nn,-wasi-common",
|
||||
])
|
||||
@@ -720,7 +720,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_no_modules() {
|
||||
let options =
|
||||
CommonOptions::from_iter_safe(vec!["foo", "--wasi-modules=-default"]).unwrap();
|
||||
CommonOptions::try_parse_from(vec!["foo", "--wasi-modules=-default"]).unwrap();
|
||||
assert_eq!(
|
||||
options.wasi_modules.unwrap(),
|
||||
WasiModules {
|
||||
|
||||
Reference in New Issue
Block a user