Skip to content

Commit 97b91b3

Browse files
authored
Merge branch 'main' into dev-clean-up
2 parents 6aab191 + 7465dee commit 97b91b3

File tree

3 files changed

+21
-5
lines changed

3 files changed

+21
-5
lines changed

.github/workflows/cpp.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
- uses: actions/checkout@v1
6868

6969
- name: Mount bazel cache
70-
uses: actions/cache@v1
70+
uses: actions/cache@v4
7171
with:
7272
path: "/home/runner/.cache/bazel"
7373
key: bazel

Makefile

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,23 @@ PKG_CONFIG_PATH = ${EMSDK}/upstream/emscripten/cache/sysroot/lib/pkgconfig
2626
WASM_LIBS = $(shell $(PKG_CONFIG) $(WASM_DEPS) $(PROTO_DEPS) \
2727
--with-path=$(PKG_CONFIG_PATH) --libs | sed -e 's/-pthread //g')
2828

29+
# See proxy_wasm_cc_binary build rule definition in bazel/defs.bzl for
30+
# explanation of emscripten link options.
31+
EMSCRIPTEN_LINK_OPTS := --no-entry \
32+
--js-library ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.js \
33+
-sSTANDALONE_WASM -sEXPORTED_FUNCTIONS=_malloc \
34+
-sALLOW_MEMORY_GROWTH=1 -sINITIAL_HEAP=64KB
35+
36+
2937
debug-deps:
3038
# WASM_DEPS : ${WASM_DEPS}
3139
# WASM_LIBS : ${WASM_LIBS}
3240
# PROTO_DEPS: ${PROTO_DEPS}
3341
# PROTO_OPTS: ${PROTO_OPTS}
3442

35-
# TODO(mpwarres): Add Emscripten stack/heap size params in PR#174.
3643
%.wasm %.wat: %.cc
37-
em++ --no-entry -sSTANDALONE_WASM -sEXPORTED_FUNCTIONS=_malloc \
38-
--std=c++17 -O3 -flto \
39-
--js-library ${PROXY_WASM_CPP_SDK}/proxy_wasm_intrinsics.js \
44+
em++ --std=c++17 -O3 -flto \
45+
${EMSCRIPTEN_LINK_OPTS} \
4046
-I${PROXY_WASM_CPP_SDK} \
4147
${CPP_CONTEXT_LIB} \
4248
${PROTO_OPTS} \

bazel/defs.bzl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,20 @@ def proxy_wasm_cc_binary(
9090
"@proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js",
9191
],
9292
linkopts = linkopts + [
93+
# Setting to indicate module is a "reactor library" without a main() entry point:
94+
# https://emscripten.org/docs/tools_reference/settings_reference.html#standalone-wasm
9395
"--no-entry",
96+
# File listing additional functions that Emscripten should expect to be implemented by the host:
97+
# https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#implement-c-in-javascript
9498
"--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)",
99+
# Emit Wasm module that can run without JavaScript
95100
"-sSTANDALONE_WASM",
101+
# Give host code access to Emscripten's _malloc() function
96102
"-sEXPORTED_FUNCTIONS=_malloc",
103+
# Allow allocating memory past initial heap size
104+
"-sALLOW_MEMORY_GROWTH=1",
105+
# Initial amount of heap memory. 64KB matches Rust SDK starting heap size.
106+
"-sINITIAL_HEAP=64KB",
97107
],
98108
tags = tags + [
99109
"manual",

0 commit comments

Comments
 (0)