Skip to content

Commit 2c70d61

Browse files
committed
Update compile/link options to work with Abseil.
- Define STANDALONE_WASM at compile time - Disable USE_PTHREADS at link time (it implies SHARED_MEMORY, which is incompatible with STANDALONE_WASM) Signed-off-by: Martijn Stevenson <[email protected]>
1 parent 54167e2 commit 2c70d61

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

bazel/defs.bzl

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
1818
def _optimized_wasm_cc_binary_transition_impl(settings, attr):
1919
# TODO(PiotrSikora): Add -flto to copts/linkopts when fixed in emsdk.
2020
# See: https://github.com/emscripten-core/emsdk/issues/971
21+
#
22+
# Define STANDALONE_WASM at compile time as well as link time (below).
23+
# This influences Abseil libraries using conditional dependencies.
2124
return {
22-
"//command_line_option:copt": ["-O3"],
25+
"//command_line_option:copt": ["-O3", "-DSTANDALONE_WASM"],
2326
"//command_line_option:cxxopt": [],
2427
"//command_line_option:linkopt": [],
2528
"//command_line_option:collect_code_coverage": False,
@@ -93,6 +96,12 @@ def proxy_wasm_cc_binary(
9396
"--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)",
9497
"-sSTANDALONE_WASM",
9598
"-sEXPORTED_FUNCTIONS=_malloc",
99+
# Disable pthreads, because USE_PTHREADS implies SHARED_MEMORY and
100+
# "STANDALONE_WASM does not support shared memories yet"
101+
#
102+
# https://emscripten.org/docs/porting/pthreads.html
103+
# https://emscripten.org/docs/api_reference/wasm_workers.html
104+
"-sUSE_PTHREADS=0",
96105
],
97106
tags = tags + [
98107
"manual",

0 commit comments

Comments
 (0)