Skip to content

Commit 461126c

Browse files
feat: full no_std support
Signed-off-by: Henry Gressmann <[email protected]>
1 parent b9a4e87 commit 461126c

File tree

24 files changed

+363
-31
lines changed

24 files changed

+363
-31
lines changed

.github/workflows/test.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ jobs:
4141
run: rustup update nightly
4242

4343
- name: Build (nightly, no default features)
44-
run: cargo +nightly build --workspace --exclude wasm-testsuite --no-default-features
44+
run: cargo +nightly build --workspace --exclude wasm-testsuite --exclude rust-wasm-examples --no-default-features
4545

4646
- name: Run tests (nightly, no default features)
47-
run: cargo +nightly test --workspace --exclude wasm-testsuite --no-default-features
47+
run: cargo +nightly test --workspace --exclude wasm-testsuite --exclude rust-wasm-examples --no-default-features
4848

4949
- name: Run MVP testsuite (nightly)
5050
run: cargo +nightly test-mvp

Cargo.lock

Lines changed: 101 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
[workspace]
22
members=["crates/*"]
3-
default-members=["crates/cli"]
43
resolver="2"
54

65
[workspace.package]
@@ -9,3 +8,12 @@ edition="2021"
98
license="MIT OR Apache-2.0"
109
authors=["Henry Gressmann <[email protected]>"]
1110
repository="https://github.com/explodingcamera/tinywasm"
11+
12+
[package]
13+
name="tinywasm-root"
14+
publish=false
15+
edition="2021"
16+
17+
[dev-dependencies]
18+
color-eyre="0.6"
19+
tinywasm={path="crates/tinywasm"}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ $ cargo add tinywasm
5555
- **`parser`**\
5656
Enables the `tinywasm-parser` crate. This is enabled by default.
5757

58-
With all these features disabled, TinyWasm does not depend on any external crates and can be used in `no_std` environments.
58+
With all these features disabled, TinyWasm only depends on `core`, `alloc` and `libm` and can be used in `no_std` environments.
5959

6060
<!-- # 🎯 Goals
6161

crates/parser/src/conversion.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::log;
12
use alloc::{boxed::Box, format, string::ToString, vec::Vec};
2-
use log::debug;
33
use tinywasm_types::*;
44
use wasmparser::{FuncValidator, OperatorsReader, ValidatorResources};
55

@@ -239,7 +239,7 @@ pub fn process_operators<'a>(
239239
let mut labels_ptrs = Vec::new(); // indexes into the instructions array
240240

241241
for op in ops {
242-
debug!("op: {:?}", op);
242+
log::debug!("op: {:?}", op);
243243

244244
let op = op?;
245245
validator.op(offset, &op)?;
@@ -274,7 +274,7 @@ pub fn process_operators<'a>(
274274
}
275275
End => {
276276
if let Some(label_pointer) = labels_ptrs.pop() {
277-
debug!("ending block: {:?}", instructions[label_pointer]);
277+
log::debug!("ending block: {:?}", instructions[label_pointer]);
278278

279279
let current_instr_ptr = instructions.len();
280280

crates/parser/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ use log;
1414
#[cfg(not(feature = "logging"))]
1515
mod log {
1616
macro_rules! debug ( ($($tt:tt)*) => {{}} );
17+
macro_rules! error ( ($($tt:tt)*) => {{}} );
1718
pub(crate) use debug;
19+
pub(crate) use error;
1820
}
1921

2022
mod conversion;

crates/parser/src/module.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ impl ModuleReader {
181181
validator.end(offset)?;
182182
self.end_reached = true;
183183
}
184-
CustomSection(reader) => {
184+
CustomSection(_reader) => {
185185
debug!("Found custom section");
186-
debug!("Skipping custom section: {:?}", reader.name());
186+
debug!("Skipping custom section: {:?}", _reader.name());
187187
}
188188
// TagSection(tag) => {
189189
// debug!("Found tag section");

crates/tinywasm/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ path="src/lib.rs"
1616
log={version="0.4", optional=true}
1717
tinywasm-parser={version="0.3.0-alpha.0", path="../parser", default-features=false, optional=true}
1818
tinywasm-types={version="0.3.0-alpha.0", path="../types", default-features=false}
19+
libm={version="0.2", default-features=false}
1920

2021
[dev-dependencies]
2122
wasm-testsuite={path="../wasm-testsuite"}

crates/tinywasm/src/func.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
use crate::log;
12
use alloc::{boxed::Box, format, string::String, string::ToString, vec, vec::Vec};
2-
use log::{debug, info};
33
use tinywasm_types::{FuncAddr, FuncType, ValType, WasmValue};
44

55
use crate::{
@@ -34,7 +34,7 @@ impl FuncHandle {
3434

3535
// 4. If the length of the provided argument values is different from the number of expected arguments, then fail
3636
if func_ty.params.len() != params.len() {
37-
info!("func_ty.params: {:?}", func_ty.params);
37+
log::info!("func_ty.params: {:?}", func_ty.params);
3838
return Err(Error::Other(format!(
3939
"param count mismatch: expected {}, got {}",
4040
func_ty.params.len(),
@@ -62,7 +62,7 @@ impl FuncHandle {
6262
};
6363

6464
// 6. Let f be the dummy frame
65-
debug!("locals: {:?}", locals);
65+
log::debug!("locals: {:?}", locals);
6666
let call_frame = CallFrame::new(func_inst, params, locals);
6767

6868
// 7. Push the frame f to the call stack

crates/tinywasm/src/imports.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use core::fmt::Debug;
44

55
use crate::{
66
func::{FromWasmValueTuple, IntoWasmValueTuple, ValTypesFromTuple},
7-
LinkingError, Result,
7+
log, LinkingError, Result,
88
};
99
use alloc::{
1010
collections::BTreeMap,

0 commit comments

Comments
 (0)