-
Notifications
You must be signed in to change notification settings - Fork 10
feat(wasi): Wasmtime integration test target (8/8 β ) #20
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
Open
gwpl
wants to merge
6
commits into
raphaelmansuy:main
Choose a base branch
from
VariousForks:i19-target-wasmtime
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,570
β6
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
dd59e71
feat(cli): add WASI target support with conditional rayon
gwpl 071003f
feat(wasi): add Docker-based WASM/RISC-V integration test infrastructure
gwpl b7ea475
feat(make): add wasi-build/test/status/clean Makefile targets
gwpl b5ef3be
fix(wasi): add ca-certificates and fix arg passing for RISC-V VM runners
gwpl 616130d
fix(wasi): fix Spike pk path and document RISC-V VM limitations
gwpl bc882e8
fix(wasi): address Copilot review β test robustness and UX improvements
gwpl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| # Build artifacts β extracted binaries from Docker builds | ||
| .build/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| # βββ Reproducible RISC-V Cross-Compilation ββββββββββββββββββββββββββββββββββ | ||
| # Greg's AI coding buddy: | ||
| # Cross-compiles edgeparse for riscv64gc-unknown-linux-gnu. | ||
| # Produces TWO binaries: | ||
| # 1. Dynamic-linked β runs under QEMU user-mode (with sysroot) | ||
| # 2. Static-linked β runs on Spike/libriscv/RVVM/CKB-VM (no sysroot) | ||
| # | ||
| # riscv64gc = RV64IMAFDC β the "general-purpose computing" profile | ||
| # that Linux distros target (Debian, Ubuntu, Fedora all ship riscv64gc). | ||
| # | ||
| # Usage: | ||
| # docker build -f tests/wasm-runtimes/Dockerfile.build.riscv \ | ||
| # -t edgeparse-riscv-build . | ||
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
|
||
| FROM rust:1-slim-bookworm AS builder | ||
|
|
||
| # Cross-compilation toolchain for RISC-V 64-bit | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| gcc-riscv64-linux-gnu \ | ||
| libc6-dev-riscv64-cross \ | ||
| pkg-config \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN rustup target add riscv64gc-unknown-linux-gnu | ||
|
|
||
| # Tell cargo which linker to use for the RISC-V target | ||
| ENV CARGO_TARGET_RISCV64GC_UNKNOWN_LINUX_GNU_LINKER=riscv64-linux-gnu-gcc | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| # ββ Cache cargo registry: copy manifests first ββββββββββββββββββββββββββββββ | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY crates/edgeparse-core/Cargo.toml crates/edgeparse-core/ | ||
| COPY crates/edgeparse-cli/Cargo.toml crates/edgeparse-cli/ | ||
| COPY crates/pdf-cos/Cargo.toml crates/pdf-cos/ | ||
|
|
||
| # Strip workspace members that need native platform SDKs | ||
| RUN sed -E -i \ | ||
| '/"crates\/(edgeparse-python|edgeparse-node|edgeparse-wasm)"/d' \ | ||
| Cargo.toml && \ | ||
| mkdir -p crates/edgeparse-core/src crates/edgeparse-cli/src crates/pdf-cos/src && \ | ||
| echo "fn main() {}" > crates/edgeparse-cli/src/main.rs && \ | ||
| touch crates/edgeparse-core/src/lib.rs && \ | ||
| touch crates/pdf-cos/src/lib.rs && \ | ||
| cargo build --target riscv64gc-unknown-linux-gnu --release \ | ||
| -p edgeparse-cli 2>/dev/null || true | ||
|
|
||
| # ββ Copy real source and build (dynamic) ββββββββββββββββββββββββββββββββββββ | ||
| COPY crates/ crates/ | ||
| RUN find crates/ -name '*.rs' -exec touch {} + && \ | ||
| cargo build --target riscv64gc-unknown-linux-gnu --release \ | ||
| -p edgeparse-cli | ||
|
|
||
| # Save dynamic binary before static build overwrites it | ||
| RUN cp target/riscv64gc-unknown-linux-gnu/release/edgeparse /tmp/edgeparse-dynamic | ||
|
|
||
| # ββ Build statically-linked variant for Spike/libriscv/RVVM/CKB-VM βββββββββ | ||
| # These VMs have minimal/no dynamic linker β static linking is essential. | ||
| RUN RUSTFLAGS="-C target-feature=+crt-static" \ | ||
| cargo build --target riscv64gc-unknown-linux-gnu --release \ | ||
| -p edgeparse-cli && \ | ||
| cp target/riscv64gc-unknown-linux-gnu/release/edgeparse /tmp/edgeparse-static | ||
|
|
||
| # ββ Output stage ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| FROM scratch AS output | ||
| COPY --from=builder /tmp/edgeparse-dynamic /out/edgeparse | ||
| COPY --from=builder /tmp/edgeparse-static /out/edgeparse-static |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| # βββ Reproducible WASIX Build βββββββββββββββββββββββββββββββββββββββββββββββ | ||
| # Greg's AI coding buddy: | ||
| # Builds edgeparse as a WASIX binary (.wasm) using cargo-wasix. | ||
| # WASIX = WASI + POSIX superpowers (threads, sockets, fork/exec). | ||
| # Only runs on Wasmer β the one runtime to rule them all (for WASIX). | ||
| # | ||
| # The target triple is wasm32-wasmer-wasi β a custom Wasmer target | ||
| # that extends wasm32-wasi with the full POSIX syscall surface. | ||
| # | ||
| # Usage: | ||
| # docker build -f tests/wasm-runtimes/Dockerfile.build.wasix \ | ||
| # -t edgeparse-wasix-build . | ||
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
|
||
| FROM rust:1-slim-bookworm AS builder | ||
|
|
||
| # cargo-wasix installs its own rustup toolchain + wasm32-wasmer-wasi target | ||
| RUN cargo install cargo-wasix | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| # ββ Cache cargo registry: copy manifests first ββββββββββββββββββββββββββββββ | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY crates/edgeparse-core/Cargo.toml crates/edgeparse-core/ | ||
| COPY crates/edgeparse-cli/Cargo.toml crates/edgeparse-cli/ | ||
| COPY crates/pdf-cos/Cargo.toml crates/pdf-cos/ | ||
|
|
||
| # Strip workspace members that don't compile for WASIX | ||
| RUN sed -E -i \ | ||
| '/"crates\/(edgeparse-python|edgeparse-node|edgeparse-wasm)"/d' \ | ||
| Cargo.toml && \ | ||
| mkdir -p crates/edgeparse-core/src crates/edgeparse-cli/src crates/pdf-cos/src && \ | ||
| echo "fn main() {}" > crates/edgeparse-cli/src/main.rs && \ | ||
| touch crates/edgeparse-core/src/lib.rs && \ | ||
| touch crates/pdf-cos/src/lib.rs && \ | ||
| cargo wasix build --release -p edgeparse-cli --no-default-features 2>/dev/null || true | ||
|
|
||
| # ββ Copy real source and build ββββββββββββββββββββββββββββββββββββββββββββββ | ||
| COPY crates/ crates/ | ||
| RUN find crates/ -name '*.rs' -exec touch {} + && \ | ||
| cargo wasix build --release -p edgeparse-cli --no-default-features | ||
|
|
||
| # ββ Output stage ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| FROM scratch AS output | ||
| COPY --from=builder \ | ||
| /build/target/wasm32-wasmer-wasi/release/edgeparse.wasm \ | ||
| /out/edgeparse-wasix.wasm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| # βββ Reproducible WASM (WASI) Build βββββββββββββββββββββββββββββββββββββββββ | ||
| # Greg's AI coding buddy: | ||
| # Builds edgeparse as a WASI Preview 1 binary (.wasm) that runs on | ||
| # any conformant runtime (wasmtime, wasmer, wasmedge, wamr). | ||
| # | ||
| # The wasm32-wasip1 target compiles edgeparse-core without rayon/image/zip | ||
| # (those need native threads or JS glue). Pure PDF parsing still works β | ||
| # you just lose parallelism and image extraction. | ||
| # | ||
| # Usage: | ||
| # docker build -f tests/wasm-runtimes/Dockerfile.build.wasm \ | ||
| # -t edgeparse-wasi-build . | ||
| # # Extract the binary: | ||
| # id=$(docker create edgeparse-wasi-build) && \ | ||
| # docker cp "$id":/out/edgeparse.wasm tests/wasm-runtimes/.build/ && \ | ||
| # docker rm "$id" | ||
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
|
||
| FROM rust:1-slim-bookworm AS builder | ||
|
|
||
| RUN rustup target add wasm32-wasip1 | ||
|
|
||
| WORKDIR /build | ||
|
|
||
| # ββ Cache cargo registry: copy manifests first ββββββββββββββββββββββββββββββ | ||
| COPY Cargo.toml Cargo.lock ./ | ||
| COPY crates/edgeparse-core/Cargo.toml crates/edgeparse-core/ | ||
| COPY crates/edgeparse-cli/Cargo.toml crates/edgeparse-cli/ | ||
| COPY crates/pdf-cos/Cargo.toml crates/pdf-cos/ | ||
|
|
||
| # Strip workspace members that don't compile for wasm32-wasip1 | ||
| # (pyo3, napi-rs, wasm-bindgen are browser-only / native-only) | ||
| RUN sed -E -i \ | ||
| '/"crates\/(edgeparse-python|edgeparse-node|edgeparse-wasm)"/d' \ | ||
| Cargo.toml && \ | ||
| mkdir -p crates/edgeparse-core/src crates/edgeparse-cli/src crates/pdf-cos/src && \ | ||
| echo "fn main() {}" > crates/edgeparse-cli/src/main.rs && \ | ||
| touch crates/edgeparse-core/src/lib.rs && \ | ||
| touch crates/pdf-cos/src/lib.rs && \ | ||
| cargo build --target wasm32-wasip1 --release \ | ||
| -p edgeparse-cli --no-default-features 2>/dev/null || true | ||
| # ^^ dummy build warms the dep cache; may fail on empty libs β that's fine | ||
|
|
||
| # ββ Copy real source and build ββββββββββββββββββββββββββββββββββββββββββββββ | ||
| COPY crates/ crates/ | ||
| RUN find crates/ -name '*.rs' -exec touch {} + && \ | ||
| cargo build --target wasm32-wasip1 --release \ | ||
| -p edgeparse-cli --no-default-features | ||
|
|
||
| # ββ Output stage β just the binary ββββββββββββββββββββββββββββββββββββββββββ | ||
| FROM scratch AS output | ||
| COPY --from=builder \ | ||
| /build/target/wasm32-wasip1/release/edgeparse.wasm \ | ||
| /out/edgeparse.wasm |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # βββ Shared Runner Base βββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| # Greg's AI coding buddy: | ||
| # Common base layer for all WASM runtime test containers. | ||
| # Build this FIRST β subsequent runtime images inherit its cached layers. | ||
| # | ||
| # docker build -f tests/wasm-runtimes/Dockerfile.runner.base \ | ||
| # -t edgeparse-wasi-base . | ||
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
|
||
| FROM ubuntu:24.04 | ||
|
|
||
| # Shared dependencies β curl for runtime installers, ca-certs for HTTPS, | ||
| # xz-utils for compressed release tarballs, file for MIME sniffing | ||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| curl \ | ||
| ca-certificates \ | ||
| xz-utils \ | ||
| file \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| WORKDIR /test | ||
|
|
||
| # Copy test fixtures and scripts | ||
| COPY tests/fixtures/sample.pdf /test/fixtures/ | ||
| COPY tests/wasm-runtimes/run-tests.sh /test/ | ||
| RUN chmod +x /test/run-tests.sh | ||
|
|
||
| # The .wasm binary is expected at /test/edgeparse.wasm | ||
| # It gets copied in by each runtime Dockerfile or mounted at runtime. | ||
|
|
||
| ENTRYPOINT ["/test/run-tests.sh"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # βββ CKB-VM Runner ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
| # Greg's AI coding buddy: | ||
| # CKB-VM β Production blockchain VM from Nervos Network. | ||
| # rv64imc ISA, W^X memory protection, gas metering, JIT compilation. | ||
| # 2.5x faster than Wasmer Singlepass. Deployed on CKB mainnet. | ||
| # | ||
| # Uses ckb-debugger to execute RISC-V ELF binaries with | ||
| # Linux syscall emulation. Limited POSIX support β designed for | ||
| # deterministic computation, not general-purpose Linux apps. | ||
| # | ||
| # EXPERIMENTAL: CKB-VM has limited syscall support. edgeparse's | ||
| # file I/O may not be fully supported. Tests may partially fail. | ||
| # | ||
| # docker build -f tests/wasm-runtimes/Dockerfile.runner.ckb-vm \ | ||
| # -t edgeparse-riscv-ckb-vm . | ||
| # βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | ||
|
|
||
| FROM rust:1-slim-bookworm AS builder | ||
|
|
||
| # Build ckb-standalone-debugger which can run RISC-V ELF binaries | ||
| RUN cargo install ckb-debugger 2>/dev/null || \ | ||
| (apt-get update && apt-get install -y --no-install-recommends git pkg-config libssl-dev && \ | ||
| cargo install --git https://github.com/nervosnetwork/ckb-standalone-debugger ckb-debugger) | ||
|
|
||
| FROM ubuntu:24.04 | ||
|
|
||
| RUN apt-get update && apt-get install -y --no-install-recommends \ | ||
| file \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY --from=builder /usr/local/cargo/bin/ckb-debugger /usr/local/bin/ | ||
|
|
||
| # Verify | ||
| RUN ckb-debugger --version 2>&1 || echo "CKB debugger installed" | ||
|
|
||
| WORKDIR /test | ||
|
|
||
| COPY tests/fixtures/sample.pdf /test/fixtures/ | ||
| COPY tests/wasm-runtimes/run-tests.sh /test/ | ||
| RUN chmod +x /test/run-tests.sh | ||
|
|
||
| # Copy pre-built RISC-V binary (statically linked) | ||
| COPY tests/wasm-runtimes/.build/edgeparse-riscv64-static /test/edgeparse-riscv64 | ||
|
|
||
| ENTRYPOINT ["/test/run-tests.sh"] | ||
| CMD ["ckb-vm"] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These targets invoke
tests/wasm-runtimes/wasm-test.shdirectly. If the file mode isn't executable in a fresh checkout (common when scripts are added withoutchmod +x),make wasi-*will fail. To make this robust, consider invoking it viabash $(WASI_SCRIPT)(or ensure the executable bit is guaranteed in the repo).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI Assistant: The script has
#!/usr/bin/env bashshebang and is marked executable (chmod +x). Running it directly is standard Unix practice. If execute permissions are missing,makewill report a clear error. Usingbash $(WASI_SCRIPT)would bypass the shebang, which could cause issues if the script ever needs a different shell.