Skip to content
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

add instructions for Makefile based projects #48

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ replicate its build steps.

# Usage

### CMAKE based projects
For building CMake projects, a toolchain file is included in the released sysroot
at `wasix-sysroot/clang-wasm.cmake_toolchain`. In addition to specifying the
toolchain:
Expand All @@ -67,6 +68,29 @@ toolchain:
linker package. It should be in the `PATH`.
* `CMAKE_TOOLCHAIN_FILE` and `CMAKE_SYSROOT` should both be set by you.

For an example of a CMAKE based project being built for WASIX, please read the (notes)[https://github.com/wasix-org/llvm-project/blob/llvmorg-16.0.0-wasix/NOTES-WASIX.md]
on how to build LLVM/clang for WASIX.

### Makefile based projects
For building `Makefile` based projects, there are certain compiler and linker flags that
need to be passed to as env vars:
```
CFLAGS="--target=wasm32-wasi --sysroot=$SYSROOT -matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \
-fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \
-g -flto -O2"

CXXFLAGS="--target=wasm32-wasi --sysroot=$SYSROOT -matomics -mbulk-memory -mmutable-globals -pthread -mthread-model posix -ftls-model=local-exec \
-fno-trapping-math -D_WASI_EMULATED_MMAN -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS \
-g -flto -fno-exceptions -O2"

LDFLAGS="-Wl,--shared-memory -Wl,--max-memory=4294967296 -Wl,--import-memory -Wl,--export-dynamic \
-Wl,--export=__heap_base -Wl,--export=__stack_pointer -Wl,--export=__data_end -Wl,--export=__wasm_init_tls \
-Wl,--export=__wasm_signal -Wl,--export=__tls_size -Wl,--export=__tls_align -Wl,--export=__tls_base \
-lwasi-emulated-mman -flto -g -Wl,-z,stack-size=8388608 -Wl,--error-limit=0"
```
For an example of a Makefile based project being built for WASIX, please read the (notes)[https://github.com/wasix-org/openssl/blob/master/NOTES-WASIX.md]
on how to build OpenSSL for WASIX.

The WASIX-specific tests and script in `test/wasix` can serve as examples for how
to set this up.

Expand Down
Loading