File tree 2 files changed +14
-7
lines changed
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -29,17 +29,23 @@ PKG_CONFIG_PATH = ${EMSDK}/upstream/emscripten/cache/sysroot/lib/pkgconfig
29
29
WASM_LIBS = $(shell $(PKG_CONFIG ) $(WASM_DEPS ) $(PROTO_DEPS ) \
30
30
--with-path=$(PKG_CONFIG_PATH ) --libs | sed -e 's/-pthread //g')
31
31
32
+ # See proxy_wasm_cc_binary build rule definition in bazel/defs.bzl for
33
+ # explanation of emscripten link options.
34
+ EMSCRIPTEN_LINK_OPTS := --no-entry \
35
+ --js-library ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.js \
36
+ -sSTANDALONE_WASM -sEXPORTED_FUNCTIONS=_malloc \
37
+ -sALLOW_MEMORY_GROWTH=1 -sSTACK_SIZE=256KB -sINITIAL_HEAP=1MB
38
+
39
+
32
40
debug-deps :
33
41
# WASM_DEPS : ${WASM_DEPS}
34
42
# WASM_LIBS : ${WASM_LIBS}
35
43
# PROTO_DEPS: ${PROTO_DEPS}
36
44
# PROTO_OPTS: ${PROTO_OPTS}
37
45
38
- # TODO(mpwarres): Add Emscripten stack/heap size params in PR#174.
39
46
% .wasm % .wat : % .cc
40
- em++ --no-entry -sSTANDALONE_WASM -sEXPORTED_FUNCTIONS=_malloc \
41
- --std=c++17 -O3 -flto \
42
- --js-library ${PROXY_WASM_CPP_SDK} /proxy_wasm_intrinsics.js \
47
+ em++ --std=c++17 -O3 -flto \
48
+ ${EMSCRIPTEN_LINK_OPTS} \
43
49
-I${PROXY_WASM_CPP_SDK} \
44
50
${CPP_CONTEXT_LIB} \
45
51
${PROTO_OPTS} \
Original file line number Diff line number Diff line change @@ -104,9 +104,10 @@ def proxy_wasm_cc_binary(
104
104
"-sALLOW_MEMORY_GROWTH=1" ,
105
105
# Total stack size (fixed). Emscripten default stack size changed from 5MiB to 64KiB in
106
106
# 3.1.27: https://github.com/emscripten-core/emscripten/blob/main/ChangeLog.md,
107
- # https://github.com/emscripten-core/emscripten/pull/18191. We pick 1MiB somewhat
108
- # arbitrarily, since it is gives a little more room and is easy to remember.
109
- "-sSTACK_SIZE=1MB" ,
107
+ # https://github.com/emscripten-core/emscripten/pull/18191. We pick 256KB as a balance
108
+ # between reducing memory size and providing more headroom in case of deeper call
109
+ # stacks. For comparison, the Rust SDK uses 1MB stack by default.
110
+ "-sSTACK_SIZE=256KB" ,
110
111
# Initial amount of heap memory
111
112
"-sINITIAL_HEAP=1MB" ,
112
113
],
You can’t perform that action at this time.
0 commit comments