Skip to content

Merge origin/main into resources branch #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ serde_json = { workspace = true }
wasmparser = { workspace = true }
wasm-encoder = { workspace = true }

async-trait = { workspace = true }
tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] }
hyper = { workspace = true, optional = true }
http-body = { workspace = true }
http-body-util = { workspace = true }

[target.'cfg(unix)'.dependencies]
rustix = { workspace = true, features = ["mm", "param"] }

Expand All @@ -60,7 +66,7 @@ filecheck = { workspace = true }
tempfile = { workspace = true }
test-programs = { path = "crates/test-programs" }
wasmtime-runtime = { workspace = true }
tokio = { version = "1.8.0", features = ["rt", "time", "macros", "rt-multi-thread"] }
tokio = { workspace = true, features = ["rt", "time", "macros", "rt-multi-thread"] }
wast = { workspace = true }
criterion = "0.5.0"
num_cpus = "1.13.0"
Expand Down Expand Up @@ -101,6 +107,7 @@ members = [
"crates/jit-icache-coherence",
"crates/test-programs/wasi-tests",
"crates/test-programs/wasi-http-tests",
"crates/test-programs/wasi-http-proxy-tests",
"crates/test-programs/wasi-sockets-tests",
"crates/test-programs/command-tests",
"crates/test-programs/reactor-tests",
Expand Down Expand Up @@ -251,7 +258,11 @@ tempfile = "3.1.0"
filecheck = "0.5.0"
libc = "0.2.60"
file-per-thread-logger = "0.2.0"
tokio = { version = "1.26.0" }
tokio = { version = "1.26.0", features = [ "rt", "time" ] }
hyper = "=1.0.0-rc.3"
http = "0.2.9"
http-body = "=1.0.0-rc.2"
http-body-util = "=0.1.0-rc.2"
bytes = "1.4"
futures = { version = "0.3.27", default-features = false }
indexmap = "2.0.0"
Expand All @@ -275,7 +286,7 @@ jitdump = ["wasmtime/jitdump"]
vtune = ["wasmtime/vtune"]
wasi-nn = ["dep:wasmtime-wasi-nn"]
wasi-threads = ["dep:wasmtime-wasi-threads"]
wasi-http = ["dep:wasmtime-wasi-http", "wasmtime-wasi-http?/sync"]
wasi-http = ["component-model", "dep:wasmtime-wasi-http", "dep:tokio", "dep:hyper", "wasmtime-wasi-http?/sync"]
pooling-allocator = ["wasmtime/pooling-allocator", "wasmtime-cli-flags/pooling-allocator"]
all-arch = ["wasmtime/all-arch"]
component-model = [
Expand All @@ -286,6 +297,9 @@ component-model = [
winch = ["wasmtime/winch"]
wmemcheck = ["wasmtime/wmemcheck"]

# Enable the `wasmtime serve` command
serve = ["wasi-http", "component-model"]

[[test]]
name = "host_segfault"
harness = false
Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ publish = false

[lib]
name = "wasmtime"
crate-type = ["staticlib", "cdylib"]
crate-type = ["staticlib", "cdylib", "rlib"]
doc = false
test = false
doctest = false
Expand Down
2 changes: 1 addition & 1 deletion crates/c-api/include/wasmtime/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ WASM_API_EXTERN wasmtime_error_t *wasmtime_module_deserialize_file(
* For more details see: https://docs.wasmtime.dev/api/wasmtime/struct.Module.html#method.image_range
*/
WASM_API_EXTERN void wasmtime_module_image_range(
const wasm_module_t *module,
const wasmtime_module_t *module,
size_t *start,
size_t *end
);
Expand Down
2 changes: 2 additions & 0 deletions crates/c-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]

pub use wasmtime::*;

mod config;
mod engine;
mod error;
Expand Down
1 change: 0 additions & 1 deletion crates/environ/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ wasmprinter = { workspace = true, optional = true }
wasmtime-component-util = { workspace = true, optional = true }

[dev-dependencies]
atty = "0.2.14"
clap = { workspace = true }
env_logger = { workspace = true }
wat = { workspace = true }
Expand Down
4 changes: 2 additions & 2 deletions crates/environ/examples/factc.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::{bail, Context, Result};
use clap::Parser;
use std::io::Write;
use std::io::{IsTerminal, Write};
use std::path::PathBuf;
use wasmparser::{Validator, WasmFeatures};
use wasmtime_environ::component::*;
Expand Down Expand Up @@ -179,7 +179,7 @@ impl Factc {
wasmprinter::print_bytes(&wasm)
.context("failed to convert binary wasm to text")?
.into_bytes()
} else if self.output.is_none() && atty::is(atty::Stream::Stdout) {
} else if self.output.is_none() && std::io::stdout().is_terminal() {
bail!("cannot print binary wasm output to a terminal unless `-t` flag is passed")
} else {
wasm.clone()
Expand Down
2 changes: 1 addition & 1 deletion crates/test-programs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ heck = { workspace = true }

[dependencies]
anyhow = { workspace = true }
bytes = { workspace = true }
http = { version = "0.2.9" }
http-body = "1.0.0-rc.2"
http-body-util = "0.1.0-rc.2"
hyper = { version = "1.0.0-rc.3", features = ["full"] }
is-terminal = { workspace = true }
tokio = { workspace = true, features = ["net", "rt-multi-thread", "macros"] }
tracing = { workspace = true }

Expand Down
10 changes: 9 additions & 1 deletion crates/test-programs/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fn build_and_generate_tests() {
println!("cargo:rerun-if-changed=./wasi-sockets-tests");
if BUILD_WASI_HTTP_TESTS {
println!("cargo:rerun-if-changed=./wasi-http-tests");
println!("cargo:rerun-if-changed=./wasi-http-proxy-tests");
} else {
println!("cargo:rustc-cfg=skip_wasi_http_tests");
}
Expand All @@ -50,6 +51,7 @@ fn build_and_generate_tests() {
.env_remove("CARGO_ENCODED_RUSTFLAGS");
if BUILD_WASI_HTTP_TESTS {
cmd.arg("--package=wasi-http-tests");
cmd.arg("--package=wasi-http-proxy-tests");
}
let status = cmd.status().unwrap();
assert!(status.success());
Expand All @@ -60,8 +62,14 @@ fn build_and_generate_tests() {
components_rs(&meta, "wasi-tests", "bin", &command_adapter, &out_dir);

if BUILD_WASI_HTTP_TESTS {
modules_rs(&meta, "wasi-http-tests", "bin", &out_dir);
components_rs(&meta, "wasi-http-tests", "bin", &command_adapter, &out_dir);
components_rs(
&meta,
"wasi-http-proxy-tests",
"cdylib",
&reactor_adapter,
&out_dir,
);
}

components_rs(&meta, "command-tests", "bin", &command_adapter, &out_dir);
Expand Down
8 changes: 4 additions & 4 deletions crates/test-programs/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
///! This crate exists to build crates for wasm32-wasi in build.rs, and execute
///! these wasm programs in harnesses defined under tests/.
use std::io::IsTerminal;

#[cfg(all(feature = "test_programs", not(skip_wasi_http_tests)))]
pub mod http_server;
Expand Down Expand Up @@ -40,8 +41,7 @@ pub fn wasi_tests_environment() -> &'static [(&'static str, &'static str)] {
}

pub fn stdio_is_terminal() -> bool {
use is_terminal::is_terminal;
is_terminal(&std::io::stdin())
&& is_terminal(&std::io::stdout())
&& is_terminal(&std::io::stderr())
std::io::stdin().is_terminal()
&& std::io::stdout().is_terminal()
&& std::io::stderr().is_terminal()
}
7 changes: 2 additions & 5 deletions crates/test-programs/tests/wasi-http-components-sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use wasmtime::{
Config, Engine, Store,
};
use wasmtime_wasi::preview2::{
command::sync::{add_to_linker, Command},
pipe::MemoryOutputPipe,
Table, WasiCtx, WasiCtxBuilder, WasiView,
command::sync::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
};
use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};

Expand Down Expand Up @@ -60,8 +58,7 @@ fn instantiate_component(
ctx: Ctx,
) -> Result<(Store<Ctx>, Command), anyhow::Error> {
let mut linker = Linker::new(&ENGINE);
add_to_linker(&mut linker)?;
wasmtime_wasi_http::proxy::add_to_linker(&mut linker)?;
wasmtime_wasi_http::proxy::sync::add_to_linker(&mut linker)?;

let mut store = Store::new(&ENGINE, ctx);

Expand Down
5 changes: 1 addition & 4 deletions crates/test-programs/tests/wasi-http-components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use wasmtime::{
Config, Engine, Store,
};
use wasmtime_wasi::preview2::{
command::{add_to_linker, Command},
pipe::MemoryOutputPipe,
Table, WasiCtx, WasiCtxBuilder, WasiView,
command::Command, pipe::MemoryOutputPipe, Table, WasiCtx, WasiCtxBuilder, WasiView,
};
use wasmtime_wasi_http::{WasiHttpCtx, WasiHttpView};

Expand Down Expand Up @@ -60,7 +58,6 @@ async fn instantiate_component(
ctx: Ctx,
) -> Result<(Store<Ctx>, Command), anyhow::Error> {
let mut linker = Linker::new(&ENGINE);
add_to_linker(&mut linker)?;
wasmtime_wasi_http::proxy::add_to_linker(&mut linker)?;

let mut store = Store::new(&ENGINE, ctx);
Expand Down
Loading