Skip to content
3 changes: 3 additions & 0 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Claimed to be required for emsdk:
# https://github.com/emscripten-core/emsdk/blob/main/bazel/README.md
build --incompatible_enable_cc_toolchain_resolution
14 changes: 12 additions & 2 deletions bazel/defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,17 @@ load("@rules_cc//cc:defs.bzl", "cc_binary")
def _optimized_wasm_cc_binary_transition_impl(settings, attr):
# TODO(PiotrSikora): Add -flto to copts/linkopts when fixed in emsdk.
# See: https://github.com/emscripten-core/emsdk/issues/971
#
# Define STANDALONE_WASM at compile time as well as link time (below).
# This influences Abseil libraries using conditional dependencies.
# TODO(martijneken): Remove after Abseil stops using this define.
#
# Disable warning -Wdeprecated-non-prototype for zlib:
# https://github.com/madler/zlib/issues/633
# This is fixed in more recent versions of zlib / protobuf.
# TODO(martijneken): Remove after protobuf version update.
return {
"//command_line_option:copt": ["-O3"],
"//command_line_option:copt": ["-O3", "-DSTANDALONE_WASM", "-Wno-deprecated-non-prototype"],
"//command_line_option:cxxopt": [],
"//command_line_option:linkopt": [],
"//command_line_option:collect_code_coverage": False,
Expand Down Expand Up @@ -91,7 +100,6 @@ def proxy_wasm_cc_binary(
linkopts = linkopts + [
"--no-entry",
"--js-library=$(location @proxy_wasm_cpp_sdk//:proxy_wasm_intrinsics_js)",
"-sSTANDALONE_WASM",
"-sEXPORTED_FUNCTIONS=_malloc",
],
tags = tags + [
Expand All @@ -102,6 +110,8 @@ def proxy_wasm_cc_binary(
)

wasm_cc_binary(
standalone = True,
threads = "off",
name = "wasm_" + name,
cc_target = ":proxy_wasm_" + name.rstrip(".wasm"),
tags = tags + [
Expand Down
2 changes: 2 additions & 0 deletions bazel/dependencies_extra.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@
# limitations under the License.

load("@emsdk//:emscripten_deps.bzl", "emscripten_deps")
load("@emsdk//:toolchains.bzl", "register_emscripten_toolchains")

# Requires proxy_wasm_cpp_sdk_dependencies() to be loaded first.
def proxy_wasm_cpp_sdk_dependencies_extra():
emscripten_deps()
register_emscripten_toolchains()
25 changes: 10 additions & 15 deletions bazel/emsdk.patch
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
diff --git a/bazel/emscripten_deps.bzl b/bazel/emscripten_deps.bzl
index 95801ba..95fdabd 100644
index 219cd93..c127d49 100644
--- a/bazel/emscripten_deps.bzl
+++ b/bazel/emscripten_deps.bzl
@@ -69,31 +69,3 @@ def emscripten_deps(emscripten_version = "latest"):
build_file = "@emsdk//emscripten_toolchain:emscripten.BUILD",
@@ -167,38 +167,3 @@ def emscripten_deps(emscripten_version = "latest"):
build_file_content = BUILD_FILE_CONTENT_TEMPLATE.format(bin_extension = ".exe"),
type = "zip",
)
-
Expand All @@ -14,6 +14,13 @@ index 95801ba..95fdabd 100644
- package_lock_json = "@emscripten_bin_linux//:emscripten/package-lock.json",
- )
-
- if "emscripten_npm_linux_arm64" not in excludes:
- npm_install(
- name = "emscripten_npm_linux_arm64",
- package_json = "@emscripten_bin_linux_arm64//:emscripten/package.json",
- package_lock_json = "@emscripten_bin_linux_arm64//:emscripten/package-lock.json",
- )
-
- if "emscripten_npm_mac" not in excludes:
- npm_install(
- name = "emscripten_npm_mac",
Expand All @@ -34,15 +41,3 @@ index 95801ba..95fdabd 100644
- package_json = "@emscripten_bin_win//:emscripten/package.json",
- package_lock_json = "@emscripten_bin_win//:emscripten/package-lock.json",
- )
diff --git a/bazel/emscripten_toolchain/BUILD.bazel b/bazel/emscripten_toolchain/BUILD.bazel
index eb36959..12dba37 100644
--- a/bazel/emscripten_toolchain/BUILD.bazel
+++ b/bazel/emscripten_toolchain/BUILD.bazel
@@ -13,7 +13,6 @@ filegroup(
"env.sh",
"env.bat",
"@emsdk//:binaries",
- "@emsdk//:node_modules",
"@nodejs//:node_files",
],
)
8 changes: 4 additions & 4 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def proxy_wasm_cpp_sdk_repositories():
maybe(
http_archive,
name = "emsdk",
sha256 = "1ca0ff918d476c55707bb99bc0452be28ac5fb8f22a9260a8aae8a38d1bc0e27",
# v3.1.7 with Bazel fixes
strip_prefix = "emsdk-0ea8f8a8707070e9a7c83fbb4a3065683bcf1799/bazel",
url = "https://github.com/emscripten-core/emsdk/archive/0ea8f8a8707070e9a7c83fbb4a3065683bcf1799.tar.gz",
sha256 = "d9e084ef352adaa4a15470f0dfc675fe8cab1a4e4d1720fb2e7547f31c3b5d40",
# v3.1.67
strip_prefix = "emsdk-a2383b33581adb7383c8f874d2dc34e07d055332/bazel",
url = "https://github.com/emscripten-core/emsdk/archive/a2383b33581adb7383c8f874d2dc34e07d055332.tar.gz",
patches = ["@proxy_wasm_cpp_sdk//bazel:emsdk.patch"],
patch_args = ["-p2"],
)
Expand Down