Skip to content

Commit 12763f6

Browse files
committed
rust: Fix building of unit-wasm and rust examples
When building the rust stuff we were getting the following compiler error error: failed to run `rustc` to learn about target-specific information ... --- stderr error: Error loading target specification: Could not find specification for target "wasm32-wasi". Run `rustc --print target-list` for a list of built-in targets This is due to wasm32-wasi being renamed to wasm32-wasip1, with wasm32-wasi being kept clear for an eventual WASI 1.0 release. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 4d4f1f2 commit 12763f6

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

.github/workflows/build_tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
steps:
3232
- name: Install tools/deps
3333
run: |
34-
dnf -y install git wget clang llvm compiler-rt lld make wasi-libc-devel cargo rust rust-std-static-wasm32-unknown-unknown rust-std-static-wasm32-wasi
34+
dnf -y install git wget clang llvm compiler-rt lld make wasi-libc-devel cargo rust rust-std-static-wasm32-wasip1
3535
wget -O- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/libclang_rt.builtins-wasm32-wasi-20.0.tar.gz | tar --strip-components=1 -xvzf - -C $(dirname $(clang -print-runtime-dir))
3636
3737
- uses: actions/checkout@v3
@@ -55,7 +55,7 @@ jobs:
5555
wget -O- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/libclang_rt.builtins-wasm32-wasi-20.0.tar.gz | tar --strip-components=1 -xvzf - -C $(dirname $(clang -print-runtime-dir))
5656
curl https://sh.rustup.rs -sSf | sh -s -- -y
5757
. "$HOME/.cargo/env"
58-
rustup target add wasm32-wasi
58+
rustup target add wasm32-wasip1
5959
wget -O- https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sysroot-20.0.tar.gz | tar -xzf - -C ${RUNNER_TEMP}
6060
6161
- uses: actions/checkout@v3

examples/rust/Makefile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
include ../../shared.mk
22

3+
TARGET = wasm32-wasip1
4+
CARGO_CMD = cargo build --target=$(TARGET)
5+
36
SDIR = examples/rust
47

58
examples: rust-echo-request \
@@ -8,20 +11,20 @@ examples: rust-echo-request \
811
rust-large-upload
912

1013
rust-echo-request: echo-request/Cargo.toml echo-request/src/lib.rs
11-
$(PP_GEN) $(SDIR)/echo-request/target/wasm32-wasi/
12-
$(v)cd echo-request; cargo build --target=wasm32-wasi
14+
$(PP_GEN) $(SDIR)/echo-request/target/$(TARGET)/
15+
$(v)cd echo-request; $(CARGO_CMD)
1316

1417
rust-upload-reflector: upload-reflector/Cargo.toml upload-reflector/src/lib.rs
15-
$(PP_GEN) $(SDIR)/upload-reflector/target/wasm32-wasi/
16-
$(v)cd upload-reflector; cargo build --target=wasm32-wasi
18+
$(PP_GEN) $(SDIR)/upload-reflector/target/$(TARGET)/
19+
$(v)cd upload-reflector; $(CARGO_CMD)
1720

1821
rust-hello-world: hello-world/Cargo.toml hello-world/src/lib.rs
19-
$(PP_GEN) $(SDIR)/hello-world/target/wasm32-wasi/
20-
$(v)cd hello-world; cargo build --target=wasm32-wasi
22+
$(PP_GEN) $(SDIR)/hello-world/target/$(TARGET)/
23+
$(v)cd hello-world; $(CARGO_CMD)
2124

2225
rust-large-upload: large-upload/Cargo.toml large-upload/src/lib.rs
23-
$(PP_GEN) $(SDIR)/large-upload/target/wasm32-wasi/
24-
$(v)cd large-upload; cargo build --target=wasm32-wasi
26+
$(PP_GEN) $(SDIR)/large-upload/target/$(TARGET)/
27+
$(v)cd large-upload; $(CARGO_CMD)
2528

2629
clean:
2730
rm -f */Cargo.lock

src/rust/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ include ../../shared.mk
33
SDIR = src/rust
44

55
rustlib:
6-
$(PP_GEN) $(SDIR)/target/wasm32-wasi
7-
$(v)cargo build --target=wasm32-wasi
6+
$(PP_GEN) $(SDIR)/target/wasm32-wasip1
7+
$(v)cargo build --target=wasm32-wasip1
88

99
clean:
1010
rm -f Cargo.lock unit-wasm-sys/Cargo.lock

src/rust/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ cargo add unit-wasm
99

1010
## Prerequisites
1111

12-
- target add wasm32-wasi. `rustup target add wasm32-wasi`
12+
- target add wasm32-wasip1. `rustup target add wasm32-wasip1`
1313

1414
## From Source
1515

0 commit comments

Comments
 (0)