From 7fb064a10f348deaece634ed4ad5bb228ed0c80f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 10 Aug 2023 20:58:54 +0200 Subject: [PATCH 1/5] [12.0.0] Revert "Require wasmtime options are first when running modules (#6737)" (#6830) * [12.0.0] Revert "Require wasmtime options are first when running modules (#6737)" This reverts commit 8091556514f03b919bad001a580a8a38f18d11a0. The fallout of this change has been larger than expected so revert this on the 12.0.0 branch to provide more time to discuss this and figure out the best course of action. * Revert addition of one more test --- ci/run-wasi-crypto-example.sh | 2 +- ci/run-wasi-nn-example.sh | 2 +- src/bin/wasmtime.rs | 46 +++-- src/commands/run.rs | 106 ++++++------ tests/all/cli_tests.rs | 217 ++++++------------------ tests/all/cli_tests/print-arguments.wat | 75 -------- tests/all/cli_tests/run | 3 - tests/all/debug/gdb.rs | 2 +- tests/all/debug/lldb.rs | 4 +- tests/all/wasi_testsuite.rs | 9 +- 10 files changed, 138 insertions(+), 328 deletions(-) delete mode 100644 tests/all/cli_tests/print-arguments.wat delete mode 100644 tests/all/cli_tests/run diff --git a/ci/run-wasi-crypto-example.sh b/ci/run-wasi-crypto-example.sh index 30bbada3c76a..b027e4834002 100755 --- a/ci/run-wasi-crypto-example.sh +++ b/ci/run-wasi-crypto-example.sh @@ -7,4 +7,4 @@ pushd "$RUST_BINDINGS" cargo build --release --target=wasm32-wasi popd -cargo run --features wasi-crypto -- run --wasi-modules=experimental-wasi-crypto "$RUST_BINDINGS/target/wasm32-wasi/release/wasi-crypto-guest.wasm" +cargo run --features wasi-crypto -- run "$RUST_BINDINGS/target/wasm32-wasi/release/wasi-crypto-guest.wasm" --wasi-modules=experimental-wasi-crypto diff --git a/ci/run-wasi-nn-example.sh b/ci/run-wasi-nn-example.sh index b8012120d3fa..82990d0bbda3 100755 --- a/ci/run-wasi-nn-example.sh +++ b/ci/run-wasi-nn-example.sh @@ -33,7 +33,7 @@ cp target/wasm32-wasi/release/wasi-nn-example.wasm $TMP_DIR popd # Run the example in Wasmtime (note that the example uses `fixture` as the expected location of the model/tensor files). -cargo run -- run --mapdir fixture::$TMP_DIR --wasi-modules=experimental-wasi-nn $TMP_DIR/wasi-nn-example.wasm +cargo run -- run --mapdir fixture::$TMP_DIR $TMP_DIR/wasi-nn-example.wasm --wasi-modules=experimental-wasi-nn # Clean up the temporary directory only if it was not specified (users may want to keep the directory around). if [[ $REMOVE_TMP_DIR -eq 1 ]]; then diff --git a/src/bin/wasmtime.rs b/src/bin/wasmtime.rs index d32a0b63f373..6d425625dfa4 100644 --- a/src/bin/wasmtime.rs +++ b/src/bin/wasmtime.rs @@ -4,7 +4,7 @@ //! See `wasmtime --help` for usage. use anyhow::Result; -use clap::Parser; +use clap::{error::ErrorKind, Parser}; use wasmtime_cli::commands::{ CompileCommand, ConfigCommand, ExploreCommand, RunCommand, SettingsCommand, WastCommand, }; @@ -27,24 +27,10 @@ use wasmtime_cli::commands::{ \n\ Invoking a specific function (e.g. `add`) in a WebAssembly module:\n\ \n \ - wasmtime example.wasm --invoke add 1 2\n", - - // This option enables the pattern below where we ask clap to parse twice - // sorta: once where it's trying to find a subcommand and once assuming - // a subcommand doesn't get passed. Clap should then, apparently, - // fill in the `subcommand` if found and otherwise fill in the - // `RunCommand`. - args_conflicts_with_subcommands = true + wasmtime example.wasm --invoke add 1 2\n" )] -struct Wasmtime { - #[clap(subcommand)] - subcommand: Option, - #[clap(flatten)] - run: RunCommand, -} - -#[derive(Parser)] -enum Subcommand { +enum Wasmtime { + // !!! IMPORTANT: if subcommands are added or removed, update `parse_module` in `src/commands/run.rs`. !!! /// Controls Wasmtime configuration settings Config(ConfigCommand), /// Compiles a WebAssembly module. @@ -62,20 +48,26 @@ enum Subcommand { impl Wasmtime { /// Executes the command. pub fn execute(self) -> Result<()> { - let subcommand = self.subcommand.unwrap_or(Subcommand::Run(self.run)); - match subcommand { - Subcommand::Config(c) => c.execute(), - Subcommand::Compile(c) => c.execute(), - Subcommand::Explore(c) => c.execute(), - Subcommand::Run(c) => c.execute(), - Subcommand::Settings(c) => c.execute(), - Subcommand::Wast(c) => c.execute(), + match self { + Self::Config(c) => c.execute(), + Self::Compile(c) => c.execute(), + Self::Explore(c) => c.execute(), + Self::Run(c) => c.execute(), + Self::Settings(c) => c.execute(), + Self::Wast(c) => c.execute(), } } } fn main() -> Result<()> { - Wasmtime::parse().execute() + Wasmtime::try_parse() + .unwrap_or_else(|e| match e.kind() { + ErrorKind::InvalidSubcommand | ErrorKind::UnknownArgument => { + Wasmtime::Run(RunCommand::parse()) + } + _ => e.exit(), + }) + .execute() } #[test] diff --git a/src/commands/run.rs b/src/commands/run.rs index 00ef5e1fead5..55b09b53616c 100644 --- a/src/commands/run.rs +++ b/src/commands/run.rs @@ -1,11 +1,14 @@ //! The module that implements the `wasmtime run` command. use anyhow::{anyhow, bail, Context as _, Result}; +use clap::builder::{OsStringValueParser, TypedValueParser}; use clap::Parser; use once_cell::sync::Lazy; +use std::ffi::OsStr; +use std::ffi::OsString; use std::fs::File; use std::io::Write; -use std::path::{Path, PathBuf}; +use std::path::{Component, Path, PathBuf}; use std::thread; use std::time::Duration; use wasmtime::{ @@ -36,6 +39,18 @@ use wasmtime_wasi_threads::WasiThreadsCtx; #[cfg(feature = "wasi-http")] use wasmtime_wasi_http::WasiHttp; +fn parse_module(s: OsString) -> anyhow::Result { + // Do not accept wasmtime subcommand names as the module name + match s.to_str() { + Some("help") | Some("config") | Some("run") | Some("wast") | Some("compile") => { + bail!("module name cannot be the same as a subcommand") + } + #[cfg(unix)] + Some("-") => Ok(PathBuf::from("/dev/stdin")), + _ => Ok(s.into()), + } +} + fn parse_env_var(s: &str) -> Result<(String, Option)> { let mut parts = s.splitn(2, '='); Ok(( @@ -96,7 +111,7 @@ static AFTER_HELP: Lazy = Lazy::new(|| crate::FLAG_EXPLANATIONS.to_strin /// Runs a WebAssembly module #[derive(Parser)] -#[structopt(name = "run", after_help = AFTER_HELP.as_str())] +#[structopt(name = "run", trailing_var_arg = true, after_help = AFTER_HELP.as_str())] pub struct RunCommand { #[clap(flatten)] common: CommonOptions, @@ -159,6 +174,14 @@ pub struct RunCommand { #[clap(long = "mapdir", number_of_values = 1, value_name = "GUEST_DIR::HOST_DIR", value_parser = parse_map_dirs)] map_dirs: Vec<(String, String)>, + /// The path of the WebAssembly module to run + #[clap( + required = true, + value_name = "MODULE", + value_parser = OsStringValueParser::new().try_map(parse_module), + )] + module: PathBuf, + /// Load the given WebAssembly module before the main module #[clap( long = "preload", @@ -202,6 +225,11 @@ pub struct RunCommand { #[clap(long = "coredump-on-trap", value_name = "PATH")] coredump_on_trap: Option, + // NOTE: this must come last for trailing varargs + /// The arguments to pass to the module + #[clap(value_name = "ARGS")] + module_args: Vec, + /// Maximum size, in bytes, that a linear memory is allowed to reach. /// /// Growth beyond this limit will cause `memory.grow` instructions in @@ -233,14 +261,6 @@ pub struct RunCommand { /// memory, for example. #[clap(long)] trap_on_grow_failure: bool, - - /// The WebAssembly module to run and arguments to pass to it. - /// - /// Arguments passed to the wasm module will be configured as WASI CLI - /// arguments unless the `--invoke` CLI argument is passed in which case - /// arguments will be interpreted as arguments to the function specified. - #[clap(value_name = "WASM", trailing_var_arg = true, required = true)] - module_and_args: Vec, } #[derive(Clone)] @@ -283,13 +303,13 @@ impl RunCommand { // Make wasi available by default. let preopen_dirs = self.compute_preopen_dirs()?; - let argv = self.compute_argv()?; + let argv = self.compute_argv(); let mut linker = Linker::new(&engine); linker.allow_unknown_exports(self.allow_unknown_exports); // Read the wasm module binary either as `*.wat` or a raw binary. - let module = self.load_module(linker.engine(), &self.module_and_args[0])?; + let module = self.load_module(linker.engine(), &self.module)?; let mut modules = vec![(String::new(), module.clone())]; let host = Host::default(); @@ -350,12 +370,8 @@ impl RunCommand { // Load the main wasm module. match self .load_main_module(&mut store, &mut linker, module, modules, &argv[0]) - .with_context(|| { - format!( - "failed to run main module `{}`", - self.module_and_args[0].display() - ) - }) { + .with_context(|| format!("failed to run main module `{}`", self.module.display())) + { Ok(()) => (), Err(e) => { // Exit the process if Wasmtime understands the error; @@ -404,25 +420,27 @@ impl RunCommand { Ok(listeners) } - fn compute_argv(&self) -> Result> { + fn compute_argv(&self) -> Vec { let mut result = Vec::new(); - for (i, arg) in self.module_and_args.iter().enumerate() { - // For argv[0], which is the program name. Only include the base - // name of the main wasm module, to avoid leaking path information. - let arg = if i == 0 { - arg.components().next_back().unwrap().as_os_str() - } else { - arg.as_ref() - }; - result.push( - arg.to_str() - .ok_or_else(|| anyhow!("failed to convert {arg:?} to utf-8"))? - .to_string(), - ); + // Add argv[0], which is the program name. Only include the base name of the + // main wasm module, to avoid leaking path information. + result.push( + self.module + .components() + .next_back() + .map(Component::as_os_str) + .and_then(OsStr::to_str) + .unwrap_or("") + .to_owned(), + ); + + // Add the remaining arguments. + for arg in self.module_args.iter() { + result.push(arg.clone()); } - Ok(result) + result } fn setup_epoch_handler( @@ -523,10 +541,9 @@ impl RunCommand { } // Use "" as a default module name. - linker.module(&mut *store, "", &module).context(format!( - "failed to instantiate {:?}", - self.module_and_args[0] - ))?; + linker + .module(&mut *store, "", &module) + .context(format!("failed to instantiate {:?}", self.module))?; // If a function to invoke was given, invoke it. let func = if let Some(name) = &self.invoke { @@ -567,7 +584,7 @@ impl RunCommand { is experimental and may break in the future" ); } - let mut args = self.module_and_args.iter().skip(1); + let mut args = self.module_args.iter(); let mut values = Vec::new(); for ty in ty.params() { let val = match args.next() { @@ -580,9 +597,6 @@ impl RunCommand { } } }; - let val = val - .to_str() - .ok_or_else(|| anyhow!("argument is not valid utf-8: {val:?}"))?; values.push(match ty { // TODO: integer parsing here should handle hexadecimal notation // like `0x0...`, but the Rust standard library currently only @@ -609,9 +623,7 @@ impl RunCommand { if let Err(err) = invoke_res { let err = if err.is::() { if let Some(coredump_path) = self.coredump_on_trap.as_ref() { - let source_name = self.module_and_args[0] - .to_str() - .unwrap_or_else(|| "unknown"); + let source_name = self.module.to_str().unwrap_or_else(|| "unknown"); if let Err(coredump_err) = generate_coredump(&err, &source_name, coredump_path) { @@ -652,12 +664,6 @@ impl RunCommand { } fn load_module(&self, engine: &Engine, path: &Path) -> Result { - let path = match path.to_str() { - #[cfg(unix)] - Some("-") => "/dev/stdin".as_ref(), - _ => path, - }; - if self.allow_precompiled { unsafe { Module::from_trusted_file(engine, path) } } else { diff --git a/tests/all/cli_tests.rs b/tests/all/cli_tests.rs index d7fd98cc103f..b66263128360 100644 --- a/tests/all/cli_tests.rs +++ b/tests/all/cli_tests.rs @@ -1,21 +1,41 @@ #![cfg(not(miri))] -use anyhow::{bail, Result}; +use anyhow::{bail, Context, Result}; use std::fs::File; -use std::io::Write; +use std::io::{Read, Write}; use std::path::Path; -use std::process::{Command, Output}; +use std::process::{Command, Output, Stdio}; use tempfile::{NamedTempFile, TempDir}; // Run the wasmtime CLI with the provided args and return the `Output`. // If the `stdin` is `Some`, opens the file and redirects to the child's stdin. pub fn run_wasmtime_for_output(args: &[&str], stdin: Option<&Path>) -> Result { let mut cmd = get_wasmtime_command()?; - cmd.args(args); - if let Some(file) = stdin { - cmd.stdin(File::open(file)?); + let stdin = stdin + .map(File::open) + .transpose() + .context("Cannot open a file to use as stdin")?; + + if let Some(mut f) = stdin { + let mut buf = Vec::new(); + f.read_to_end(&mut buf)?; + + let mut child = cmd + .stdout(Stdio::piped()) + .stdin(Stdio::piped()) + .args(args) + .spawn()?; + + let mut stdin = child.stdin.take().unwrap(); + std::thread::spawn(move || { + stdin + .write_all(&buf) + .expect("failed to write module to child stdin") + }); + child.wait_with_output().map_err(Into::into) + } else { + cmd.args(args).output().map_err(Into::into) } - cmd.output().map_err(Into::into) } /// Get the Wasmtime CLI as a [Command]. @@ -74,10 +94,10 @@ fn run_wasmtime_simple() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/simple.wat")?; run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "simple", "--disable-cache", - wasm.path().to_str().unwrap(), "4", ])?; Ok(()) @@ -90,10 +110,10 @@ fn run_wasmtime_simple_fail_no_args() -> Result<()> { assert!( run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--disable-cache", "--invoke", "simple", - wasm.path().to_str().unwrap(), ]) .is_err(), "shall fail" @@ -108,11 +128,11 @@ fn run_coredump_smoketest() -> Result<()> { let coredump_arg = format!("--coredump-on-trap={}", coredump_file.path().display()); let err = run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "a", "--disable-cache", &coredump_arg, - wasm.path().to_str().unwrap(), ]) .unwrap_err(); assert!(err.to_string().contains(&format!( @@ -128,29 +148,29 @@ fn run_wasmtime_simple_wat() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/simple.wat")?; run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "simple", "--disable-cache", - wasm.path().to_str().unwrap(), "4", ])?; assert_eq!( run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "get_f32", "--disable-cache", - wasm.path().to_str().unwrap(), ])?, "100\n" ); assert_eq!( run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "get_f64", "--disable-cache", - wasm.path().to_str().unwrap(), ])?, "100\n" ); @@ -185,7 +205,7 @@ fn run_wasmtime_unreachable_wat() -> Result<()> { #[test] fn hello_wasi_snapshot0() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/hello_wasi_snapshot0.wat")?; - let stdout = run_wasmtime(&["--disable-cache", wasm.path().to_str().unwrap()])?; + let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?; assert_eq!(stdout, "Hello, world!\n"); Ok(()) } @@ -194,7 +214,7 @@ fn hello_wasi_snapshot0() -> Result<()> { #[test] fn hello_wasi_snapshot1() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/hello_wasi_snapshot1.wat")?; - let stdout = run_wasmtime(&["--disable-cache", wasm.path().to_str().unwrap()])?; + let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?; assert_eq!(stdout, "Hello, world!\n"); Ok(()) } @@ -205,10 +225,10 @@ fn timeout_in_start() -> Result<()> { let output = run_wasmtime_for_output( &[ "run", + wasm.path().to_str().unwrap(), "--wasm-timeout", "1ms", "--disable-cache", - wasm.path().to_str().unwrap(), ], None, )?; @@ -229,10 +249,10 @@ fn timeout_in_invoke() -> Result<()> { let output = run_wasmtime_for_output( &[ "run", + wasm.path().to_str().unwrap(), "--wasm-timeout", "1ms", "--disable-cache", - wasm.path().to_str().unwrap(), ], None, )?; @@ -252,7 +272,7 @@ fn timeout_in_invoke() -> Result<()> { fn exit2_wasi_snapshot0() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit2_wasi_snapshot0.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; assert_eq!(output.status.code().unwrap(), 2); Ok(()) } @@ -262,7 +282,7 @@ fn exit2_wasi_snapshot0() -> Result<()> { fn exit2_wasi_snapshot1() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit2_wasi_snapshot1.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; assert_eq!(output.status.code().unwrap(), 2); Ok(()) } @@ -272,7 +292,7 @@ fn exit2_wasi_snapshot1() -> Result<()> { fn exit125_wasi_snapshot0() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit125_wasi_snapshot0.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; if cfg!(windows) { assert_eq!(output.status.code().unwrap(), 1); } else { @@ -286,7 +306,7 @@ fn exit125_wasi_snapshot0() -> Result<()> { fn exit125_wasi_snapshot1() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit125_wasi_snapshot1.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; if cfg!(windows) { assert_eq!(output.status.code().unwrap(), 1); } else { @@ -300,7 +320,7 @@ fn exit125_wasi_snapshot1() -> Result<()> { fn exit126_wasi_snapshot0() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit126_wasi_snapshot0.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; assert_eq!(output.status.code().unwrap(), 1); assert!(output.stdout.is_empty()); assert!(String::from_utf8_lossy(&output.stderr).contains("invalid exit status")); @@ -323,7 +343,7 @@ fn exit126_wasi_snapshot1() -> Result<()> { #[test] fn minimal_command() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/minimal-command.wat")?; - let stdout = run_wasmtime(&["--disable-cache", wasm.path().to_str().unwrap()])?; + let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?; assert_eq!(stdout, ""); Ok(()) } @@ -332,7 +352,7 @@ fn minimal_command() -> Result<()> { #[test] fn minimal_reactor() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/minimal-reactor.wat")?; - let stdout = run_wasmtime(&["--disable-cache", wasm.path().to_str().unwrap()])?; + let stdout = run_wasmtime(&[wasm.path().to_str().unwrap(), "--disable-cache"])?; assert_eq!(stdout, ""); Ok(()) } @@ -343,10 +363,10 @@ fn command_invoke() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/minimal-command.wat")?; run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "_start", "--disable-cache", - wasm.path().to_str().unwrap(), ])?; Ok(()) } @@ -357,10 +377,10 @@ fn reactor_invoke() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/minimal-reactor.wat")?; run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--invoke", "_initialize", "--disable-cache", - wasm.path().to_str().unwrap(), ])?; Ok(()) } @@ -371,10 +391,10 @@ fn greeter() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/greeter_command.wat")?; let stdout = run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--disable-cache", "--preload", "reactor=tests/all/cli_tests/greeter_reactor.wat", - wasm.path().to_str().unwrap(), ])?; assert_eq!( stdout, @@ -389,10 +409,10 @@ fn greeter_preload_command() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/greeter_reactor.wat")?; let stdout = run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--disable-cache", "--preload", "reactor=tests/all/cli_tests/hello_wasi_snapshot1.wat", - wasm.path().to_str().unwrap(), ])?; assert_eq!(stdout, "Hello _initialize\n"); Ok(()) @@ -404,10 +424,10 @@ fn greeter_preload_callable_command() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/greeter_command.wat")?; let stdout = run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--disable-cache", "--preload", "reactor=tests/all/cli_tests/greeter_callable_command.wat", - wasm.path().to_str().unwrap(), ])?; assert_eq!(stdout, "Hello _start\nHello callable greet\nHello done\n"); Ok(()) @@ -419,7 +439,7 @@ fn greeter_preload_callable_command() -> Result<()> { fn exit_with_saved_fprs() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/exit_with_saved_fprs.wat")?; let output = - run_wasmtime_for_output(&["--disable-cache", wasm.path().to_str().unwrap()], None)?; + run_wasmtime_for_output(&[wasm.path().to_str().unwrap(), "--disable-cache"], None)?; assert_eq!(output.status.code().unwrap(), 0); assert!(output.stdout.is_empty()); Ok(()) @@ -449,7 +469,7 @@ fn hello_wasi_snapshot0_from_stdin() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/hello_wasi_snapshot0.wat")?; let stdout = { let path = wasm.path(); - let args: &[&str] = &["--disable-cache", "-"]; + let args: &[&str] = &["-", "--disable-cache"]; let output = run_wasmtime_for_output(args, Some(path))?; if !output.status.success() { bail!( @@ -511,8 +531,6 @@ fn specify_env() -> Result<()> { #[cfg(unix)] #[test] fn run_cwasm_from_stdin() -> Result<()> { - use std::process::Stdio; - let td = TempDir::new()?; let cwasm = td.path().join("foo.cwasm"); let stdout = run_wasmtime(&[ @@ -522,32 +540,11 @@ fn run_cwasm_from_stdin() -> Result<()> { cwasm.to_str().unwrap(), ])?; assert_eq!(stdout, ""); - - // If stdin is literally the file itself then that should work let args: &[&str] = &["run", "--allow-precompiled", "-"]; - let output = get_wasmtime_command()? - .args(args) - .stdin(File::open(&cwasm)?) - .output()?; - assert!(output.status.success(), "a file as stdin should work"); - - // If stdin is a pipe, however, that should fail - let input = std::fs::read(&cwasm)?; - let mut child = get_wasmtime_command()? - .args(args) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn()?; - let mut stdin = child.stdin.take().unwrap(); - let t = std::thread::spawn(move || { - let _ = stdin.write_all(&input); - }); - let output = child.wait_with_output()?; + let output = run_wasmtime_for_output(args, Some(&cwasm))?; if output.status.success() { bail!("wasmtime should fail loading precompiled modules from piped files, but suceeded"); } - t.join().unwrap(); Ok(()) } @@ -585,6 +582,7 @@ fn run_simple_with_wasi_threads() -> Result<()> { let wasm = build_wasm("tests/all/cli_tests/simple.wat")?; let stdout = run_wasmtime(&[ "run", + wasm.path().to_str().unwrap(), "--wasi-modules", "experimental-wasi-threads", "--wasm-features", @@ -592,101 +590,12 @@ fn run_simple_with_wasi_threads() -> Result<()> { "--disable-cache", "--invoke", "simple", - wasm.path().to_str().unwrap(), "4", ])?; assert_eq!(stdout, "4\n"); Ok(()) } -#[test] -fn wasm_flags() -> Result<()> { - // Any argument after the wasm module should be interpreted as for the - // command itself - let stdout = run_wasmtime(&[ - "run", - "tests/all/cli_tests/print-arguments.wat", - "--argument", - "-for", - "the", - "command", - ])?; - assert_eq!( - stdout, - "\ - print-arguments.wat\n\ - --argument\n\ - -for\n\ - the\n\ - command\n\ - " - ); - let stdout = run_wasmtime(&["run", "tests/all/cli_tests/print-arguments.wat", "-"])?; - assert_eq!( - stdout, - "\ - print-arguments.wat\n\ - -\n\ - " - ); - let stdout = run_wasmtime(&["run", "tests/all/cli_tests/print-arguments.wat", "--"])?; - assert_eq!( - stdout, - "\ - print-arguments.wat\n\ - --\n\ - " - ); - let stdout = run_wasmtime(&[ - "run", - "tests/all/cli_tests/print-arguments.wat", - "--", - "--", - "-a", - "b", - ])?; - assert_eq!( - stdout, - "\ - print-arguments.wat\n\ - --\n\ - --\n\ - -a\n\ - b\n\ - " - ); - Ok(()) -} - -#[test] -fn name_same_as_builtin_command() -> Result<()> { - // a bare subcommand shouldn't run successfully - let output = get_wasmtime_command()? - .current_dir("tests/all/cli_tests") - .arg("run") - .output()?; - assert!(!output.status.success()); - - // a `--` prefix should let everything else get interpreted as a wasm - // module and arguments, even if the module has a name like `run` - let output = get_wasmtime_command()? - .current_dir("tests/all/cli_tests") - .arg("--") - .arg("run") - .output()?; - assert!(output.status.success(), "expected success got {output:#?}"); - - // Passing options before the subcommand should work and doesn't require - // `--` to disambiguate - let output = get_wasmtime_command()? - .current_dir("tests/all/cli_tests") - .arg("--disable-cache") - .arg("run") - .output()?; - assert!(output.status.success(), "expected success got {output:#?}"); - Ok(()) -} - #[test] #[cfg(unix)] fn run_just_stdin_argument() -> Result<()> { @@ -698,26 +607,6 @@ fn run_just_stdin_argument() -> Result<()> { Ok(()) } -#[test] -fn wasm_flags_without_subcommand() -> Result<()> { - let output = get_wasmtime_command()? - .current_dir("tests/all/cli_tests/") - .arg("print-arguments.wat") - .arg("-foo") - .arg("bar") - .output()?; - assert!(output.status.success()); - assert_eq!( - String::from_utf8_lossy(&output.stdout), - "\ - print-arguments.wat\n\ - -foo\n\ - bar\n\ - " - ); - Ok(()) -} - #[test] fn wasi_misaligned_pointer() -> Result<()> { let output = get_wasmtime_command()? diff --git a/tests/all/cli_tests/print-arguments.wat b/tests/all/cli_tests/print-arguments.wat deleted file mode 100644 index 93e4558c46f0..000000000000 --- a/tests/all/cli_tests/print-arguments.wat +++ /dev/null @@ -1,75 +0,0 @@ -(module - (import "wasi_snapshot_preview1" "fd_write" - (func $fd_write (param i32 i32 i32 i32) (result i32))) - - (import "wasi_snapshot_preview1" "args_get" - (func $args_get (param i32 i32) (result i32))) - - (memory (export "memory") 1) - - (func (export "_start") - (local $argptrs i32) - (local $argmem i32) - (local $arg i32) - - (local.set $argptrs (i32.mul (memory.grow (i32.const 1)) (i32.const 65536))) - (local.set $argmem (i32.mul (memory.grow (i32.const 1)) (i32.const 65536))) - - (if (i32.ne - (call $args_get (local.get $argptrs) (local.get $argmem)) - (i32.const 0)) - (unreachable)) - - (loop - (local.set $arg (i32.load (local.get $argptrs))) - (local.set $argptrs (i32.add (local.get $argptrs) (i32.const 4))) - (if (i32.eq (local.get $arg) (i32.const 0)) (return)) - - (call $write_all (local.get $arg) (call $strlen (local.get $arg))) - (call $write_all (i32.const 10) (i32.const 1)) - br 0 - ) - ) - - (func $write_all (param $ptr i32) (param $len i32) - (local $rc i32) - (local $iov i32) - (local $written i32) - - (local.set $written (i32.const 80)) - (local.set $iov (i32.const 100)) - - (loop - (local.get $len) - if - (i32.store (local.get $iov) (local.get $ptr)) - (i32.store offset=4 (local.get $iov) (local.get $len)) - (local.set $rc - (call $fd_write - (i32.const 1) - (local.get $iov) - (i32.const 1) - (local.get $written))) - (if (i32.ne (local.get $rc) (i32.const 0)) (unreachable)) - - (local.set $len (i32.sub (local.get $len) (i32.load (local.get $written)))) - (local.set $ptr (i32.add (local.get $ptr) (i32.load (local.get $written)))) - end - ) - ) - - (func $strlen (param $ptr i32) (result i32) - (local $len i32) - (loop - (i32.load8_u (i32.add (local.get $ptr) (local.get $len))) - if - (local.set $len (i32.add (local.get $len) (i32.const 1))) - br 1 - end - ) - local.get $len - ) - - (data (i32.const 10) "\n") -) - diff --git a/tests/all/cli_tests/run b/tests/all/cli_tests/run deleted file mode 100644 index 4139404d3725..000000000000 --- a/tests/all/cli_tests/run +++ /dev/null @@ -1,3 +0,0 @@ -(module - (func (export "_start")) -) diff --git a/tests/all/debug/gdb.rs b/tests/all/debug/gdb.rs index 3ef3518b21ed..6f5bbdb338dd 100644 --- a/tests/all/debug/gdb.rs +++ b/tests/all/debug/gdb.rs @@ -59,9 +59,9 @@ pub fn test_debug_dwarf_gdb() -> Result<()> { &[ "--disable-cache", "-g", + "tests/all/debug/testsuite/fib-wasm.wasm", "--invoke", "fib", - "tests/all/debug/testsuite/fib-wasm.wasm", "3", ], r#"set breakpoint pending on diff --git a/tests/all/debug/lldb.rs b/tests/all/debug/lldb.rs index b6a097eb60e7..08fc344f880b 100644 --- a/tests/all/debug/lldb.rs +++ b/tests/all/debug/lldb.rs @@ -64,9 +64,9 @@ pub fn test_debug_dwarf_lldb() -> Result<()> { &[ "--disable-cache", "-g", + "tests/all/debug/testsuite/fib-wasm.wasm", "--invoke", "fib", - "tests/all/debug/testsuite/fib-wasm.wasm", "3", ], r#"b fib @@ -105,9 +105,9 @@ pub fn test_debug_dwarf5_lldb() -> Result<()> { &[ "--disable-cache", "-g", + "tests/all/debug/testsuite/fib-wasm-dwarf5.wasm", "--invoke", "fib", - "tests/all/debug/testsuite/fib-wasm-dwarf5.wasm", "3", ], r#"b fib diff --git a/tests/all/wasi_testsuite.rs b/tests/all/wasi_testsuite.rs index 8edeecaa8cbd..b1708a3fa017 100644 --- a/tests/all/wasi_testsuite.rs +++ b/tests/all/wasi_testsuite.rs @@ -118,6 +118,11 @@ fn build_command>(module: P, extra_flags: &[&str], spec: &Spec) - cmd.arg(format!("{}::{}", dir, parent_dir.join(dir).display())); } } + cmd.arg(module.as_ref().to_str().unwrap()); + if let Some(spec_args) = &spec.args { + cmd.args(spec_args); + } + // Add environment variables as CLI arguments. if let Some(env) = &spec.env { for env_pair in env { @@ -126,10 +131,6 @@ fn build_command>(module: P, extra_flags: &[&str], spec: &Spec) - } cmd.envs(env); } - cmd.arg(module.as_ref().to_str().unwrap()); - if let Some(spec_args) = &spec.args { - cmd.args(spec_args); - } Ok(cmd) } From 54cbe5f4509a67c9791bcd89dd6c14ffb5b67799 Mon Sep 17 00:00:00 2001 From: wasmtime-publish <59749941+wasmtime-publish@users.noreply.github.com> Date: Mon, 21 Aug 2023 10:14:52 -0500 Subject: [PATCH 2/5] Release Wasmtime 12.0.0 (#6864) * Release Wasmtime 12.0.0 [automatically-tag-and-release-this-commit] * Update release date to today * Update release notes for 12.0.0 --------- Co-authored-by: Wasmtime Publish Co-authored-by: Alex Crichton --- RELEASES.md | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index 0ea9bc52c3b2..f2744398c22f 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,12 +2,68 @@ ## 12.0.0 -Unreleased. +Released 2023-08-21. ### Added +* Wasmtime now supports having multiple different versions of itself being + linked into the same final executable by mangling some C symbols used by + Wasmtime. + [#6673](https://github.com/bytecodealliance/wasmtime/pull/6673) + +* The `perfmap` profiling option is now supported on any Unix platform instead + of just Linux. + [#6701](https://github.com/bytecodealliance/wasmtime/pull/6701) + +* The `wasmtime` CLI now supports `--env FOO` to inherit the value of the + environment variable `FOO` which avoids needing to do `--env FOO=$FOO` for + example. + [#6746](https://github.com/bytecodealliance/wasmtime/pull/6746) + +* Wasmtime now supports component model resources, although support has not yet + been added to `bindgen!`. + [#6691](https://github.com/bytecodealliance/wasmtime/pull/6691) + +* Wasmtime now supports configuration to enable the tail calls proposal. + Platform support now also includes AArch64 and RISC-V in addition to the + previous x86\_64 support. + [#6723](https://github.com/bytecodealliance/wasmtime/pull/6723) + [#6749](https://github.com/bytecodealliance/wasmtime/pull/6749) + [#6774](https://github.com/bytecodealliance/wasmtime/pull/6774) + +* Wasmtime's implementation of WASI Preview 2 now supports streams/pollables + with host objects that are all backed by Rust `async`. + [#6556](https://github.com/bytecodealliance/wasmtime/pull/6556) + +* Support for core dumps has now been added to the `wasmtime` crate. + [#6513](https://github.com/bytecodealliance/wasmtime/pull/6513) + +* New `{Module,Component}::resources_required` APIs allow inspecting what will + be required when instantiating the module or component. + [#6789](https://github.com/bytecodealliance/wasmtime/pull/6789) + +### Fixed + +* Functions on instances defined through `component::Linker::func_new` are now + defined correctly. + [#6637](https://github.com/bytecodealliance/wasmtime/pull/6637) + +* The `async_stack_size` configuration option is no longer inspected when + `async_support` is disabled at runtime. + [#6771](https://github.com/bytecodealliance/wasmtime/pull/6771) + +* WASI Preview 1 APIs will now trap on misaligned or out-of-bounds pointers + instead of returning an error. + [#6776](https://github.com/bytecodealliance/wasmtime/pull/6776) + +* Optimized the cranelift compilation on aarch64 for large wasm modules. + [#6804](https://github.com/bytecodealliance/wasmtime/pull/6804) + ### Changed +* Empty types are no longer allowed in the component model. + [#6777](https://github.com/bytecodealliance/wasmtime/pull/6777) + -------------------------------------------------------------------------------- ## 11.0.0 From ee7cc00e2750b861808e607cd3bd9e0b99a46911 Mon Sep 17 00:00:00 2001 From: Timon Date: Thu, 24 Aug 2023 17:41:16 +0200 Subject: [PATCH 3/5] Backport: "Cranelift: avoid quadratic behavior in label-fixup processing" to 12.0.1 (#6897) * Cranelift: avoid quadratic behavior in label-fixup processing (#6804) * WIP: two-tier processing for MachBuffer veneer processing in island emission * Unconditionally emit veneers for label forward-refs that cross islands. * Clean up and fix tests * Review feedback * Add some more detailed comments. * Update the releases file to reflect the patch --------- Co-authored-by: Chris Fallin --- RELEASES.md | 12 +- .../codegen/src/isa/aarch64/inst/emit.rs | 4 +- .../codegen/src/isa/riscv64/inst/emit.rs | 4 +- cranelift/codegen/src/machinst/buffer.rs | 185 ++++++++++++++---- cranelift/codegen/src/machinst/vcode.rs | 2 +- 5 files changed, 160 insertions(+), 47 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index f2744398c22f..9ecdfceb6121 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,5 +1,14 @@ -------------------------------------------------------------------------------- +## 12.0.1 + +Unreleased + +### Fixed + +* Optimized the cranelift compilation on aarch64 for large wasm modules. + [#6804](https://github.com/bytecodealliance/wasmtime/pull/6804) + ## 12.0.0 Released 2023-08-21. @@ -56,9 +65,6 @@ Released 2023-08-21. instead of returning an error. [#6776](https://github.com/bytecodealliance/wasmtime/pull/6776) -* Optimized the cranelift compilation on aarch64 for large wasm modules. - [#6804](https://github.com/bytecodealliance/wasmtime/pull/6804) - ### Changed * Empty types are no longer allowed in the component model. diff --git a/cranelift/codegen/src/isa/aarch64/inst/emit.rs b/cranelift/codegen/src/isa/aarch64/inst/emit.rs index 085daaf27153..a828135bfdc5 100644 --- a/cranelift/codegen/src/isa/aarch64/inst/emit.rs +++ b/cranelift/codegen/src/isa/aarch64/inst/emit.rs @@ -3590,7 +3590,7 @@ impl MachInstEmit for Inst { dest: BranchTarget::Label(jump_around_label), }; jmp.emit(&[], sink, emit_info, state); - sink.emit_island(needed_space + 4, &mut state.ctrl_plane); + sink.emit_island(&mut state.ctrl_plane); sink.bind_label(jump_around_label, &mut state.ctrl_plane); } } @@ -3789,7 +3789,7 @@ fn emit_return_call_common_sequence( dest: BranchTarget::Label(jump_around_label), }; jmp.emit(&[], sink, emit_info, state); - sink.emit_island(space_needed + 4, &mut state.ctrl_plane); + sink.emit_island(&mut state.ctrl_plane); sink.bind_label(jump_around_label, &mut state.ctrl_plane); } diff --git a/cranelift/codegen/src/isa/riscv64/inst/emit.rs b/cranelift/codegen/src/isa/riscv64/inst/emit.rs index 348007d2ffb0..f522bc50ef06 100644 --- a/cranelift/codegen/src/isa/riscv64/inst/emit.rs +++ b/cranelift/codegen/src/isa/riscv64/inst/emit.rs @@ -1189,7 +1189,7 @@ impl MachInstEmit for Inst { // we need to emit a jump table here to support that jump. let distance = (targets.len() * 2 * Inst::INSTRUCTION_SIZE as usize) as u32; if sink.island_needed(distance) { - sink.emit_island(distance, &mut state.ctrl_plane); + sink.emit_island(&mut state.ctrl_plane); } // Emit the jumps back to back @@ -3132,7 +3132,7 @@ fn emit_return_call_common_sequence( dest: BranchTarget::Label(jump_around_label), } .emit(&[], sink, emit_info, state); - sink.emit_island(space_needed + 4, &mut state.ctrl_plane); + sink.emit_island(&mut state.ctrl_plane); sink.bind_label(jump_around_label, &mut state.ctrl_plane); } diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 9f458052e185..72460136e3f5 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -139,6 +139,52 @@ //! //! Given these invariants, we argue why each optimization preserves execution //! semantics below (grep for "Preserves execution semantics"). +//! +//! # Avoiding Quadratic Behavior +//! +//! There are two cases where we've had to take some care to avoid +//! quadratic worst-case behavior: +//! +//! - The "labels at this branch" list can grow unboundedly if the +//! code generator binds many labels at one location. If the count +//! gets too high (defined by the `LABEL_LIST_THRESHOLD` constant), we +//! simply abort an optimization early in a way that is always correct +//! but is conservative. +//! +//! - The fixup list can interact with island emission to create +//! "quadratic island behvior". In a little more detail, one can hit +//! this behavior by having some pending fixups (forward label +//! references) with long-range label-use kinds, and some others +//! with shorter-range references that nonetheless still are pending +//! long enough to trigger island generation. In such a case, we +//! process the fixup list, generate veneers to extend some forward +//! references' ranges, but leave the other (longer-range) ones +//! alone. The way this was implemented put them back on a list and +//! resulted in quadratic behavior. +//! +//! To avoid this, we could use a better data structure that allows +//! us to query for fixups with deadlines "coming soon" and generate +//! veneers for only those fixups. However, there is some +//! interaction with the branch peephole optimizations: the +//! invariant there is that branches in the "most recent branches +//! contiguous with end of buffer" list have corresponding fixups in +//! order (so that when we chomp the branch, we can chomp its fixup +//! too). +//! +//! So instead, when we generate an island, for now we create +//! veneers for *all* pending fixups, then if upgraded to a kind +//! that no longer supports veneers (is at "max range"), kick the +//! fixups off to a list that is *not* processed at islands except +//! for one last pass after emission. This allows us to skip the +//! work and avoids the quadratic behvior. We expect that this is +//! fine-ish for now: islands are relatively rare, and if they do +//! happen and generate unnecessary veneers (as will now happen for +//! the case above) we'll only get one unnecessary veneer per +//! branch (then they are at max range already). +//! +//! Longer-term, we could use a data structure that allows querying +//! by deadline, as long as we can properly chomp just-added fixups +//! when chomping branches. use crate::binemit::{Addend, CodeOffset, Reloc, StackMap}; use crate::ir::{ExternalName, Opcode, RelSourceLoc, SourceLoc, TrapCode}; @@ -150,7 +196,7 @@ use crate::timing; use crate::trace; use cranelift_control::ControlPlane; use cranelift_entity::{entity_impl, PrimaryMap}; -use smallvec::SmallVec; +use smallvec::{smallvec, SmallVec}; use std::convert::TryFrom; use std::mem; use std::string::String; @@ -190,6 +236,18 @@ impl CompilePhase for Final { type SourceLocType = SourceLoc; } +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum ForceVeneers { + Yes, + No, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum IsLastIsland { + Yes, + No, +} + /// A buffer of output to be produced, fixed up, and then emitted to a CodeSink /// in bulk. /// @@ -234,6 +292,10 @@ pub struct MachBuffer { pending_traps: SmallVec<[MachLabelTrap; 16]>, /// Fixups that must be performed after all code is emitted. fixup_records: SmallVec<[MachLabelFixup; 16]>, + /// Fixups whose labels are at maximum range already: these need + /// not be considered in island emission until we're done + /// emitting. + fixup_records_max_range: SmallVec<[MachLabelFixup; 16]>, /// Current deadline at which all constants are flushed and all code labels /// are extended by emitting long-range jumps in an island. This flush /// should be rare (e.g., on AArch64, the shortest-range PC-rel references @@ -389,6 +451,7 @@ impl MachBuffer { pending_constants: SmallVec::new(), pending_traps: SmallVec::new(), fixup_records: SmallVec::new(), + fixup_records_max_range: SmallVec::new(), island_deadline: UNKNOWN_LABEL_OFFSET, island_worst_case_size: 0, latest_branches: SmallVec::new(), @@ -1157,16 +1220,16 @@ impl MachBuffer { /// Should only be called if `island_needed()` returns true, i.e., if we /// actually reach a deadline. It's not necessarily a problem to do so /// otherwise but it may result in unnecessary work during emission. - pub fn emit_island(&mut self, distance: CodeOffset, ctrl_plane: &mut ControlPlane) { - self.emit_island_maybe_forced(false, distance, ctrl_plane); + pub fn emit_island(&mut self, ctrl_plane: &mut ControlPlane) { + self.emit_island_maybe_forced(ForceVeneers::No, IsLastIsland::No, ctrl_plane); } /// Same as `emit_island`, but an internal API with a `force_veneers` /// argument to force all veneers to always get emitted for debugging. fn emit_island_maybe_forced( &mut self, - force_veneers: bool, - distance: CodeOffset, + force_veneers: ForceVeneers, + last_island: IsLastIsland, ctrl_plane: &mut ControlPlane, ) { // We're going to purge fixups, so no latest-branch editing can happen @@ -1174,10 +1237,7 @@ impl MachBuffer { self.latest_branches.clear(); // Reset internal calculations about islands since we're going to - // change the calculus as we apply fixups. The `forced_threshold` is - // used here to determine whether jumps to unknown labels will require - // a veneer or not. - let forced_threshold = self.worst_case_end_of_island(distance); + // change the calculus as we apply fixups. self.island_deadline = UNKNOWN_LABEL_OFFSET; self.island_worst_case_size = 0; @@ -1232,7 +1292,14 @@ impl MachBuffer { self.get_appended_space(size); } - for fixup in mem::take(&mut self.fixup_records) { + let last_island_fixups = match last_island { + IsLastIsland::Yes => mem::take(&mut self.fixup_records_max_range), + IsLastIsland::No => smallvec![], + }; + for fixup in mem::take(&mut self.fixup_records) + .into_iter() + .chain(last_island_fixups.into_iter()) + { trace!("emit_island: fixup {:?}", fixup); let MachLabelFixup { label, @@ -1275,7 +1342,8 @@ impl MachBuffer { kind.max_neg_range() ); - if (force_veneers && kind.supports_veneer()) || veneer_required { + if (force_veneers == ForceVeneers::Yes && kind.supports_veneer()) || veneer_required + { self.emit_veneer(label, offset, kind); } else { let slice = &mut self.data[start..end]; @@ -1284,21 +1352,43 @@ impl MachBuffer { } } else { // If the offset of this label is not known at this time then - // there's one of two possibilities: + // there are three possibilities: // - // * First we may be about to exceed the maximum jump range of - // this fixup. In that case a veneer is inserted to buy some - // more budget for the forward-jump. It's guaranteed that the - // label will eventually come after where we're at, so we know - // that the forward jump is necessary. + // 1. It's possible that the label is already a "max + // range" label: a veneer would not help us any, + // and so we need not consider the label during + // island emission any more until the very end (the + // last "island" pass). In this case we kick the + // label into a separate list to process once at + // the end, to avoid quadratic behavior (see + // "quadratic island behavior" above, and issue + // #6798). // - // * Otherwise we're still within range of the forward jump but - // the precise target isn't known yet. In that case we - // enqueue the fixup to get processed later. - if forced_threshold - offset > kind.max_pos_range() { - self.emit_veneer(label, offset, kind); + // 2. Or, we may be about to exceed the maximum jump range of + // this fixup. In that case a veneer is inserted to buy some + // more budget for the forward-jump. It's guaranteed that the + // label will eventually come after where we're at, so we know + // that the forward jump is necessary. + // + // 3. Otherwise, we're still within range of the + // forward jump but the precise target isn't known + // yet. In that case, to avoid quadratic behavior + // (again, see above), we emit a veneer and if the + // resulting label-use fixup is then max-range, we + // put it in the max-range list. We could enqueue + // the fixup for processing later, and this would + // enable slightly fewer veneers, but islands are + // relatively rare and the cost of "upgrading" all + // forward label refs that cross an island should + // be relatively low. + if !kind.supports_veneer() { + self.fixup_records_max_range.push(MachLabelFixup { + label, + offset, + kind, + }); } else { - self.use_label_at_offset(offset, label, kind); + self.emit_veneer(label, offset, kind); } } } @@ -1346,25 +1436,36 @@ impl MachBuffer { veneer_fixup_off, veneer_label_use ); - // Register a new use of `label` with our new veneer fixup and offset. - // This'll recalculate deadlines accordingly and enqueue this fixup to - // get processed at some later time. - self.use_label_at_offset(veneer_fixup_off, label, veneer_label_use); + // Register a new use of `label` with our new veneer fixup and + // offset. This'll recalculate deadlines accordingly and + // enqueue this fixup to get processed at some later + // time. Note that if we now have a max-range, we instead skip + // the usual fixup list to avoid quadratic behavior. + if veneer_label_use.supports_veneer() { + self.use_label_at_offset(veneer_fixup_off, label, veneer_label_use); + } else { + self.fixup_records_max_range.push(MachLabelFixup { + label, + offset: veneer_fixup_off, + kind: veneer_label_use, + }); + } } fn finish_emission_maybe_forcing_veneers( &mut self, - force_veneers: bool, + force_veneers: ForceVeneers, ctrl_plane: &mut ControlPlane, ) { while !self.pending_constants.is_empty() || !self.pending_traps.is_empty() || !self.fixup_records.is_empty() + || !self.fixup_records_max_range.is_empty() { // `emit_island()` will emit any pending veneers and constants, and // as a side-effect, will also take care of any fixups with resolved // labels eagerly. - self.emit_island_maybe_forced(force_veneers, u32::MAX, ctrl_plane); + self.emit_island_maybe_forced(force_veneers, IsLastIsland::Yes, ctrl_plane); } // Ensure that all labels have been fixed up after the last island is emitted. This is a @@ -1385,7 +1486,7 @@ impl MachBuffer { // had bound one last label. self.optimize_branches(ctrl_plane); - self.finish_emission_maybe_forcing_veneers(false, ctrl_plane); + self.finish_emission_maybe_forcing_veneers(ForceVeneers::No, ctrl_plane); let alignment = self.finish_constants(constants); @@ -1734,7 +1835,7 @@ impl MachBranch { pub struct MachTextSectionBuilder { buf: MachBuffer, next_func: usize, - force_veneers: bool, + force_veneers: ForceVeneers, } impl MachTextSectionBuilder { @@ -1746,7 +1847,7 @@ impl MachTextSectionBuilder { MachTextSectionBuilder { buf, next_func: 0, - force_veneers: false, + force_veneers: ForceVeneers::No, } } } @@ -1762,9 +1863,9 @@ impl TextSectionBuilder for MachTextSectionBuilder { // Conditionally emit an island if it's necessary to resolve jumps // between functions which are too far away. let size = func.len() as u32; - if self.force_veneers || self.buf.island_needed(size) { + if self.force_veneers == ForceVeneers::Yes || self.buf.island_needed(size) { self.buf - .emit_island_maybe_forced(self.force_veneers, size, ctrl_plane); + .emit_island_maybe_forced(self.force_veneers, IsLastIsland::No, ctrl_plane); } self.buf.align_to(align); @@ -1796,7 +1897,7 @@ impl TextSectionBuilder for MachTextSectionBuilder { } fn force_veneers(&mut self) { - self.force_veneers = true; + self.force_veneers = ForceVeneers::Yes; } fn finish(&mut self, ctrl_plane: &mut ControlPlane) -> Vec { @@ -1946,7 +2047,7 @@ mod test { buf.bind_label(label(1), state.ctrl_plane_mut()); while buf.cur_offset() < 2000000 { if buf.island_needed(0) { - buf.emit_island(0, state.ctrl_plane_mut()); + buf.emit_island(state.ctrl_plane_mut()); } let inst = Inst::Nop4; inst.emit(&[], &mut buf, &info, &mut state); @@ -1983,9 +2084,15 @@ mod test { // before the deadline. taken: BranchTarget::ResolvedOffset((1 << 20) - 4 - 20), - // This branch is in-range so no veneers should be needed, it should - // go directly to the target. - not_taken: BranchTarget::ResolvedOffset(2000000 + 4 - 4), + // This branch is in-range so no veneers are technically + // be needed; however because we resolve *all* pending + // fixups that cross an island when that island occurs, it + // will have a veneer as well. This veneer comes just + // after the one above. (Note that because the CondBr has + // two instructions, the conditinoal and unconditional, + // this offset is the same, though the veneer is four + // bytes later.) + not_taken: BranchTarget::ResolvedOffset((1 << 20) - 4 - 20), }; inst.emit(&[], &mut buf2, &info, &mut state); diff --git a/cranelift/codegen/src/machinst/vcode.rs b/cranelift/codegen/src/machinst/vcode.rs index 6b05b38c8bd3..59c7328c3aa8 100644 --- a/cranelift/codegen/src/machinst/vcode.rs +++ b/cranelift/codegen/src/machinst/vcode.rs @@ -1050,7 +1050,7 @@ impl VCode { bb_padding.len() as u32 + I::LabelUse::ALIGN - 1 }; if buffer.island_needed(padding + worst_case_next_bb) { - buffer.emit_island(padding + worst_case_next_bb, ctrl_plane); + buffer.emit_island(ctrl_plane); } // Insert padding, if configured, to stress the `MachBuffer`'s From 6116aae3d4cdcc2ec9f385a0146a93240f009cca Mon Sep 17 00:00:00 2001 From: wasmtime-publish <59749941+wasmtime-publish@users.noreply.github.com> Date: Thu, 24 Aug 2023 13:01:46 -0500 Subject: [PATCH 4/5] Release Wasmtime 12.0.1 (#6901) * Release Wasmtime 12.0.1 [automatically-tag-and-release-this-commit] * Update cargo-vet metadata --------- Co-authored-by: Wasmtime Publish Co-authored-by: Alex Crichton --- Cargo.lock | 110 +++---- Cargo.toml | 92 +++--- RELEASES.md | 2 +- cranelift/bforest/Cargo.toml | 2 +- cranelift/codegen/Cargo.toml | 8 +- cranelift/codegen/meta/Cargo.toml | 4 +- cranelift/codegen/shared/Cargo.toml | 2 +- cranelift/control/Cargo.toml | 2 +- cranelift/entity/Cargo.toml | 2 +- cranelift/frontend/Cargo.toml | 2 +- cranelift/interpreter/Cargo.toml | 2 +- cranelift/isle/isle/Cargo.toml | 2 +- cranelift/jit/Cargo.toml | 2 +- cranelift/module/Cargo.toml | 2 +- cranelift/native/Cargo.toml | 2 +- cranelift/object/Cargo.toml | 2 +- cranelift/reader/Cargo.toml | 2 +- cranelift/serde/Cargo.toml | 2 +- cranelift/umbrella/Cargo.toml | 2 +- cranelift/wasm/Cargo.toml | 2 +- crates/c-api/include/wasmtime.h | 4 +- supply-chain/imports.lock | 436 ++++++++++++++++++++++++++++ winch/codegen/Cargo.toml | 2 +- 23 files changed, 562 insertions(+), 126 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 944fe518213b..378d8961ca1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -285,7 +285,7 @@ checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" [[package]] name = "byte-array-literals" -version = "12.0.0" +version = "12.0.1" [[package]] name = "byteorder" @@ -653,7 +653,7 @@ dependencies = [ [[package]] name = "cranelift" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen", "cranelift-frontend", @@ -661,14 +661,14 @@ dependencies = [ [[package]] name = "cranelift-bforest" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-entity", ] [[package]] name = "cranelift-codegen" -version = "0.99.0" +version = "0.99.1" dependencies = [ "anyhow", "bincode", @@ -695,25 +695,25 @@ dependencies = [ [[package]] name = "cranelift-codegen-meta" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen-shared", ] [[package]] name = "cranelift-codegen-shared" -version = "0.99.0" +version = "0.99.1" [[package]] name = "cranelift-control" -version = "0.99.0" +version = "0.99.1" dependencies = [ "arbitrary", ] [[package]] name = "cranelift-entity" -version = "0.99.0" +version = "0.99.1" dependencies = [ "serde", ] @@ -749,7 +749,7 @@ dependencies = [ [[package]] name = "cranelift-frontend" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen", "hashbrown 0.13.2", @@ -773,7 +773,7 @@ dependencies = [ [[package]] name = "cranelift-interpreter" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -787,7 +787,7 @@ dependencies = [ [[package]] name = "cranelift-isle" -version = "0.99.0" +version = "0.99.1" dependencies = [ "codespan-reporting", "log", @@ -796,7 +796,7 @@ dependencies = [ [[package]] name = "cranelift-jit" -version = "0.99.0" +version = "0.99.1" dependencies = [ "anyhow", "cranelift", @@ -817,7 +817,7 @@ dependencies = [ [[package]] name = "cranelift-module" -version = "0.99.0" +version = "0.99.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -828,7 +828,7 @@ dependencies = [ [[package]] name = "cranelift-native" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen", "libc", @@ -837,7 +837,7 @@ dependencies = [ [[package]] name = "cranelift-object" -version = "0.99.0" +version = "0.99.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -852,7 +852,7 @@ dependencies = [ [[package]] name = "cranelift-reader" -version = "0.99.0" +version = "0.99.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -862,7 +862,7 @@ dependencies = [ [[package]] name = "cranelift-serde" -version = "0.99.0" +version = "0.99.1" dependencies = [ "clap", "cranelift-codegen", @@ -909,7 +909,7 @@ dependencies = [ [[package]] name = "cranelift-wasm" -version = "0.99.0" +version = "0.99.1" dependencies = [ "cranelift-codegen", "cranelift-entity", @@ -3557,7 +3557,7 @@ dependencies = [ [[package]] name = "verify-component-adapter" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "wasmparser 0.92.0", @@ -3613,7 +3613,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasi-cap-std-sync" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "async-trait", @@ -3636,7 +3636,7 @@ dependencies = [ [[package]] name = "wasi-common" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "bitflags 2.3.3", @@ -3691,7 +3691,7 @@ dependencies = [ [[package]] name = "wasi-preview1-component-adapter" -version = "12.0.0" +version = "12.0.1" dependencies = [ "byte-array-literals", "object", @@ -3711,7 +3711,7 @@ dependencies = [ [[package]] name = "wasi-tokio" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cap-std", @@ -3944,7 +3944,7 @@ dependencies = [ [[package]] name = "wasmtime" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "async-trait", @@ -3984,14 +3984,14 @@ dependencies = [ [[package]] name = "wasmtime-asm-macros" -version = "12.0.0" +version = "12.0.1" dependencies = [ "cfg-if", ] [[package]] name = "wasmtime-bench-api" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cap-std", @@ -4009,7 +4009,7 @@ dependencies = [ [[package]] name = "wasmtime-c-api" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cap-std", @@ -4033,7 +4033,7 @@ dependencies = [ [[package]] name = "wasmtime-cache" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "base64", @@ -4055,7 +4055,7 @@ dependencies = [ [[package]] name = "wasmtime-cli" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "async-trait", @@ -4105,7 +4105,7 @@ dependencies = [ [[package]] name = "wasmtime-cli-flags" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "clap", @@ -4117,7 +4117,7 @@ dependencies = [ [[package]] name = "wasmtime-component-macro" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "component-macro-test-helpers", @@ -4133,11 +4133,11 @@ dependencies = [ [[package]] name = "wasmtime-component-util" -version = "12.0.0" +version = "12.0.1" [[package]] name = "wasmtime-cranelift" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -4159,7 +4159,7 @@ dependencies = [ [[package]] name = "wasmtime-cranelift-shared" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -4173,7 +4173,7 @@ dependencies = [ [[package]] name = "wasmtime-environ" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "atty", @@ -4211,7 +4211,7 @@ dependencies = [ [[package]] name = "wasmtime-explorer" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "capstone", @@ -4224,7 +4224,7 @@ dependencies = [ [[package]] name = "wasmtime-fiber" -version = "12.0.0" +version = "12.0.1" dependencies = [ "backtrace", "cc", @@ -4292,7 +4292,7 @@ dependencies = [ [[package]] name = "wasmtime-jit" -version = "12.0.0" +version = "12.0.1" dependencies = [ "addr2line", "anyhow", @@ -4316,7 +4316,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-debug" -version = "12.0.0" +version = "12.0.1" dependencies = [ "object", "once_cell", @@ -4326,7 +4326,7 @@ dependencies = [ [[package]] name = "wasmtime-jit-icache-coherence" -version = "12.0.0" +version = "12.0.1" dependencies = [ "cfg-if", "libc", @@ -4335,7 +4335,7 @@ dependencies = [ [[package]] name = "wasmtime-runtime" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cc", @@ -4363,7 +4363,7 @@ dependencies = [ [[package]] name = "wasmtime-types" -version = "12.0.0" +version = "12.0.1" dependencies = [ "cranelift-entity", "serde", @@ -4373,7 +4373,7 @@ dependencies = [ [[package]] name = "wasmtime-versioned-export-macros" -version = "12.0.0" +version = "12.0.1" dependencies = [ "proc-macro2", "quote", @@ -4382,7 +4382,7 @@ dependencies = [ [[package]] name = "wasmtime-wasi" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "async-trait", @@ -4412,7 +4412,7 @@ dependencies = [ [[package]] name = "wasmtime-wasi-crypto" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "wasi-crypto", @@ -4422,7 +4422,7 @@ dependencies = [ [[package]] name = "wasmtime-wasi-http" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "bytes", @@ -4440,7 +4440,7 @@ dependencies = [ [[package]] name = "wasmtime-wasi-nn" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "openvino", @@ -4451,7 +4451,7 @@ dependencies = [ [[package]] name = "wasmtime-wasi-threads" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "log", @@ -4463,7 +4463,7 @@ dependencies = [ [[package]] name = "wasmtime-wast" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "log", @@ -4473,7 +4473,7 @@ dependencies = [ [[package]] name = "wasmtime-winch" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "cranelift-codegen", @@ -4488,7 +4488,7 @@ dependencies = [ [[package]] name = "wasmtime-wit-bindgen" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "heck", @@ -4558,7 +4558,7 @@ dependencies = [ [[package]] name = "wiggle" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "async-trait", @@ -4575,7 +4575,7 @@ dependencies = [ [[package]] name = "wiggle-generate" -version = "12.0.0" +version = "12.0.1" dependencies = [ "anyhow", "heck", @@ -4588,7 +4588,7 @@ dependencies = [ [[package]] name = "wiggle-macro" -version = "12.0.0" +version = "12.0.1" dependencies = [ "proc-macro2", "quote", @@ -4643,7 +4643,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "winch-codegen" -version = "0.10.0" +version = "0.10.1" dependencies = [ "anyhow", "cranelift-codegen", diff --git a/Cargo.toml b/Cargo.toml index c40532c4fe68..d3328eeac37a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -117,64 +117,64 @@ exclude = [ ] [workspace.package] -version = "12.0.0" +version = "12.0.1" authors = ["The Wasmtime Project Developers"] edition = "2021" rust-version = "1.66.0" [workspace.dependencies] -wasmtime = { path = "crates/wasmtime", version = "12.0.0", default-features = false } -wasmtime-cache = { path = "crates/cache", version = "=12.0.0" } -wasmtime-cli-flags = { path = "crates/cli-flags", version = "=12.0.0" } -wasmtime-cranelift = { path = "crates/cranelift", version = "=12.0.0" } -wasmtime-cranelift-shared = { path = "crates/cranelift-shared", version = "=12.0.0" } -wasmtime-winch = { path = "crates/winch", version = "=12.0.0" } -wasmtime-environ = { path = "crates/environ", version = "=12.0.0" } -wasmtime-explorer = { path = "crates/explorer", version = "=12.0.0" } -wasmtime-fiber = { path = "crates/fiber", version = "=12.0.0" } -wasmtime-types = { path = "crates/types", version = "12.0.0" } -wasmtime-jit = { path = "crates/jit", version = "=12.0.0" } -wasmtime-jit-debug = { path = "crates/jit-debug", version = "=12.0.0" } -wasmtime-runtime = { path = "crates/runtime", version = "=12.0.0" } -wasmtime-wast = { path = "crates/wast", version = "=12.0.0" } -wasmtime-wasi = { path = "crates/wasi", version = "12.0.0" } -wasmtime-wasi-crypto = { path = "crates/wasi-crypto", version = "12.0.0" } -wasmtime-wasi-http = { path = "crates/wasi-http", version = "=12.0.0" } -wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "12.0.0" } -wasmtime-wasi-threads = { path = "crates/wasi-threads", version = "12.0.0" } -wasmtime-component-util = { path = "crates/component-util", version = "=12.0.0" } -wasmtime-component-macro = { path = "crates/component-macro", version = "=12.0.0" } -wasmtime-asm-macros = { path = "crates/asm-macros", version = "=12.0.0" } -wasmtime-versioned-export-macros = { path = "crates/versioned-export-macros", version = "=12.0.0" } +wasmtime = { path = "crates/wasmtime", version = "12.0.1", default-features = false } +wasmtime-cache = { path = "crates/cache", version = "=12.0.1" } +wasmtime-cli-flags = { path = "crates/cli-flags", version = "=12.0.1" } +wasmtime-cranelift = { path = "crates/cranelift", version = "=12.0.1" } +wasmtime-cranelift-shared = { path = "crates/cranelift-shared", version = "=12.0.1" } +wasmtime-winch = { path = "crates/winch", version = "=12.0.1" } +wasmtime-environ = { path = "crates/environ", version = "=12.0.1" } +wasmtime-explorer = { path = "crates/explorer", version = "=12.0.1" } +wasmtime-fiber = { path = "crates/fiber", version = "=12.0.1" } +wasmtime-types = { path = "crates/types", version = "12.0.1" } +wasmtime-jit = { path = "crates/jit", version = "=12.0.1" } +wasmtime-jit-debug = { path = "crates/jit-debug", version = "=12.0.1" } +wasmtime-runtime = { path = "crates/runtime", version = "=12.0.1" } +wasmtime-wast = { path = "crates/wast", version = "=12.0.1" } +wasmtime-wasi = { path = "crates/wasi", version = "12.0.1" } +wasmtime-wasi-crypto = { path = "crates/wasi-crypto", version = "12.0.1" } +wasmtime-wasi-http = { path = "crates/wasi-http", version = "=12.0.1" } +wasmtime-wasi-nn = { path = "crates/wasi-nn", version = "12.0.1" } +wasmtime-wasi-threads = { path = "crates/wasi-threads", version = "12.0.1" } +wasmtime-component-util = { path = "crates/component-util", version = "=12.0.1" } +wasmtime-component-macro = { path = "crates/component-macro", version = "=12.0.1" } +wasmtime-asm-macros = { path = "crates/asm-macros", version = "=12.0.1" } +wasmtime-versioned-export-macros = { path = "crates/versioned-export-macros", version = "=12.0.1" } component-test-util = { path = "crates/misc/component-test-util" } component-fuzz-util = { path = "crates/misc/component-fuzz-util" } -wiggle = { path = "crates/wiggle", version = "=12.0.0", default-features = false } -wiggle-macro = { path = "crates/wiggle/macro", version = "=12.0.0" } -wiggle-generate = { path = "crates/wiggle/generate", version = "=12.0.0" } -wasi-common = { path = "crates/wasi-common", version = "=12.0.0" } -wasi-tokio = { path = "crates/wasi-common/tokio", version = "=12.0.0" } -wasi-cap-std-sync = { path = "crates/wasi-common/cap-std-sync", version = "=12.0.0" } +wiggle = { path = "crates/wiggle", version = "=12.0.1", default-features = false } +wiggle-macro = { path = "crates/wiggle/macro", version = "=12.0.1" } +wiggle-generate = { path = "crates/wiggle/generate", version = "=12.0.1" } +wasi-common = { path = "crates/wasi-common", version = "=12.0.1" } +wasi-tokio = { path = "crates/wasi-common/tokio", version = "=12.0.1" } +wasi-cap-std-sync = { path = "crates/wasi-common/cap-std-sync", version = "=12.0.1" } wasmtime-fuzzing = { path = "crates/fuzzing" } -wasmtime-jit-icache-coherence = { path = "crates/jit-icache-coherence", version = "=12.0.0" } -wasmtime-wit-bindgen = { path = "crates/wit-bindgen", version = "=12.0.0" } +wasmtime-jit-icache-coherence = { path = "crates/jit-icache-coherence", version = "=12.0.1" } +wasmtime-wit-bindgen = { path = "crates/wit-bindgen", version = "=12.0.1" } -cranelift-wasm = { path = "cranelift/wasm", version = "0.99.0" } -cranelift-codegen = { path = "cranelift/codegen", version = "0.99.0" } -cranelift-frontend = { path = "cranelift/frontend", version = "0.99.0" } -cranelift-entity = { path = "cranelift/entity", version = "0.99.0" } -cranelift-native = { path = "cranelift/native", version = "0.99.0" } -cranelift-module = { path = "cranelift/module", version = "0.99.0" } -cranelift-interpreter = { path = "cranelift/interpreter", version = "0.99.0" } -cranelift-reader = { path = "cranelift/reader", version = "0.99.0" } +cranelift-wasm = { path = "cranelift/wasm", version = "0.99.1" } +cranelift-codegen = { path = "cranelift/codegen", version = "0.99.1" } +cranelift-frontend = { path = "cranelift/frontend", version = "0.99.1" } +cranelift-entity = { path = "cranelift/entity", version = "0.99.1" } +cranelift-native = { path = "cranelift/native", version = "0.99.1" } +cranelift-module = { path = "cranelift/module", version = "0.99.1" } +cranelift-interpreter = { path = "cranelift/interpreter", version = "0.99.1" } +cranelift-reader = { path = "cranelift/reader", version = "0.99.1" } cranelift-filetests = { path = "cranelift/filetests" } -cranelift-object = { path = "cranelift/object", version = "0.99.0" } -cranelift-jit = { path = "cranelift/jit", version = "0.99.0" } +cranelift-object = { path = "cranelift/object", version = "0.99.1" } +cranelift-jit = { path = "cranelift/jit", version = "0.99.1" } cranelift-fuzzgen = { path = "cranelift/fuzzgen" } -cranelift-bforest = { path = "cranelift/bforest", version = "0.99.0" } -cranelift-control = { path = "cranelift/control", version = "0.99.0" } -cranelift = { path = "cranelift/umbrella", version = "0.99.0" } +cranelift-bforest = { path = "cranelift/bforest", version = "0.99.1" } +cranelift-control = { path = "cranelift/control", version = "0.99.1" } +cranelift = { path = "cranelift/umbrella", version = "0.99.1" } -winch-codegen = { path = "winch/codegen", version = "=0.10.0" } +winch-codegen = { path = "winch/codegen", version = "=0.10.1" } winch-filetests = { path = "winch/filetests" } winch-test-macros = { path = "winch/test-macros" } diff --git a/RELEASES.md b/RELEASES.md index 9ecdfceb6121..bc8e3e50a0ec 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -2,7 +2,7 @@ ## 12.0.1 -Unreleased +Released 2023-08-24 ### Fixed diff --git a/cranelift/bforest/Cargo.toml b/cranelift/bforest/Cargo.toml index 008e295bfb03..8c8254e5caf6 100644 --- a/cranelift/bforest/Cargo.toml +++ b/cranelift/bforest/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-bforest" -version = "0.99.0" +version = "0.99.1" description = "A forest of B+-trees" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift-bforest" diff --git a/cranelift/codegen/Cargo.toml b/cranelift/codegen/Cargo.toml index a0a78ba867c4..06318381bcd7 100644 --- a/cranelift/codegen/Cargo.toml +++ b/cranelift/codegen/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-codegen" -version = "0.99.0" +version = "0.99.1" description = "Low-level code generator library" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift-codegen" @@ -16,7 +16,7 @@ edition.workspace = true anyhow = { workspace = true, optional = true } bumpalo = "3" capstone = { workspace = true, optional = true } -cranelift-codegen-shared = { path = "./shared", version = "0.99.0" } +cranelift-codegen-shared = { path = "./shared", version = "0.99.1" } cranelift-entity = { workspace = true } cranelift-bforest = { workspace = true } cranelift-control = { workspace = true } @@ -40,8 +40,8 @@ criterion = { version = "0.5.0", features = ["html_reports"] } similar = "2.1.0" [build-dependencies] -cranelift-codegen-meta = { path = "meta", version = "0.99.0" } -cranelift-isle = { path = "../isle/isle", version = "=0.99.0" } +cranelift-codegen-meta = { path = "meta", version = "0.99.1" } +cranelift-isle = { path = "../isle/isle", version = "=0.99.1" } [features] default = ["std", "unwind", "host-arch"] diff --git a/cranelift/codegen/meta/Cargo.toml b/cranelift/codegen/meta/Cargo.toml index 75303fa4d211..b016ace9c673 100644 --- a/cranelift/codegen/meta/Cargo.toml +++ b/cranelift/codegen/meta/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cranelift-codegen-meta" authors = ["The Cranelift Project Developers"] -version = "0.99.0" +version = "0.99.1" description = "Metaprogram for cranelift-codegen code generator library" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/bytecodealliance/wasmtime" @@ -12,4 +12,4 @@ edition.workspace = true rustdoc-args = [ "--document-private-items" ] [dependencies] -cranelift-codegen-shared = { path = "../shared", version = "0.99.0" } +cranelift-codegen-shared = { path = "../shared", version = "0.99.1" } diff --git a/cranelift/codegen/shared/Cargo.toml b/cranelift/codegen/shared/Cargo.toml index 6137d0d2f357..91abb99a7ca5 100644 --- a/cranelift/codegen/shared/Cargo.toml +++ b/cranelift/codegen/shared/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-codegen-shared" -version = "0.99.0" +version = "0.99.1" description = "For code shared between cranelift-codegen-meta and cranelift-codegen" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/control/Cargo.toml b/cranelift/control/Cargo.toml index 0cd32a45733e..38c62a43ac31 100644 --- a/cranelift/control/Cargo.toml +++ b/cranelift/control/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-control" -version = "0.99.0" +version = "0.99.1" description = "White-box fuzz testing framework" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/entity/Cargo.toml b/cranelift/entity/Cargo.toml index b1383a03d4c4..9cdf62d1eba8 100644 --- a/cranelift/entity/Cargo.toml +++ b/cranelift/entity/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-entity" -version = "0.99.0" +version = "0.99.1" description = "Data structures using entity references as mapping keys" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift-entity" diff --git a/cranelift/frontend/Cargo.toml b/cranelift/frontend/Cargo.toml index 68f29ec720c5..ebeef4b62c38 100644 --- a/cranelift/frontend/Cargo.toml +++ b/cranelift/frontend/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-frontend" -version = "0.99.0" +version = "0.99.1" description = "Cranelift IR builder helper" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift-frontend" diff --git a/cranelift/interpreter/Cargo.toml b/cranelift/interpreter/Cargo.toml index 9648a7ccbd2d..f1aebdf531f5 100644 --- a/cranelift/interpreter/Cargo.toml +++ b/cranelift/interpreter/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-interpreter" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Interpret Cranelift IR" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/isle/isle/Cargo.toml b/cranelift/isle/isle/Cargo.toml index dfd84f84dba2..4fd0cd4e8d50 100644 --- a/cranelift/isle/isle/Cargo.toml +++ b/cranelift/isle/isle/Cargo.toml @@ -6,7 +6,7 @@ license = "Apache-2.0 WITH LLVM-exception" name = "cranelift-isle" readme = "../README.md" repository = "https://github.com/bytecodealliance/wasmtime/tree/main/cranelift/isle" -version = "0.99.0" +version = "0.99.1" [dependencies] codespan-reporting = { version = "0.11.1", optional = true } diff --git a/cranelift/jit/Cargo.toml b/cranelift/jit/Cargo.toml index 73905f9089ed..64f0a8e78e2c 100644 --- a/cranelift/jit/Cargo.toml +++ b/cranelift/jit/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-jit" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "A JIT library backed by Cranelift" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/module/Cargo.toml b/cranelift/module/Cargo.toml index b5c850f3b2e9..0e814aff108b 100644 --- a/cranelift/module/Cargo.toml +++ b/cranelift/module/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-module" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Support for linking functions and data with Cranelift" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/native/Cargo.toml b/cranelift/native/Cargo.toml index e37e998ee344..ff97e6843b40 100644 --- a/cranelift/native/Cargo.toml +++ b/cranelift/native/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-native" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Support for targeting the host with Cranelift" documentation = "https://docs.rs/cranelift-native" diff --git a/cranelift/object/Cargo.toml b/cranelift/object/Cargo.toml index c576f310e282..fe2f8ce8472d 100644 --- a/cranelift/object/Cargo.toml +++ b/cranelift/object/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-object" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Emit Cranelift output to native object files with `object`" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/reader/Cargo.toml b/cranelift/reader/Cargo.toml index 3ec07ce9c962..c5c8801cf4b0 100644 --- a/cranelift/reader/Cargo.toml +++ b/cranelift/reader/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift-reader" -version = "0.99.0" +version = "0.99.1" description = "Cranelift textual IR reader" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift-reader" diff --git a/cranelift/serde/Cargo.toml b/cranelift/serde/Cargo.toml index 2846623ec770..b73fabcdbcc0 100644 --- a/cranelift/serde/Cargo.toml +++ b/cranelift/serde/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-serde" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Serializer/Deserializer for Cranelift IR" repository = "https://github.com/bytecodealliance/wasmtime" diff --git a/cranelift/umbrella/Cargo.toml b/cranelift/umbrella/Cargo.toml index 2fdd8afdec74..d7d5b0ab719b 100644 --- a/cranelift/umbrella/Cargo.toml +++ b/cranelift/umbrella/Cargo.toml @@ -1,7 +1,7 @@ [package] authors = ["The Cranelift Project Developers"] name = "cranelift" -version = "0.99.0" +version = "0.99.1" description = "Umbrella for commonly-used cranelift crates" license = "Apache-2.0 WITH LLVM-exception" documentation = "https://docs.rs/cranelift" diff --git a/cranelift/wasm/Cargo.toml b/cranelift/wasm/Cargo.toml index 4657744ab976..3218e02a568b 100644 --- a/cranelift/wasm/Cargo.toml +++ b/cranelift/wasm/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cranelift-wasm" -version = "0.99.0" +version = "0.99.1" authors = ["The Cranelift Project Developers"] description = "Translator from WebAssembly to Cranelift IR" documentation = "https://docs.rs/cranelift-wasm" diff --git a/crates/c-api/include/wasmtime.h b/crates/c-api/include/wasmtime.h index cd7cc353c3ff..12592b6aefe6 100644 --- a/crates/c-api/include/wasmtime.h +++ b/crates/c-api/include/wasmtime.h @@ -199,7 +199,7 @@ /** * \brief Wasmtime version string. */ -#define WASMTIME_VERSION "12.0.0" +#define WASMTIME_VERSION "12.0.1" /** * \brief Wasmtime major version number. */ @@ -211,7 +211,7 @@ /** * \brief Wasmtime patch version number. */ -#define WASMTIME_VERSION_PATCH 0 +#define WASMTIME_VERSION_PATCH 1 #ifdef __cplusplus extern "C" { diff --git a/supply-chain/imports.lock b/supply-chain/imports.lock index 14f8c6d384d6..9b8a4dc86c99 100644 --- a/supply-chain/imports.lock +++ b/supply-chain/imports.lock @@ -9,6 +9,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-bforest]] version = "0.98.0" audited_as = "0.97.1" @@ -17,6 +21,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-bforest]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-codegen]] version = "0.98.0" audited_as = "0.97.1" @@ -25,6 +33,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-codegen]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-codegen-meta]] version = "0.98.0" audited_as = "0.97.1" @@ -33,6 +45,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-codegen-meta]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-codegen-shared]] version = "0.98.0" audited_as = "0.97.1" @@ -41,6 +57,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-codegen-shared]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-control]] version = "0.98.0" audited_as = "0.97.1" @@ -49,6 +69,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-control]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-entity]] version = "0.98.0" audited_as = "0.97.1" @@ -57,6 +81,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-entity]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-frontend]] version = "0.98.0" audited_as = "0.97.1" @@ -65,6 +93,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-frontend]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-interpreter]] version = "0.98.0" audited_as = "0.97.1" @@ -73,6 +105,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-interpreter]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-isle]] version = "0.98.0" audited_as = "0.97.1" @@ -81,6 +117,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-isle]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-jit]] version = "0.98.0" audited_as = "0.97.1" @@ -89,6 +129,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-jit]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-module]] version = "0.98.0" audited_as = "0.97.1" @@ -97,6 +141,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-module]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-native]] version = "0.98.0" audited_as = "0.97.1" @@ -105,6 +153,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-native]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-object]] version = "0.98.0" audited_as = "0.97.1" @@ -113,6 +165,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-object]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-reader]] version = "0.98.0" audited_as = "0.97.1" @@ -121,6 +177,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-reader]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-serde]] version = "0.98.0" audited_as = "0.97.1" @@ -129,6 +189,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-serde]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.cranelift-wasm]] version = "0.98.0" audited_as = "0.97.1" @@ -137,6 +201,10 @@ audited_as = "0.97.1" version = "0.99.0" audited_as = "0.97.1" +[[unpublished.cranelift-wasm]] +version = "0.99.1" +audited_as = "0.99.0" + [[unpublished.wasi-cap-std-sync]] version = "11.0.0" audited_as = "10.0.1" @@ -145,6 +213,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasi-cap-std-sync]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasi-common]] version = "11.0.0" audited_as = "10.0.1" @@ -153,6 +225,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasi-common]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasi-tokio]] version = "11.0.0" audited_as = "10.0.1" @@ -161,6 +237,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasi-tokio]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime]] version = "11.0.0" audited_as = "10.0.1" @@ -169,6 +249,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-asm-macros]] version = "11.0.0" audited_as = "10.0.1" @@ -177,6 +261,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-asm-macros]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-cache]] version = "11.0.0" audited_as = "10.0.1" @@ -185,6 +273,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-cache]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-cli]] version = "11.0.0" audited_as = "10.0.1" @@ -193,6 +285,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-cli]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-cli-flags]] version = "11.0.0" audited_as = "10.0.1" @@ -201,6 +297,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-cli-flags]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-component-macro]] version = "11.0.0" audited_as = "10.0.1" @@ -209,6 +309,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-component-macro]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-component-util]] version = "11.0.0" audited_as = "10.0.1" @@ -217,6 +321,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-component-util]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-cranelift]] version = "11.0.0" audited_as = "10.0.1" @@ -225,6 +333,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-cranelift]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-cranelift-shared]] version = "11.0.0" audited_as = "10.0.1" @@ -233,6 +345,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-cranelift-shared]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-environ]] version = "11.0.0" audited_as = "10.0.1" @@ -241,6 +357,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-environ]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-explorer]] version = "11.0.0" audited_as = "10.0.1" @@ -249,6 +369,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-explorer]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-fiber]] version = "11.0.0" audited_as = "10.0.1" @@ -257,6 +381,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-fiber]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-jit]] version = "11.0.0" audited_as = "10.0.1" @@ -265,6 +393,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-jit]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-jit-debug]] version = "11.0.0" audited_as = "10.0.1" @@ -273,6 +405,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-jit-debug]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-jit-icache-coherence]] version = "11.0.0" audited_as = "10.0.1" @@ -281,6 +417,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-jit-icache-coherence]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-runtime]] version = "11.0.0" audited_as = "10.0.1" @@ -289,6 +429,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-runtime]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-types]] version = "11.0.0" audited_as = "10.0.1" @@ -297,6 +441,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-types]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wasi]] version = "11.0.0" audited_as = "10.0.1" @@ -305,6 +453,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wasi]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wasi-crypto]] version = "11.0.0" audited_as = "10.0.1" @@ -313,6 +465,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wasi-crypto]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wasi-http]] version = "11.0.0" audited_as = "10.0.1" @@ -321,6 +477,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wasi-http]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wasi-nn]] version = "11.0.0" audited_as = "10.0.1" @@ -329,6 +489,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wasi-nn]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wasi-threads]] version = "11.0.0" audited_as = "10.0.1" @@ -337,6 +501,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wasi-threads]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wast]] version = "11.0.0" audited_as = "10.0.1" @@ -345,6 +513,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wast]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-winch]] version = "11.0.0" audited_as = "10.0.1" @@ -353,6 +525,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-winch]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wasmtime-wit-bindgen]] version = "11.0.0" audited_as = "10.0.1" @@ -361,6 +537,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wasmtime-wit-bindgen]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wiggle]] version = "11.0.0" audited_as = "10.0.1" @@ -369,6 +549,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wiggle]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wiggle-generate]] version = "11.0.0" audited_as = "10.0.1" @@ -377,6 +561,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wiggle-generate]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wiggle-macro]] version = "11.0.0" audited_as = "10.0.1" @@ -385,6 +573,10 @@ audited_as = "10.0.1" version = "12.0.0" audited_as = "10.0.1" +[[unpublished.wiggle-macro]] +version = "12.0.1" +audited_as = "12.0.0" + [[unpublished.wiggle-test]] version = "0.0.0" audited_as = "0.1.0" @@ -397,6 +589,10 @@ audited_as = "0.8.1" version = "0.10.0" audited_as = "0.8.1" +[[unpublished.winch-codegen]] +version = "0.10.1" +audited_as = "0.10.0" + [[publisher.aho-corasick]] version = "1.0.2" when = "2023-06-04" @@ -585,102 +781,204 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-bforest]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-bforest]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-codegen]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-codegen]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-codegen-meta]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-codegen-meta]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-codegen-shared]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-codegen-shared]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-control]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-control]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-entity]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-entity]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-frontend]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-frontend]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-interpreter]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-interpreter]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-isle]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-isle]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-jit]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-jit]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-module]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-module]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-native]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-native]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-object]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-object]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-reader]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-reader]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-serde]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-serde]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.cranelift-wasm]] version = "0.97.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.cranelift-wasm]] +version = "0.99.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.derive_arbitrary]] version = "1.3.0" when = "2023-03-13" @@ -1064,12 +1362,24 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasi-cap-std-sync]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasi-common]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasi-common]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasi-tokio]] version = "10.0.1" when = "2023-06-21" @@ -1285,18 +1595,36 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-asm-macros]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-asm-macros]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-cache]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-cache]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-cli]] version = "10.0.1" when = "2023-06-21" @@ -1315,30 +1643,60 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-component-macro]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-component-util]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-component-util]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-cranelift]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-cranelift]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-cranelift-shared]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-cranelift-shared]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-environ]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-environ]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-explorer]] version = "10.0.1" when = "2023-06-21" @@ -1351,36 +1709,72 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-fiber]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-jit]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-jit]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-jit-debug]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-jit-debug]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-jit-icache-coherence]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-jit-icache-coherence]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-runtime]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-runtime]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-types]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-types]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-wasi]] version = "10.0.1" when = "2023-06-21" @@ -1405,6 +1799,12 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-wasi-nn]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-wasi-threads]] version = "10.0.1" when = "2023-06-21" @@ -1423,12 +1823,24 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-winch]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wasmtime-wit-bindgen]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wasmtime-wit-bindgen]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wast]] version = "60.0.0" when = "2023-05-26" @@ -1491,18 +1903,36 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wiggle]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wiggle-generate]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wiggle-generate]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wiggle-macro]] version = "10.0.1" when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.wiggle-macro]] +version = "12.0.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.wiggle-test]] version = "0.1.0" when = "2020-03-12" @@ -1523,6 +1953,12 @@ when = "2023-06-21" user-id = 73222 user-login = "wasmtime-publish" +[[publisher.winch-codegen]] +version = "0.10.0" +when = "2023-08-21" +user-id = 73222 +user-login = "wasmtime-publish" + [[publisher.windows-sys]] version = "0.45.0" when = "2023-01-21" diff --git a/winch/codegen/Cargo.toml b/winch/codegen/Cargo.toml index e9aa457acbde..4405ec91e12f 100644 --- a/winch/codegen/Cargo.toml +++ b/winch/codegen/Cargo.toml @@ -4,7 +4,7 @@ name = "winch-codegen" description = "Winch code generation library" license = "Apache-2.0 WITH LLVM-exception" repository = "https://github.com/bytecodealliance/wasmtime" -version = "0.10.0" +version = "0.10.1" edition.workspace = true [dependencies] From 0b024afa8267d2680bbd4aa21924d4318f651441 Mon Sep 17 00:00:00 2001 From: veeshi <31014797+veeshi@users.noreply.github.com> Date: Sat, 5 Aug 2023 00:51:49 +0100 Subject: [PATCH 5/5] add http-acl to wasi-http --- Cargo.lock | 39 +++++--- crates/test-programs/tests/wasi-http.rs | 30 +++++- .../src/bin/outbound_request.rs | 30 ++++++ crates/wasi-http/Cargo.toml | 1 + crates/wasi-http/src/http_impl.rs | 91 +++++++++++++++---- crates/wasi-http/src/lib.rs | 1 + crates/wasi-http/src/struct.rs | 53 +++++++++++ 7 files changed, 209 insertions(+), 36 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 378d8961ca1f..73a7034939bc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1410,9 +1410,9 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "form_urlencoded" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +checksum = "a62bc1cf6f830c2ec14a513a9fb124d0a213a629668a4186f329db21fe045652" dependencies = [ "percent-encoding", ] @@ -1701,6 +1701,16 @@ dependencies = [ "itoa", ] +[[package]] +name = "http-acl" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4f9211910745aa685e723b8c160eb682a60a8b9b9ee07842640ddcd7aa0e348d" +dependencies = [ + "ipnet", + "url", +] + [[package]] name = "http-body" version = "1.0.0-rc.2" @@ -1781,9 +1791,9 @@ checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" [[package]] name = "idna" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +checksum = "7d20d6b07bfbc108882d88ed8e37d39636dcc260e15e30c45e6ba089610b917c" dependencies = [ "unicode-bidi", "unicode-normalization", @@ -1866,9 +1876,9 @@ checksum = "bffb4def18c48926ccac55c1223e02865ce1a821751a95920448662696e7472c" [[package]] name = "ipnet" -version = "2.5.0" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" +checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" [[package]] name = "is-terminal" @@ -2344,9 +2354,9 @@ dependencies = [ [[package]] name = "percent-encoding" -version = "2.2.0" +version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" +checksum = "9b2a4787296e9989611394c33f193f676704af1686e70b8f8033ab5ba9a35a94" [[package]] name = "pin-project-lite" @@ -3464,9 +3474,9 @@ dependencies = [ [[package]] name = "unicode-bidi" -version = "0.3.8" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" [[package]] name = "unicode-ident" @@ -3476,9 +3486,9 @@ checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" [[package]] name = "unicode-normalization" -version = "0.1.21" +version = "0.1.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" dependencies = [ "tinyvec", ] @@ -3519,9 +3529,9 @@ checksum = "a156c684c91ea7d62626509bce3cb4e1d9ed5c4d978f7b4352658f96a4c26b4a" [[package]] name = "url" -version = "2.3.1" +version = "2.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +checksum = "50bff7831e19200a85b17131d085c25d7811bc4e186efdaf54bbd132994a88cb" dependencies = [ "form_urlencoded", "idna", @@ -4427,6 +4437,7 @@ dependencies = [ "anyhow", "bytes", "http", + "http-acl", "http-body", "http-body-util", "hyper", diff --git a/crates/test-programs/tests/wasi-http.rs b/crates/test-programs/tests/wasi-http.rs index 0b1a4fd70567..0a0918458e50 100644 --- a/crates/test-programs/tests/wasi-http.rs +++ b/crates/test-programs/tests/wasi-http.rs @@ -1,13 +1,19 @@ #![cfg(all(feature = "test_programs", not(skip_wasi_http_tests)))] use wasmtime::{Config, Engine, Linker, Store}; use wasmtime_wasi::{sync::WasiCtxBuilder, WasiCtx}; -use wasmtime_wasi_http::WasiHttp; +use wasmtime_wasi_http::{ + http_acl::{acl::HttpRequestMethod, HttpAcl}, + WasiHttp, +}; use http_body_util::combinators::BoxBody; use http_body_util::BodyExt; use hyper::server::conn::http1; use hyper::{body::Bytes, service::service_fn, Request, Response}; -use std::{error::Error, net::SocketAddr}; +use std::{ + error::Error, + net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr}, +}; use tokio::net::TcpListener; lazy_static::lazy_static! { @@ -77,12 +83,30 @@ pub fn run(name: &str) -> anyhow::Result<()> { // Create our wasi context. let builder = WasiCtxBuilder::new().inherit_stdio().arg(name)?; + let acl = HttpAcl::builder() + .clear_allowed_methods() + .add_allowed_method(HttpRequestMethod::GET) + .unwrap() + .add_allowed_method(HttpRequestMethod::POST) + .unwrap() + .add_allowed_method(HttpRequestMethod::PUT) + .unwrap() + .add_allowed_host("localhost".to_string()) + .unwrap() + .add_allowed_port_range(3000..=3000) + .unwrap() + .add_allowed_ip_range(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)).into()) + .unwrap() + .add_allowed_ip_range(IpAddr::V6(Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1)).into()) + .unwrap() + .build(); + let wasi_http = WasiHttp::new_with_acl(acl); let mut store = Store::new( &ENGINE, Ctx { wasi: builder.build(), - http: WasiHttp::new(), + http: wasi_http, }, ); diff --git a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs index 7987c0dada23..f7206d32b229 100644 --- a/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs +++ b/crates/test-programs/wasi-http-tests/src/bin/outbound_request.rs @@ -184,5 +184,35 @@ fn main() -> Result<()> { "Error::UnexpectedError(\"unsupported scheme WS\")" ); + // DELETE is not an allowed method in this test. + let r6 = request( + wasi::http::types::Method::Delete, + wasi::http::types::Scheme::Http, + "localhost:3000", + "/", + &[], + ); + + let error = r6.unwrap_err(); + assert_eq!( + error.to_string(), + "Error::UnexpectedError(\"Method DELETE is not allowed - The entity is denied because the default is to deny if no ACL match is found.\")" + ); + + // 8080 is not an allowed port in this test. + let r7 = request( + wasi::http::types::Method::Get, + wasi::http::types::Scheme::Http, + "localhost:8080", + "/", + &[], + ); + + let error = r7.unwrap_err(); + assert_eq!( + error.to_string(), + "Error::UnexpectedError(\"Port 8080 is not allowed - The entity is denied because the default is to deny if no ACL match is found.\")" + ); + Ok(()) } diff --git a/crates/wasi-http/Cargo.toml b/crates/wasi-http/Cargo.toml index a99f9a32e491..3345c5e00cd4 100644 --- a/crates/wasi-http/Cargo.toml +++ b/crates/wasi-http/Cargo.toml @@ -13,6 +13,7 @@ bytes = { workspace = true } hyper = { version = "=1.0.0-rc.3", features = ["full"] } tokio = { version = "1", default-features = false, features = ["net", "rt-multi-thread", "time"] } http = { version = "0.2.9" } +http-acl = "0.5.0" http-body = "1.0.0-rc.2" http-body-util = "0.1.0-rc.2" thiserror = { workspace = true } diff --git a/crates/wasi-http/src/http_impl.rs b/crates/wasi-http/src/http_impl.rs index 239e54a68771..3fb3176ed2ff 100644 --- a/crates/wasi-http/src/http_impl.rs +++ b/crates/wasi-http/src/http_impl.rs @@ -9,6 +9,7 @@ use http_body_util::{BodyExt, Full}; use hyper::Method; use hyper::Request; use std::collections::HashMap; +use std::net::SocketAddr; #[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] use std::sync::Arc; use std::time::Duration; @@ -31,15 +32,15 @@ impl crate::wasi::http::outgoing_handler::Host for WasiHttp { } } -fn port_for_scheme(scheme: &Option) -> &str { +fn port_for_scheme(scheme: &Option) -> u16 { match scheme { Some(s) => match s { - Scheme::Http => ":80", - Scheme::Https => ":443", + Scheme::Http => 80, + Scheme::Https => 443, // This should never happen. _ => panic!("unsupported scheme!"), }, - None => ":443", + None => 443, } } @@ -82,21 +83,74 @@ impl WasiHttp { crate::wasi::http::types::Method::Other(s) => bail!("unknown method {}", s), }; + let acl_method_match = self.acl.is_method_allowed(method.as_str()); + if acl_method_match.is_denied() { + bail!( + "Method {} is not allowed - {}", + method.as_str(), + acl_method_match + ); + } + let scheme = match request.scheme.as_ref().unwrap_or(&Scheme::Https) { - Scheme::Http => "http://", - Scheme::Https => "https://", + Scheme::Http => "http", + Scheme::Https => "https", Scheme::Other(s) => bail!("unsupported scheme {}", s), }; - // Largely adapted from https://hyper.rs/guides/1/client/basic/ - let authority = match request.authority.find(":") { - Some(_) => request.authority.clone(), - None => request.authority.clone() + port_for_scheme(&request.scheme), + let acl_scheme_match = self.acl.is_scheme_allowed(scheme); + if acl_scheme_match.is_denied() { + bail!("Scheme {} is not allowed - {}", scheme, acl_scheme_match); + } + + let authority = match http_acl::utils::authority::Authority::parse(&request.authority) { + Ok(a) => a, + Err(e) => bail!("invalid authority: {}", e), + }; + + let port = if authority.port == 0 { + port_for_scheme(&request.scheme) + } else { + authority.port + }; + let acl_port_match = self.acl.is_port_allowed(port); + if acl_port_match.is_denied() { + bail!("Port {} is not allowed - {}", port, acl_port_match); + } + + let tcp_addresses = match &authority.host { + http_acl::utils::authority::Host::Domain(domain) => { + let acl_host_match = self.acl.is_host_allowed(domain); + if acl_host_match.is_denied() { + bail!("Host {} is not allowed - {}", domain, acl_host_match); + } + + tokio::net::lookup_host(&(domain.clone() + ":" + &port.to_string())) + .await? + .collect::>() + } + http_acl::utils::authority::Host::Ip(ip) => { + let acl_ip_match = self.acl.is_ip_allowed(ip); + if acl_ip_match.is_denied() { + bail!("IP {} is not allowed - {}", ip, acl_ip_match); + } + + vec![SocketAddr::new(*ip, port)] + } }; - let mut sender = if scheme == "https://" { + + for tcp_address in &tcp_addresses { + let acl_ip_match = self.acl.is_ip_allowed(&tcp_address.ip()); + if acl_ip_match.is_denied() { + bail!("IP {} is not allowed - {}", tcp_address.ip(), acl_ip_match); + } + } + + // Largely adapted from https://hyper.rs/guides/1/client/basic/ + let mut sender = if scheme == "https" { #[cfg(not(any(target_arch = "riscv64", target_arch = "s390x")))] { - let stream = TcpStream::connect(authority.clone()).await?; + let stream = TcpStream::connect(tcp_addresses.as_slice()).await?; //TODO: uncomment this code and make the tls implementation a feature decision. //let connector = tokio_native_tls::native_tls::TlsConnector::builder().build()?; //let connector = tokio_native_tls::TlsConnector::from(connector); @@ -119,11 +173,10 @@ impl WasiHttp { .with_root_certificates(root_cert_store) .with_no_client_auth(); let connector = tokio_rustls::TlsConnector::from(Arc::new(config)); - let mut parts = authority.split(":"); - let host = parts.next().unwrap_or(&authority); - let domain = - rustls::ServerName::try_from(host).map_err(|_| anyhow!("invalid dnsname"))?; - let stream = connector.connect(domain, stream).await?; + let authority_string = authority.host.to_string(); + let server_name = rustls::ServerName::try_from(authority_string.as_str()) + .map_err(|_| anyhow!("invalid dnsname"))?; + let stream = connector.connect(server_name, stream).await?; let t = timeout( connect_timeout, @@ -141,7 +194,7 @@ impl WasiHttp { #[cfg(any(target_arch = "riscv64", target_arch = "s390x"))] bail!("unsupported architecture for SSL") } else { - let tcp = TcpStream::connect(authority).await?; + let tcp = TcpStream::connect(tcp_addresses.as_slice()).await?; let t = timeout(connect_timeout, hyper::client::conn::http1::handshake(tcp)).await?; let (s, conn) = t?; tokio::task::spawn(async move { @@ -152,7 +205,7 @@ impl WasiHttp { s }; - let url = scheme.to_owned() + &request.authority + &request.path_with_query; + let url = scheme.to_owned() + "://" + &request.authority + &request.path_with_query; let mut call = Request::builder() .method(method) diff --git a/crates/wasi-http/src/lib.rs b/crates/wasi-http/src/lib.rs index ce5211ef8c17..f158e037fe10 100644 --- a/crates/wasi-http/src/lib.rs +++ b/crates/wasi-http/src/lib.rs @@ -1,5 +1,6 @@ use crate::component_impl::add_component_to_linker; pub use crate::r#struct::WasiHttp; +pub use http_acl; wasmtime::component::bindgen!({ path: "wasi-http/wit", world: "proxy"}); diff --git a/crates/wasi-http/src/struct.rs b/crates/wasi-http/src/struct.rs index d73fd7c6d562..cca6383f7baa 100644 --- a/crates/wasi-http/src/struct.rs +++ b/crates/wasi-http/src/struct.rs @@ -1,6 +1,37 @@ use crate::wasi::http::types::{Method, RequestOptions, Scheme}; use bytes::{BufMut, Bytes, BytesMut}; +use http_acl::HttpAcl; use std::collections::HashMap; +use std::fmt; + +impl fmt::Display for Scheme { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let scheme_str = match self { + Scheme::Http => "http", + Scheme::Https => "https", + Scheme::Other(s) => s, + }; + write!(f, "{}", scheme_str) + } +} + +impl fmt::Display for Method { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + let method_str = match self { + Method::Get => "GET", + Method::Put => "PUT", + Method::Post => "POST", + Method::Options => "OPTIONS", + Method::Head => "HEAD", + Method::Patch => "PATCH", + Method::Connect => "CONNECT", + Method::Delete => "DELETE", + Method::Trace => "TRACE", + Method::Other(s) => s, + }; + write!(f, "{}", method_str) + } +} #[derive(Clone, Default)] pub struct Stream { @@ -20,6 +51,7 @@ pub struct WasiHttp { pub fields: HashMap>>>, pub streams: HashMap, pub futures: HashMap, + pub acl: HttpAcl, } #[derive(Clone)] @@ -119,6 +151,27 @@ impl WasiHttp { fields: HashMap::new(), streams: HashMap::new(), futures: HashMap::new(), + acl: HttpAcl::builder() + .host_acl_default(true) + .port_acl_default(true) + .ip_acl_default(true) + .build(), + } + } + + pub fn new_with_acl(acl: HttpAcl) -> Self { + Self { + request_id_base: 1, + response_id_base: 1, + fields_id_base: 1, + streams_id_base: 1, + future_id_base: 1, + requests: HashMap::new(), + responses: HashMap::new(), + fields: HashMap::new(), + streams: HashMap::new(), + futures: HashMap::new(), + acl, } } }