You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Suggested updates to proof of concept C host documentation
- Fills in documentation on how to use the C host
- Updates Dockerfile to be cross architecture
- Adds a new Dockerfile that is just the host
Signed-off-by: Kate Goldenring <kgoldenr@akamai.com>
Copy file name to clipboardExpand all lines: component-model/examples/example-c-host/Dockerfile.guest_and_host
+29-10Lines changed: 29 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -2,27 +2,46 @@ FROM ubuntu:24.04 AS build
2
2
3
3
ARG WASMTIME_VERSION=42.0.1
4
4
ARG WASI_SDK_VERSION=27
5
+
ARG TARGETARCH
5
6
6
7
RUN apt-get update && apt-get install -y --no-install-recommends \
7
8
gcc libc6-dev curl xz-utils ca-certificates \
8
9
&& rm -rf /var/lib/apt/lists/*
9
10
10
11
# Install wasmtime C API
11
-
RUN curl -sL https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-x86_64-linux-c-api.tar.xz \
# Install wit-bindgen and wasm-tools (pin versions)
21
34
ARG WIT_BINDGEN_VERSION=0.53.1
22
35
ARG WASM_TOOLS_VERSION=1.245.1
23
-
RUN curl -sL https://github.com/bytecodealliance/wit-bindgen/releases/download/v${WIT_BINDGEN_VERSION}/wit-bindgen-${WIT_BINDGEN_VERSION}-x86_64-linux.tar.gz \
24
-
| tar xz --strip-components=1 -C /usr/local/bin --wildcards '*/wit-bindgen' \
The following section requires you to have [a Rust toolchain][rust] installed.
307
+
This repository includes a C application that can execute components that implement the add interface. This application embeds Wasmtime using the Wasmtime C API:
308
+
`component-model/examples/example-c-host/host.c`.
309
309
310
-
> [!WARNING]
311
-
> You must be careful to use a version of the adapter (`wasi_snapshot_preview1.wasm`)
312
-
> that is compatible with the version of `wasmtime` that will be used,
313
-
> to ensure that WASI interface versions (and relevant implementation) match.
314
-
> (The `wasmtime` version is specified in [the Cargo configuration file][cargo-config]
315
-
> for the example host.)
310
+
The application expects three arguments: the two numbers to add and the Wasm component that executed the addition. For example:
316
311
317
-
{{#include ../example-host-part1.md}}
312
+
```sh
313
+
./adder-host <x><y><path-to-component.wasm>
314
+
```
315
+
316
+
You can either use a Dockerfile to execute your add component with the C application or directly run the application.
317
+
318
+
### Option A: Compile and run the host directly
319
+
320
+
If the Wasmtime C API headers and library are installed on your system,
321
+
you can compile and run the host directly:
318
322
319
-
A successful run should show the following output
320
-
(of course, the paths to your example host and adder component will vary,
321
-
and you should substitute `adder.wasm` with `adder.component.wasm`
322
-
if you followed the manual instructions above):
323
+
On Linux, the following commands install the C API artifacts in `/usr/local`
0 commit comments