diff --git a/.github/workflows/playground.yml b/.github/workflows/playground.yml index ae492a0d92..0ff19b9f4f 100644 --- a/.github/workflows/playground.yml +++ b/.github/workflows/playground.yml @@ -27,10 +27,8 @@ jobs: with: node-version: 20 - uses: ./.github/actions/install-rust - - uses: cargo-bins/cargo-binstall@v1.6.9 - - run: cargo binstall cargo-component@0.20.0 -y - run: rustup component add rustfmt # needed for cargo-component, apparently? - - run: rustup target add wasm32-wasip1 + - run: rustup target add wasm32-wasip2 - run: npm ci working-directory: playground - run: npm run build diff --git a/Cargo.lock b/Cargo.lock index 7de56f004f..d2999d20b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -398,7 +398,7 @@ version = "0.0.0" dependencies = [ "wasmprinter 0.246.2", "wat", - "wit-bindgen-rt 0.26.0", + "wit-bindgen 0.49.0", ] [[package]] @@ -2098,7 +2098,7 @@ version = "0.14.2+wasi-0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" dependencies = [ - "wit-bindgen-rt 0.39.0", + "wit-bindgen-rt", ] [[package]] @@ -3023,15 +3023,6 @@ dependencies = [ "wit-parser 0.244.0", ] -[[package]] -name = "wit-bindgen-rt" -version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "29c7526379ace8709ee9ab9f2bb50f112d95581063a59ef3097d9c10153886c9" -dependencies = [ - "bitflags", -] - [[package]] name = "wit-bindgen-rt" version = "0.39.0" diff --git a/Cargo.toml b/Cargo.toml index 764870a352..0a466439c6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -85,7 +85,7 @@ unnecessary_cast = 'warn' # allow_attributes_without_reason = 'warn' [workspace.package] -edition = '2021' +edition = '2024' license = "Apache-2.0 WITH LLVM-exception OR Apache-2.0 OR MIT" version = "0.246.2" # Current thinking for wasm-tools is that the minimum supported Rust version diff --git a/crates/wit-component/dl/src/lib.rs b/crates/wit-component/dl/src/lib.rs index 8cb486eb1c..f3b1e73a30 100644 --- a/crates/wit-component/dl/src/lib.rs +++ b/crates/wit-component/dl/src/lib.rs @@ -51,21 +51,23 @@ static mut ERROR: *const c_char = ptr::null(); static mut LIBRARIES: *const Libraries = ptr::null(); unsafe fn invalid_handle(library: *const c_void) -> bool { - if LIBRARIES.is_null() { - panic!( - "`__wasm_set_libraries` should have been called during \ + unsafe { + if LIBRARIES.is_null() { + panic!( + "`__wasm_set_libraries` should have been called during \ instantiation with a non-NULL value" - ); - } - - let library = library as *const Library; - if (0..(*LIBRARIES).count) - .any(|index| (*LIBRARIES).libraries.add(usize::try_from(index).unwrap()) == library) - { - false - } else { - ERROR = c"invalid library handle".as_ptr(); - true + ); + } + + let library = library as *const Library; + if (0..(*LIBRARIES).count) + .any(|index| (*LIBRARIES).libraries.add(usize::try_from(index).unwrap()) == library) + { + false + } else { + ERROR = c"invalid library handle".as_ptr(); + true + } } } @@ -73,12 +75,12 @@ unsafe fn invalid_handle(library: *const c_void) -> bool { /// /// `library` must be a valid, not-yet-closed library pointer returned by /// `dlopen`. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn dlclose(library: *mut c_void) -> c_int { - if invalid_handle(library) { -1 } else { 0 } + unsafe { if invalid_handle(library) { -1 } else { 0 } } } -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn dlerror() -> *const c_char { unsafe { let value = ERROR; @@ -90,38 +92,40 @@ pub extern "C" fn dlerror() -> *const c_char { /// # Safety /// /// `name` must be a valid pointer to a null-terminated string. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn dlopen(name: *const c_char, flags: c_int) -> *const c_void { - if LIBRARIES.is_null() { - panic!( - "`__wasm_set_libraries` should have been called during \ + unsafe { + if LIBRARIES.is_null() { + panic!( + "`__wasm_set_libraries` should have been called during \ instantiation with a non-NULL value" + ); + } + + if (flags & !(RTLD_LAZY | RTLD_NOW | RTLD_GLOBAL)) != 0 { + // TODO + ERROR = c"dlopen flags not yet supported".as_ptr(); + return ptr::null(); + } + + let name = CStr::from_ptr(name); + let name = name.to_bytes(); + let libraries = slice::from_raw_parts( + (*LIBRARIES).libraries, + usize::try_from((*LIBRARIES).count).unwrap(), ); - } - - if (flags & !(RTLD_LAZY | RTLD_NOW | RTLD_GLOBAL)) != 0 { - // TODO - ERROR = c"dlopen flags not yet supported".as_ptr(); - return ptr::null(); - } - - let name = CStr::from_ptr(name); - let name = name.to_bytes(); - let libraries = slice::from_raw_parts( - (*LIBRARIES).libraries, - usize::try_from((*LIBRARIES).count).unwrap(), - ); - if let Ok(index) = libraries.binary_search_by(|library| { - slice::from_raw_parts( - library.name.data, - usize::try_from(library.name.length).unwrap(), - ) - .cmp(name) - }) { - &libraries[index] as *const _ as _ - } else { - ERROR = c"library not found".as_ptr(); - ptr::null() + if let Ok(index) = libraries.binary_search_by(|library| { + slice::from_raw_parts( + library.name.data, + usize::try_from(library.name.length).unwrap(), + ) + .cmp(name) + }) { + &libraries[index] as *const _ as _ + } else { + ERROR = c"library not found".as_ptr(); + ptr::null() + } } } @@ -129,36 +133,36 @@ pub unsafe extern "C" fn dlopen(name: *const c_char, flags: c_int) -> *const c_v /// /// `library` must be a valid, not-yet-closed library pointer returned by /// `dlopen`, and `name` must be a valid pointer to a null-terminated string. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn dlsym(library: *const c_void, name: *const c_char) -> *const c_void { - if library as isize == RTLD_NEXT || library as isize == RTLD_DEFAULT { - // TODO - ERROR = c"dlsym RTLD_NEXT and RTLD_DEFAULT not yet supported".as_ptr(); - return ptr::null(); - } - - if invalid_handle(library) { - return ptr::null(); - } - - let library = library as *const Library; - let name = CStr::from_ptr(name); - let name = name.to_bytes(); - let symbols = slice::from_raw_parts( - (*library).symbols.symbols, - usize::try_from((*library).symbols.count).unwrap(), - ); - if let Ok(index) = symbols.binary_search_by(|symbol| { - slice::from_raw_parts( - symbol.name.data, - usize::try_from(symbol.name.length).unwrap(), - ) - .cmp(name) - }) { - symbols[index].address - } else { - ERROR = c"symbol not found".as_ptr(); - ptr::null() + unsafe { + if library as isize == RTLD_NEXT || library as isize == RTLD_DEFAULT { + // TODO + ERROR = c"dlsym RTLD_NEXT and RTLD_DEFAULT not yet supported".as_ptr(); + return ptr::null(); + } + if invalid_handle(library) { + return ptr::null(); + } + let library = library as *const Library; + let name = CStr::from_ptr(name); + let name = name.to_bytes(); + let symbols = slice::from_raw_parts( + (*library).symbols.symbols, + usize::try_from((*library).symbols.count).unwrap(), + ); + if let Ok(index) = symbols.binary_search_by(|symbol| { + slice::from_raw_parts( + symbol.name.data, + usize::try_from(symbol.name.length).unwrap(), + ) + .cmp(name) + }) { + symbols[index].address + } else { + ERROR = c"symbol not found".as_ptr(); + ptr::null() + } } } @@ -166,9 +170,11 @@ pub unsafe extern "C" fn dlsym(library: *const c_void, name: *const c_char) -> * /// /// `libraries` must be a valid pointer to a `Libraries` object, and this /// pointer must remain valid for the lifetime of the process. -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn __wasm_set_libraries(libraries: *const Libraries) { - LIBRARIES = libraries; + unsafe { + LIBRARIES = libraries; + } } #[cfg(target_arch = "wasm32")] diff --git a/crates/wit-dylib/ffi/src/lib.rs b/crates/wit-dylib/ffi/src/lib.rs index 5e91f7c6d4..25581e027a 100644 --- a/crates/wit-dylib/ffi/src/lib.rs +++ b/crates/wit-dylib/ffi/src/lib.rs @@ -24,12 +24,12 @@ use std::ptr; #[macro_export] macro_rules! export { ($name:ident) => { - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_initialize(ptr: *const u8) { unsafe { <$name as $crate::RawInterpreter>::raw_initialize(ptr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_dealloc_bytes( cx: *mut u8, ptr: *mut u8, @@ -44,22 +44,22 @@ macro_rules! export { } } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn wit_dylib_export_start(which: usize) -> *mut u8 { unsafe { <$name as $crate::RawInterpreter>::raw_export_start(which) } } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn wit_dylib_export_call(cx: *mut u8, which: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_export_call(cx, which) } } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn wit_dylib_export_async_call(cx: *mut u8, which: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_export_async_call(cx, which) } } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn wit_dylib_export_async_callback( a: u32, b: u32, @@ -69,257 +69,257 @@ macro_rules! export { unsafe { <$name as $crate::RawInterpreter>::raw_export_async_callback(a, b, c, which) } } - #[no_mangle] + #[unsafe(no_mangle)] pub extern "C" fn wit_dylib_export_finish(cx: *mut u8, which: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_export_finish(cx, which) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_resource_dtor(ty: usize, handle: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_resource_dtor(ty, handle) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_u8(cx: *mut u8) -> u8 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_u8(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_u8(cx: *mut u8, val: u8) { unsafe { <$name as $crate::RawInterpreter>::raw_push_u8(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_s8(cx: *mut u8) -> i8 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_s8(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_s8(cx: *mut u8, val: i8) { unsafe { <$name as $crate::RawInterpreter>::raw_push_s8(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_u16(cx: *mut u8) -> u16 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_u16(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_u16(cx: *mut u8, val: u16) { unsafe { <$name as $crate::RawInterpreter>::raw_push_u16(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_s16(cx: *mut u8) -> i16 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_s16(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_s16(cx: *mut u8, val: i16) { unsafe { <$name as $crate::RawInterpreter>::raw_push_s16(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_u32(cx: *mut u8) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_u32(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_u32(cx: *mut u8, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_u32(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_s32(cx: *mut u8) -> i32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_s32(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_s32(cx: *mut u8, val: i32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_s32(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_u64(cx: *mut u8) -> u64 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_u64(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_u64(cx: *mut u8, val: u64) { unsafe { <$name as $crate::RawInterpreter>::raw_push_u64(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_s64(cx: *mut u8) -> i64 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_s64(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_s64(cx: *mut u8, val: i64) { unsafe { <$name as $crate::RawInterpreter>::raw_push_s64(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_bool(cx: *mut u8) -> bool { unsafe { <$name as $crate::RawInterpreter>::raw_pop_bool(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_bool(cx: *mut u8, val: bool) { unsafe { <$name as $crate::RawInterpreter>::raw_push_bool(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_char(cx: *mut u8) -> char { unsafe { <$name as $crate::RawInterpreter>::raw_pop_char(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_char(cx: *mut u8, val: char) { unsafe { <$name as $crate::RawInterpreter>::raw_push_char(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_f32(cx: *mut u8) -> f32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_f32(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_f32(cx: *mut u8, val: f32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_f32(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_f64(cx: *mut u8) -> f64 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_f64(cx) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_f64(cx: *mut u8, val: f64) { unsafe { <$name as $crate::RawInterpreter>::raw_push_f64(cx, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_enum(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_enum(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_enum(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_enum(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_flags(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_flags(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_flags(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_flags(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_borrow(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_borrow(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_borrow(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_borrow(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_own(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_own(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_own(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_own(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_future(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_future(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_future(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_future(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_stream(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_stream(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_stream(cx: *mut u8, ty: usize, val: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_stream(cx, ty, val) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_record(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_pop_record(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_record(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_push_record(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_tuple(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_pop_tuple(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_tuple(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_push_tuple(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_option(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_option(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_option(cx: *mut u8, ty: usize, discr: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_option(cx, ty, discr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_result(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_result(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_result(cx: *mut u8, ty: usize, discr: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_result(cx, ty, discr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_variant(cx: *mut u8, ty: usize) -> u32 { unsafe { <$name as $crate::RawInterpreter>::raw_pop_variant(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_variant(cx: *mut u8, ty: usize, discr: u32) { unsafe { <$name as $crate::RawInterpreter>::raw_push_variant(cx, ty, discr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_string(cx: *mut u8, ptr: &mut *const u8) -> usize { unsafe { <$name as $crate::RawInterpreter>::raw_pop_string(cx, ptr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_string(cx: *mut u8, ptr: *mut u8, len: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_push_string(cx, ptr, len) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_list( cx: *mut u8, ty: usize, @@ -328,17 +328,17 @@ macro_rules! export { unsafe { <$name as $crate::RawInterpreter>::raw_pop_list(cx, ty, ptr) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_iter_next(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_pop_iter_next(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_pop_iter(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_pop_iter(cx, ty) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_push_list( cx: *mut u8, ty: usize, @@ -348,7 +348,7 @@ macro_rules! export { unsafe { <$name as $crate::RawInterpreter>::raw_push_list(cx, ty, ptr, len) } } - #[no_mangle] + #[unsafe(no_mangle)] pub unsafe extern "C" fn wit_dylib_list_append(cx: *mut u8, ty: usize) { unsafe { <$name as $crate::RawInterpreter>::raw_list_append(cx, ty) } } diff --git a/playground/component/Cargo.toml b/playground/component/Cargo.toml index 9a91d341bb..be5e327e65 100644 --- a/playground/component/Cargo.toml +++ b/playground/component/Cargo.toml @@ -6,7 +6,7 @@ edition.workspace = true [dependencies] wasmprinter = { workspace = true } wat = { workspace = true } -wit-bindgen-rt = { version = "0.26.0", features = ["bitflags"] } +wit-bindgen = { workspace = true, features = ['macros'] } [lib] crate-type = ["cdylib"] diff --git a/playground/component/src/lib.rs b/playground/component/src/lib.rs index 4f493e1e14..196800589e 100644 --- a/playground/component/src/lib.rs +++ b/playground/component/src/lib.rs @@ -1,7 +1,4 @@ -#[allow(warnings)] -mod bindings; - -use bindings::{Guest, PrintPart}; +wit_bindgen::generate!(); struct Component; @@ -60,4 +57,4 @@ impl Guest for Component { } } -bindings::export!(Component with_types_in bindings); +export!(Component); diff --git a/playground/package.json b/playground/package.json index f132274a11..02dea6b695 100644 --- a/playground/package.json +++ b/playground/package.json @@ -2,11 +2,11 @@ "type": "module", "scripts": { "build": "npm run build-component && npm run transpile && npm run typecheck && npm run bundle && npm run copy-files", - "build-component": "cd component && cargo component build --release --target wasm32-wasip1", + "build-component": "cd component && cargo build --release --target wasm32-wasip2", "bundle": "for source in worker.ts parse.ts print.ts; do esbuild --bundle --format=esm src/$source --outdir=dist; done", "copy-files": "cp pages/* component-built/*.wasm dist", "clean": "rm -rf component/src/bindings.rs component-built dist && echo '## you will need to run `cargo clean` separately to delete cargo artifacts'", - "transpile": "jco transpile --no-nodejs-compat ../target/wasm32-wasip1/release/component.wasm --out-dir component-built", + "transpile": "jco transpile --no-nodejs-compat ../target/wasm32-wasip2/release/component.wasm --out-dir component-built", "typecheck": "tsc" }, "dependencies": {