-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon.mk
53 lines (43 loc) · 1.91 KB
/
common.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Note: Submodules do not use this Makefile to allow them to build standalone!
CC=clang
CFLAGS=-O3 -I. -Wall
LDFLAGS=-flto
WASMCC=${WASI_SDK_PATH}/bin/clang --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot/
WASMCFLAGS=${CFLAGS}
# See https://lld.llvm.org/WebAssembly.html
WASMLDFLAGS=${LDFLAGS} -Wl,--allow-undefined,-z,stack-size=32768,--threads=1
# Clang 12 WebAssembly Options
# See https://clang.llvm.org/docs/ClangCommandLineReference.html#webassembly
# Disable WebAssembly Proposals aWsm does not support
WASMCFLAGS+= -mno-atomics # https://github.com/WebAssembly/threads
WASMCFLAGS+= -mno-bulk-memory # https://github.com/WebAssembly/bulk-memory-operations
WASMCFLAGS+= -mno-exception-handling # https://github.com/WebAssembly/exception-handling
WASMCFLAGS+= -mno-multivalue # https://github.com/WebAssembly/multi-value
# Mutable globals still exist, but disables the ability to import mutable globals
WASMCFLAGS+= -mno-mutable-globals # https://github.com/WebAssembly/mutable-global
WASMCFLAGS+= -mno-nontrapping-fptoint # https://github.com/WebAssembly/nontrapping-float-to-int-conversions
WASMCFLAGS+= -mno-reference-types # https://github.com/WebAssembly/reference-types
WASMCFLAGS+= -mno-sign-ext # https://github.com/WebAssembly/sign-extension-ops
WASMCFLAGS+= -mno-tail-call # https://github.com/WebAssembly/tail-call
WASMCFLAGS+= -mno-simd128 # https://github.com/webassembly/simd
# Disassemble WebAssembly binary
%.wat: %.wasm
wasm2wat $< -o $@
WAT2WASMFLAGS+= --disable-bulk-memory
WAT2WASMFLAGS+= --disable-multi-value
WAT2WASMFLAGS+= --disable-mutable-globals
WAT2WASMFLAGS+= --disable-reference-types
WAT2WASMFLAGS+= --disable-saturating-float-to-int
WAT2WASMFLAGS+= --disable-sign-extension
WAT2WASMFLAGS+= --disable-simd
%.wasm: %.wat
wat2wasm ${WAT2WASMFLAGS} $< -o $@
# wasmtime AOT
%.cwasm: %.wasm
wasmtime compile $< -o $@
# wamr AOT
%.aot: %.wasm
wamrc -o $@ $<
# wasm2c WIP
# %.wasm.c: %.wasm
# wasm2c $< -o $@