Skip to content

Commit

Permalink
Merge pull request #753 from Mossaka/wasip1
Browse files Browse the repository at this point in the history
chore: switch to wasm32-wasip1 target
  • Loading branch information
jprendes authored Nov 26, 2024
2 parents 75cc369 + fd58321 commit 1b0ef20
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 22 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 16 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,35 +176,35 @@ test-image/oci: dist/img-oci.tar dist/img-oci-artifact.tar

.PHONY: test-image/clean
test-image/clean:
rm -rf target/wasm32-wasi/$(OPT_PROFILE)/
rm -rf target/wasm32-wasip1/$(OPT_PROFILE)/

.PHONY: test-image/oci/clean
test-image/oci/clean:
rm -rf target/wasm32-wasi/$(OPT_PROFILE)/img-oci.tar
rm -rf target/wasm32-wasi/$(OPT_PROFILE)/img-oci-artifact.tar
rm -rf target/wasm32-wasip1/$(OPT_PROFILE)/img-oci.tar
rm -rf target/wasm32-wasip1/$(OPT_PROFILE)/img-oci-artifact.tar

.PHONY: demo-app
demo-app: target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm
demo-app: target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm

.PHONY: target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm
target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm:
rustup target add wasm32-wasi
.PHONY: target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm
target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm:
rustup target add wasm32-wasip1
cd crates/wasi-demo-app && cargo build $(RELEASE_FLAG)

target/wasm32-wasi/$(OPT_PROFILE)/img.tar: target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm
target/wasm32-wasip1/$(OPT_PROFILE)/img.tar: target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm
cd crates/wasi-demo-app && cargo build $(RELEASE_FLAG) --features oci-v1-tar

.PHONY: dist/img.tar
dist/img.tar:
@mkdir -p "dist/"
[ -f $(PWD)/dist/img.tar ] || $(MAKE) target/wasm32-wasi/$(OPT_PROFILE)/img.tar
[ -f $(PWD)/dist/img.tar ] || cp target/wasm32-wasi/$(OPT_PROFILE)/img.tar "$@"
[ -f $(PWD)/dist/img.tar ] || $(MAKE) target/wasm32-wasip1/$(OPT_PROFILE)/img.tar
[ -f $(PWD)/dist/img.tar ] || cp target/wasm32-wasip1/$(OPT_PROFILE)/img.tar "$@"

dist/img-oci.tar: target/wasm32-wasi/$(OPT_PROFILE)/img-oci.tar
dist/img-oci.tar: target/wasm32-wasip1/$(OPT_PROFILE)/img-oci.tar
@mkdir -p "dist/"
cp "$<" "$@"

dist/img-oci-artifact.tar: target/wasm32-wasi/$(OPT_PROFILE)/img-oci-artifact.tar
dist/img-oci-artifact.tar: target/wasm32-wasip1/$(OPT_PROFILE)/img-oci-artifact.tar
@mkdir -p "dist/"
cp "$<" "$@"

Expand All @@ -218,14 +218,14 @@ load/oci: dist/img-oci.tar dist/img-oci-artifact.tar
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms $<
sudo ctr -n $(CONTAINERD_NAMESPACE) image import --all-platforms dist/img-oci-artifact.tar

target/wasm32-wasi/$(OPT_PROFILE)/img-oci.tar: target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm
target/wasm32-wasip1/$(OPT_PROFILE)/img-oci.tar: target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm
mkdir -p ${CURDIR}/bin/$(OPT_PROFILE)/
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm -o target/wasm32-wasi/$(OPT_PROFILE)/img-oci.tar
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm -o target/wasm32-wasip1/$(OPT_PROFILE)/img-oci.tar

.PHONY:
target/wasm32-wasi/$(OPT_PROFILE)/img-oci-artifact.tar: target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm
target/wasm32-wasip1/$(OPT_PROFILE)/img-oci-artifact.tar: target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm
mkdir -p ${CURDIR}/bin/$(OPT_PROFILE)/
cargo run --bin oci-tar-builder -- --name wasi-demo-oci-artifact --as-artifact --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasi/$(OPT_PROFILE)/wasi-demo-app.wasm -o target/wasm32-wasi/$(OPT_PROFILE)/img-oci-artifact.tar
cargo run --bin oci-tar-builder -- --name wasi-demo-oci-artifact --as-artifact --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasip1/$(OPT_PROFILE)/wasi-demo-app.wasm -o target/wasm32-wasip1/$(OPT_PROFILE)/img-oci-artifact.tar

bin/kind: test/k8s/Dockerfile
$(DOCKER_BUILD) --output=bin/ -f test/k8s/Dockerfile --target=kind .
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm-test-modules/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ fn compile_rust(src: impl AsRef<Path>) -> Result<PathBuf> {
let dst = output_for(src)?;

Command::new(rustc)
.arg("--target=wasm32-wasi")
.arg("--target=wasm32-wasip1")
.arg("-Copt-level=z")
.arg("-Cstrip=symbols")
.arg("-o")
Expand Down
6 changes: 3 additions & 3 deletions crates/oci-tar-builder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ There is an experimental executable that uses the library and can package a wasm
To generate the package and import to a registry using a tool such as [regctl](https://github.com/regclient/regclient/blob/main/docs/install.md). To [run a local image registry](https://www.docker.com/blog/how-to-use-your-own-registry-2/) use `docker run -d -p 5000:5000 --name registry registry:2.7`

```
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasi/debug/wasi-demo-app.wasm -o ./dist/img-oci.tar
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --module ./target/wasm32-wasip1/debug/wasi-demo-app.wasm -o ./dist/img-oci.tar
regctl image import localhost:5000/wasi-demo-oci:latest ./dist/img-oci.tar
```

Expand Down Expand Up @@ -63,8 +63,8 @@ In order to be compatible with Docker, since Docker does not currently support t
The CNCF wg-wasm has published and [OCI artifact format](https://tag-runtime.cncf.io/wgs/wasm/deliverables/wasm-oci-artifact/) for packaging wasm modules and components. The artifact can be produced locally by running the `--as-artifact` flag:

```
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --as-artifact --module ./target/wasm32-wasi/debug/wasi-demo-app.wasm -o target/wasm32-wasi/debug/img-oci-artifact.tar
regctl image import localhost:5000/wasi-artifact:latest target/wasm32-wasi/debug/img-oci-artifact.tar
cargo run --bin oci-tar-builder -- --name wasi-demo-oci --repo ghcr.io/containerd/runwasi --tag latest --as-artifact --module ./target/wasm32-wasip1/debug/wasi-demo-app.wasm -o target/wasm32-wasip1/debug/img-oci-artifact.tar
regctl image import localhost:5000/wasi-artifact:latest target/wasm32-wasip1/debug/img-oci-artifact.tar
```

The manifest will follow the guidance:
Expand Down
2 changes: 1 addition & 1 deletion crates/wasi-demo-app/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
target = ["wasm32-wasi"]
target = ["wasm32-wasip1"]
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel="1.81.0"
profile="default"
targets = ["wasm32-wasi"]
targets = ["wasm32-wasip1"]

0 comments on commit 1b0ef20

Please sign in to comment.