commit 4738b09fcf5fe12d1f1b2e8912356210de87fbbc
parent 7da89f56bf5c1fe1ae3828cb859ce7a17510b804
Author: Amin Mesbah <dev@aminmesbah.com>
Date: Sat, 2 Nov 2019 19:06:06 -0700
Fix broken wasm build
Note that it doesn't appear to be sufficient to use -Xclang as suggested
in [1] to pass args to the compiler. The problem is that the driver has
by then already added its own problematic arguments such as
--target=x86_64, and we don't appear to be able to remove those.
[1]: https://clang.llvm.org/docs/FAQ.html#i-run-clang-cc1-and-get-weird-errors-about-missing-headers
Diffstat:
1 file changed, 5 insertions(+), 0 deletions(-)
diff --git a/build_wasm.sh b/build_wasm.sh
@@ -22,6 +22,8 @@ clang \
-ffreestanding \
-fno-builtin \
-std=c11 \
+ -internal-isystem /usr/lib/clang/9.0.0/include \
+ -internal-externc-isystem /usr/include \
-DGAME_WEBGL \
-o $wasm_dir/wasm.bc \
src/platform_wasm.c
@@ -30,6 +32,8 @@ llvm-link -o $wasm_dir/wasm.bc $wasm_dir/wasm.bc
opt -O3 -disable-simplify-libcalls $wasm_dir/wasm.bc -o $wasm_dir/wasm.bc
llc -O3 -disable-simplify-libcalls -filetype=obj $wasm_dir/wasm.bc -o $wasm_dir/wasm.o
+# TODO: remove __heap_base export when LLVM bug fix is released:
+# https://reviews.llvm.org/D65920
wasm-ld \
--no-entry $wasm_dir/wasm.o \
-o $wasm_dir/binary.wasm \
@@ -38,6 +42,7 @@ wasm-ld \
--export=render \
--export=window_resize \
--export=key_callback \
+ --export=__heap_base \
--import-memory
rm $wasm_dir/*.o