Skip to content

Commit 980d0a7

Browse files
committed
readme: add docs for webassembly
Signed-off-by: Tonis Tiigi <[email protected]>
1 parent 2d1da50 commit 980d0a7

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,15 @@ RUN xx-cargo build --release --target-dir ./build && \
447447
xx-verify ./build/$(xx-cargo --print-target)/release/hello_cargo
448448
```
449449

450+
### WebAssembly
451+
452+
`xx-cargo` can also be used to build WebAssembly targets. Use platform `wasi/wasm` on your builds for `xx` to pick up the correct configuration. If your code is compatible you can use identical Dockerfile to build Linux and WebAssembly containers.
453+
454+
When using multi-stage builds to copy build results to other stages, note that Rust adds ".wasm" suffix to the binaries built with
455+
WebAssembly.
456+
457+
Only Rust builds are supported at the moment. To build C/C++ code for WebAssembly using `xx-clang` your Dockerfile needs to set up Wasi Sysroot and `libclang-rt` itself.
458+
450459
## External SDK support
451460

452461
In addition to Linux targets, `xx` can also build binaries for MacOS and Windows. When building MacOS binaries from C, external MacOS SDK is needed in `/xx-sdk` directory. Such SDK can be built, for example, with [gen_sdk_package script in osxcross project](https://github.com/tpoechtrager/osxcross/blob/master/tools/gen_sdk_package.sh). Please consult XCode license terms when making such an image. `RUN --mount` syntax can be used in Dockerfile in order to avoid copying SDK files. No special tooling such as `ld64` linker is required in the image itself.

0 commit comments

Comments
 (0)