Skip to content
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

Fix WASM/WASI target #2604

Merged
merged 4 commits into from
Jan 21, 2025
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
2 changes: 1 addition & 1 deletion cmd/pen/src/compile_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pub const CROSS_COMPILE_TARGETS: &[&str] = &[
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
];

pub static COMPILE_CONFIGURATION: LazyLock<Arc<app::module_compiler::CompileConfiguration>> =
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
"viewee",
"wadler",
"wasi",
"wasip2",
"writability"
]
}
2 changes: 1 addition & 1 deletion doc/docs/advanced-features/cross-compile.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The language's compiler supports [cross compile](https://en.wikipedia.org/wiki/c
For example, run the following command to compile a `wasm32` binary for the WASI platform.

```sh
pen build --target wasm32-wasi
pen build --target wasm32-wasip2
```

Note that we currently support those targets via [Rust](https://www.rust-lang.org/)'s cross compiler toolchain. Please install a Rust compiler through [`rustup`](https://rust-lang.github.io/rustup/) to enable installation of toolchains for different targets.
Expand Down
4 changes: 2 additions & 2 deletions features/commands/build.feature
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Feature: Building packages
| i686-unknown-linux-musl |
| x86_64-unknown-linux-musl |
| aarch64-unknown-linux-musl |
| wasm32-wasi |
| wasm32-wasip2 |

Scenario Outline: Cross-build a library package
Given a file named "pen.json" with:
Expand All @@ -89,7 +89,7 @@ Feature: Building packages
| i686-unknown-linux-musl |
| x86_64-unknown-linux-musl |
| aarch64-unknown-linux-musl |
| wasm32-wasi |
| wasm32-wasip2 |

Scenario: Build an application package again
Given a file named "pen.json" with:
Expand Down
2 changes: 1 addition & 1 deletion lib/app/src/module_compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ mod tests {
#[test]
fn calculate() {
for (triple, size) in [
("wasm32-wasi", 4),
("wasm32-wasip2", 4),
("wasm64-wasi", 8),
("i386-unknown-linux-gnu", 4),
("x86_64-unknown-linux-gnu", 8),
Expand Down
3 changes: 1 addition & 2 deletions lib/hir/src/analysis/type_equality_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ fn check_canonical(one: &Type, other: &Type) -> bool {
.arguments()
.iter()
.zip(other.arguments())
.map(|(one, other)| check_canonical(one, other))
.all(|ok| ok)
.all(|(one, other)| check_canonical(one, other))
&& check_canonical(one.result(), other.result())
}
(Type::List(one), Type::List(other)) => check_canonical(one.element(), other.element()),
Expand Down
2 changes: 1 addition & 1 deletion packages/core/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/core/ffi/src/string/utf8.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ fn get_utf8_byte_index(string: &str, index: usize) -> usize {
.char_indices()
.nth(index)
.map(|(index, _)| index)
.unwrap_or_else(|| string.as_bytes().len())
.unwrap_or_else(|| string.len())
}

#[ffi::bindgen]
Expand Down
2 changes: 1 addition & 1 deletion packages/http/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/json/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/os-sync/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/os/ffi/application/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/os/ffi/library/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/prelude/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion packages/sql/ffi/rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ targets = [
"i686-unknown-linux-musl",
"x86_64-unknown-linux-musl",
"aarch64-unknown-linux-musl",
"wasm32-wasi",
"wasm32-wasip2",
]
2 changes: 1 addition & 1 deletion tools/integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ for target in \
i686-unknown-linux-musl \
x86_64-unknown-linux-musl \
aarch64-unknown-linux-musl \
wasm32-wasi; do
wasm32-wasip2; do
rustup target add $target
done

Expand Down
Loading