Skip to content

Commit

Permalink
Update deps (#108)
Browse files Browse the repository at this point in the history
* Update deps

Highlights are that all wasm-tools packages and wasmtime are at their latest versions.

* Update to upstream wasm-convert

* update wasmtime for security release

* Update to wit-bindgen v0.19

* update to wit-bindgen 0.34.0

Signed-off-by: Joel Dice <joel.dice@fermyon.com>

* Update to upstream component-init

---------

Signed-off-by: Joel Dice <joel.dice@fermyon.com>
Co-authored-by: Joel Dice <joel.dice@fermyon.com>
  • Loading branch information
benbrandt and dicej authored Oct 16, 2024
1 parent 5aa9438 commit f19009e
Show file tree
Hide file tree
Showing 14 changed files with 463 additions and 501 deletions.
714 changes: 329 additions & 385 deletions Cargo.lock

Large diffs are not rendered by default.

43 changes: 21 additions & 22 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,52 +9,51 @@ name = "componentize_py"
crate-type = ["cdylib", "rlib"]

[dependencies]
anyhow = { version = "1.0.86", features = ["backtrace"] }
clap = { version = "4.5.17", features = ["derive"] }
tar = "0.4.41"
tempfile = "3.12.0"
anyhow = { version = "1.0.89", features = ["backtrace"] }
clap = { version = "4.5.20", features = ["derive"] }
tar = "0.4.42"
tempfile = "3.13.0"
zstd = "0.13.2"
componentize-py-shared = { path = "shared" }
wasm-encoder = "0.216.0"
wit-parser = "0.216.0"
wit-component = "0.216.0"
wasmparser = "0.216.0"
indexmap = "2.5.0"
wasm-encoder = "0.219.0"
wit-parser = "0.219.0"
wit-component = "0.219.0"
wasmparser = "0.219.0"
indexmap = "2.6.0"
bincode = "1.3.3"
heck = "0.5.0"
pyo3 = { version = "0.20.0", features = [
"abi3-py37",
"extension-module",
], optional = true }
wasmtime = "24.0.0"
wasmtime-wasi = "24.0.0"
wasi-common = "24.0.0"
once_cell = "1.19.0"
component-init = { git = "https://github.com/dicej/component-init", rev = "bc276826" }
wasm-convert = { git = "https://github.com/dicej/wasm-convert", rev = "afbec48b" }
async-trait = "0.1.82"
futures = "0.3.30"
wasmtime = "25.0.2"
wasmtime-wasi = "25.0.2"
wasi-common = "25.0.2"
once_cell = "1.20.2"
component-init = { git = "https://github.com/dicej/component-init", rev = "6964d14" }
wasm-convert = { git = "https://github.com/dicej/wasm-convert", rev = "a42b419" }
async-trait = "0.1.83"
futures = "0.3.31"
tokio = { version = "1.40.0", features = [
"macros",
"rt",
"rt-multi-thread",
"fs",
] }
bytes = "1.7.1"
bytes = "1.7.2"
pretty_env_logger = "0.5.0"
cap-std = "3.2.0"
cap-std = "3.3.0"
im-rc = "15.1.0"
serde = { version = "1.0.209", features = ["derive"] }
serde = { version = "1.0.210", features = ["derive"] }
toml = "0.8.19"
semver = "1.0.23"

[dev-dependencies]
async-trait = "0.1.82"
proptest = "1.5.0"
hex = "0.4.3"

[build-dependencies]
anyhow = "1.0.86"
anyhow = "1.0.89"
tar = "0.4.41"
zstd = "0.13.2"
test-generator = { path = "test-generator" }
Expand Down
6 changes: 3 additions & 3 deletions runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ edition = "2021"
crate-type = ["staticlib"]

[dependencies]
anyhow = "1.0.86"
once_cell = "1.19.0"
anyhow = "1.0.89"
once_cell = "1.20.2"
pyo3 = { version = "0.20.0", features = ["abi3-py311", "num-bigint"] }
componentize-py-shared = { path = "../shared" }
num-bigint = "0.4.6"
wit-bindgen = "0.16.0"
wit-bindgen = "0.34.0"
24 changes: 21 additions & 3 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ use {
wit_bindgen::generate!({
world: "init",
path: "../wit",
exports: {
"exports": MyExports
}
generate_all,
});

export!(MyExports);

static STUB_WASI: OnceCell<bool> = OnceCell::new();
static EXPORTS: OnceCell<Vec<Export>> = OnceCell::new();
static TYPES: OnceCell<Vec<Type>> = OnceCell::new();
Expand Down Expand Up @@ -1281,3 +1281,21 @@ pub mod dl {
static _CLOCK_PROCESS_CPUTIME_ID: u8 = 2;
#[no_mangle]
static _CLOCK_THREAD_CPUTIME_ID: u8 = 3;

// Traditionally, `wit-bindgen` would provide a `cabi_realloc` implementation, but recent versions use a weak
// symbol trick to avoid conflicts when more than one `wit-bindgen` version is used, and that trick does not
// currently play nice with how we build this library. So for now, we just define it ourselves here:
/// # Safety
/// TODO
#[export_name = "cabi_realloc"]
pub unsafe extern "C" fn cabi_realloc(
old_ptr: *mut u8,
old_len: usize,
align: usize,
new_size: usize,
) -> *mut u8 {
assert!(old_ptr.is_null());
assert!(old_len == 0);

alloc::alloc(Layout::from_size_align(new_size, align).unwrap())
}
21 changes: 14 additions & 7 deletions src/bindings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ pub fn make_bindings(

for (name, params, results) in IMPORT_SIGNATURES {
let offset = types.len();
types.function(params.iter().copied(), results.iter().copied());
types
.ty()
.function(params.iter().copied(), results.iter().copied());
imports.import("env", name, EntityType::Function(offset));
function_names.push((offset, (*name).to_owned()));
}
Expand Down Expand Up @@ -95,7 +97,7 @@ pub fn make_bindings(
let (params, results) = function.core_import_type(resolve);
let offset = types.len();

types.function(params, results);
types.ty().function(params, results);
imports.import(module, name, EntityType::Function(offset));
function_names.push((
offset,
Expand Down Expand Up @@ -176,7 +178,7 @@ pub fn make_bindings(
for (index, function) in summary.functions.iter().enumerate() {
let offset = types.len();
let (params, results) = function.core_export_type(resolve);
types.function(params, results);
types.ty().function(params, results);
functions.function(offset);
function_names.push((offset, function.internal_name(resolve)));
let mut gen = FunctionBindgen::new(summary, function, stack_pointer);
Expand Down Expand Up @@ -259,9 +261,13 @@ pub fn make_bindings(

{
let dispatch_offset = types.len();
types.function([ValType::I32; DISPATCH_CORE_PARAM_COUNT], []);
types
.ty()
.function([ValType::I32; DISPATCH_CORE_PARAM_COUNT], []);
let dispatchable_offset = types.len();
types.function([ValType::I32; DISPATCHABLE_CORE_PARAM_COUNT], []);
types
.ty()
.function([ValType::I32; DISPATCHABLE_CORE_PARAM_COUNT], []);
functions.function(dispatch_offset);
let name = "componentize-py#CallIndirect";
function_names.push((dispatch_offset, name.to_owned()));
Expand Down Expand Up @@ -300,7 +306,7 @@ pub fn make_bindings(
Some(0),
&ConstExpr::global_get(table_base),
Elements::Functions(
&summary
summary
.functions
.iter()
.enumerate()
Expand All @@ -309,7 +315,8 @@ pub fn make_bindings(
.is_dispatchable()
.then_some(import_function_count + u32::try_from(index).unwrap())
})
.collect::<Vec<_>>(),
.collect::<Vec<_>>()
.into(),
),
);

Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl Invoker for MyInvoker {
Ok(result)
}

async fn call_float32(&mut self, function: &str) -> Result<f32> {
async fn call_f32(&mut self, function: &str) -> Result<f32> {
let func = self
.instance
.get_typed_func::<(), (f32,)>(&mut self.store, function)?;
Expand All @@ -148,7 +148,7 @@ impl Invoker for MyInvoker {
Ok(result)
}

async fn call_float64(&mut self, function: &str) -> Result<f64> {
async fn call_f64(&mut self, function: &str) -> Result<f64> {
let func = self
.instance
.get_typed_func::<(), (f64,)>(&mut self.store, function)?;
Expand Down Expand Up @@ -532,7 +532,7 @@ pub async fn componentize(

let pre = InitPre::new(linker.instantiate_pre(component)?)?;
let instance = pre.instance_pre.instantiate_async(&mut store).await?;
let guest = pre.interface0.load(&mut store, &instance)?;
let guest = pre.indices.interface0.load(&mut store, &instance)?;

guest
.call_init(&mut store, &app_name, &symbols, stub_wasi)
Expand Down Expand Up @@ -721,7 +721,7 @@ fn make_stub_adapter(_module: &str, stubs: &HashMap<&str, FuncType>) -> Vec<u8>

for (index, (name, ty)) in stubs.iter().enumerate() {
let index = u32::try_from(index).unwrap();
types.function(
types.ty().function(
ty.params().iter().map(|&v| IntoValType(v).into()),
ty.results().iter().map(|&v| IntoValType(v).into()),
);
Expand Down
8 changes: 4 additions & 4 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,18 @@ async fn make_component(
}

#[derive(Debug, Copy, Clone)]
struct MyFloat32(f32);
struct MyF32(f32);

impl PartialEq<MyFloat32> for MyFloat32 {
impl PartialEq<MyF32> for MyF32 {
fn eq(&self, other: &Self) -> bool {
(self.0.is_nan() && other.0.is_nan()) || (self.0 == other.0)
}
}

#[derive(Debug, Copy, Clone)]
struct MyFloat64(f64);
struct MyF64(f64);

impl PartialEq<MyFloat64> for MyFloat64 {
impl PartialEq<MyF64> for MyF64 {
fn eq(&self, other: &Self) -> bool {
(self.0.is_nan() && other.0.is_nan()) || (self.0 == other.0)
}
Expand Down
Loading

0 comments on commit f19009e

Please sign in to comment.