diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 63bfbf48..d063faa3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,6 +43,8 @@ jobs: - name: test run: make ci shell: bash + - name: adapter + run: cargo build --release -p viceroy-component-adapter --target wasm32-unknown-unknown # Run the trap test in an isolated job. It needs different cargo features than the usual build, so # it entails rebuilding the whole workspace if we combine them in a single job. This way, we diff --git a/crates/adapter/src/descriptors.rs b/crates/adapter/src/descriptors.rs index bd4fd763..ea17a55d 100644 --- a/crates/adapter/src/descriptors.rs +++ b/crates/adapter/src/descriptors.rs @@ -57,13 +57,7 @@ impl Streams { pub enum StreamType { /// Streams for implementing stdio. - Stdio(Stdio), -} - -pub enum Stdio { - Stdin, - Stdout, - Stderr, + Stdio, } #[repr(C)] @@ -94,19 +88,19 @@ impl Descriptors { d.push(Descriptor::Streams(Streams { input: new_once(stdin::get_stdin()), output: OnceCell::new(), - type_: StreamType::Stdio(Stdio::Stdin), + type_: StreamType::Stdio, })) .trapping_unwrap(); d.push(Descriptor::Streams(Streams { input: OnceCell::new(), output: new_once(stdout::get_stdout()), - type_: StreamType::Stdio(Stdio::Stdout), + type_: StreamType::Stdio, })) .trapping_unwrap(); d.push(Descriptor::Streams(Streams { input: OnceCell::new(), output: new_once(stderr::get_stderr()), - type_: StreamType::Stdio(Stdio::Stderr), + type_: StreamType::Stdio, })) .trapping_unwrap(); diff --git a/crates/adapter/src/lib.rs b/crates/adapter/src/lib.rs index 531d903a..aab88d1e 100644 --- a/crates/adapter/src/lib.rs +++ b/crates/adapter/src/lib.rs @@ -1,3 +1,6 @@ +// Promote warnings into errors, when building in release mode. +#![cfg_attr(not(debug_assertions), deny(warnings))] + use crate::bindings::wasi::clocks::{monotonic_clock, wall_clock}; use crate::bindings::wasi::io::poll; use crate::bindings::wasi::io::streams; @@ -219,22 +222,6 @@ enum ImportAlloc { pointers: BumpAlloc, }, - /// An allocator specifically for getting the nth string allocation used - /// for preopens. - /// - /// This will allocate everything into `alloc`. All strings other than the - /// `nth` string, however, will be discarded (the allocator's state is reset - /// after the allocation). This means that the pointer returned for the - /// `nth` string will be retained in `alloc` while all others will be - /// discarded. - /// - /// The `cur` count starts at 0 and counts up per-string. - GetPreopenPath { - cur: u32, - nth: u32, - alloc: BumpAlloc, - }, - /// No import allocator is configured and if an allocation happens then /// this will abort. None, @@ -301,12 +288,6 @@ impl ImportAlloc { // WASI doesn't say all the strings have to be adjacent, so this // should work out in practice. // - // * Finally for `GetPreopenPath` this works out only insofar that the - // `State::temporary_alloc` space is used to store the path. The - // WASI-provided buffer is precisely sized, not overly large, meaning - // that we're forced to copy from `temporary_alloc` into the - // destination buffer for this WASI call. - // // Basically it's a case-by-case basis here that enables ignoring // shrinking return calls here. Not robust. if !old_ptr.is_null() { @@ -338,18 +319,6 @@ impl ImportAlloc { alloc.alloc(align, size) } } - ImportAlloc::GetPreopenPath { cur, nth, alloc } => { - if align == 1 { - let real_alloc = *nth == *cur; - if real_alloc { - alloc.alloc(align, size) - } else { - alloc.clone().alloc(align, size) - } - } else { - alloc.alloc(align, size) - } - } ImportAlloc::None => { unreachable!("no allocator configured") } @@ -1181,7 +1150,7 @@ pub unsafe extern "C" fn poll_oneoff( .trapping_unwrap(); match desc { Descriptor::Streams(streams) => match &streams.type_ { - StreamType::Stdio(_) => (ERRNO_SUCCESS, 1, 0), + StreamType::Stdio => (ERRNO_SUCCESS, 1, 0), }, _ => unreachable!(), } @@ -1194,7 +1163,7 @@ pub unsafe extern "C" fn poll_oneoff( .trapping_unwrap(); match desc { Descriptor::Streams(streams) => match &streams.type_ { - StreamType::Stdio(_) => (ERRNO_SUCCESS, 1, 0), + StreamType::Stdio => (ERRNO_SUCCESS, 1, 0), }, _ => unreachable!(), } @@ -1614,15 +1583,6 @@ impl State { } } - /// Configure that `cabi_import_realloc` will allocate once from - /// `self.temporary_data` for the duration of the closure `f`. - /// - /// Panics if the import allocator is already configured. - fn with_one_temporary_alloc(&self, f: impl FnOnce() -> T) -> T { - let alloc = unsafe { self.temporary_alloc() }; - self.with_import_alloc(ImportAlloc::OneAlloc(alloc), f).0 - } - /// Configure that `cabi_import_realloc` will allocate once from /// `base` with at most `len` bytes for the duration of `f`. /// diff --git a/lib/data/viceroy-component-adapter.wasm b/lib/data/viceroy-component-adapter.wasm index dbc20be7..d642012d 100755 Binary files a/lib/data/viceroy-component-adapter.wasm and b/lib/data/viceroy-component-adapter.wasm differ