Skip to content

Commit

Permalink
readme: add docs for webassembly
Browse files Browse the repository at this point in the history
Signed-off-by: Tonis Tiigi <[email protected]>
  • Loading branch information
tonistiigi committed Nov 7, 2022
1 parent 2d1da50 commit 980d0a7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,15 @@ RUN xx-cargo build --release --target-dir ./build && \
xx-verify ./build/$(xx-cargo --print-target)/release/hello_cargo
```

### WebAssembly

`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.

When using multi-stage builds to copy build results to other stages, note that Rust adds ".wasm" suffix to the binaries built with
WebAssembly.

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.

## External SDK support

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.
Expand Down

0 comments on commit 980d0a7

Please sign in to comment.