Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bazel_dep(name = "apple_support", version = "2.10.1")

# WASM builds (//wasm:*, //web:dds_web_wasm). If you bump this version,
# rebuild and run web/update_wasm.sh; see docs/wasm_build.md and patch_web_wasm.py.
bazel_dep(name = "emsdk", version = "5.0.7")
bazel_dep(name = "emsdk", version = "6.0.12")
# Java bindings (//jni:*). Provides the hermetic remote JDK used to build and run
# the FFM (java.lang.foreign) smoke test. rules_java 9.9.0 registers remotejdk_21
# and remotejdk_25; we pin JDK 25 (>= 22, so the Foreign Function & Memory API is
Expand All @@ -51,14 +51,14 @@ bazel_dep(name = "rules_java", version = "9.9.0")
bazel_dep(name = "rules_jvm_external", version = "7.1")

# Prefer GitHub, fall back to codeload CDN on transient timeouts (see CI flakes).
# Integrity and strip_prefix match BCR emsdk 5.0.7 source.json.
# Integrity and strip_prefix match BCR emsdk 6.0.12 source.json.
archive_override(
module_name = "emsdk",
integrity = "sha256-Jm30uWRN3hgwOvBdzn0EhUJzsLtSckbLf7aglZF3TM8=",
strip_prefix = "emsdk-5.0.7/bazel",
integrity = "sha256-TdOYQqDiy+O4KYeVdfuz+nArIkpf1LiYxHaMADVCJPk=",
strip_prefix = "emsdk-6.0.12/bazel",
urls = [
"https://github.com/emscripten-core/emsdk/archive/refs/tags/5.0.7.tar.gz",
"https://codeload.github.com/emscripten-core/emsdk/tar.gz/refs/tags/5.0.7",
"https://github.com/emscripten-core/emsdk/archive/refs/tags/6.0.12.tar.gz",
"https://codeload.github.com/emscripten-core/emsdk/tar.gz/refs/tags/6.0.12",
],
)

Expand Down
45 changes: 24 additions & 21 deletions MODULE.bazel.lock

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/wasm_build.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ The Emscripten SDK (emsdk) does NOT need to be manually installed. Bazel downloa

WASM builds use the Bazel Central Registry package pinned in `MODULE.bazel`:

- `bazel_dep(name = "emsdk", version = "5.0.7")` (Emscripten 5.0.x toolchain)
- `bazel_dep(name = "emsdk", version = "6.0.12")` (Emscripten 6.0.x toolchain)

If you upgrade `emsdk`, rebuild WASM targets and the DDS Web (`./web/update_wasm.sh`). The post-build script `web/patch_web_wasm.py` patches one generated `isFileURI` helper for browser/file URL safety; if Emscripten changes that line, update the regex in that script and this note.

Expand Down Expand Up @@ -159,7 +159,7 @@ For other experiments, copy built `.js` / `.wasm` files from `bazel-bin/wasm/` t

`-flto` is applied at compile time (`DDS_CPPOPTS`) but deliberately **not** at
link time. Passing `-flto` to the wasm link step was tried and reverted: the
`emsdk 5.0.7` package pinned in `MODULE.bazel` ships a frozen, pre-built cache
`emsdk` package pinned in `MODULE.bazel` (checked again at 6.0.12) ships a frozen, pre-built cache
containing only non-LTO system libraries, and requesting link-time LTO makes
Emscripten require LTO-bitcode variants of core sysroot libraries (e.g.
`libprintf_long_double`) that the frozen cache can't build on demand inside
Expand Down
4 changes: 3 additions & 1 deletion library/tests/dtest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ EM_JS(void, dtest_schedule_pthread_clean_exit, (int code), {
// Join C++ workers, let pending Worker "loaded" messages flush, then tear down
// Emscripten pthread Workers and exit Node. Avoids ASSERTIONS noise of the form
// `received "loaded" command from terminated worker` when -n exceeds the
// precreated PTHREAD_POOL_SIZE.
// precreated PTHREAD_POOL_SIZE. Emscripten 6 no longer exposes
// PThread.runningWorkers or a per-worker `loaded` flag, so there the wait is a
// bounded retry (up to 100 event-loop turns) rather than a readiness check.
[[noreturn]] static void dtest_emscripten_clean_exit(const int code)
{
dds::internal::shutdown_parallel_boards_pool();
Expand Down
4 changes: 2 additions & 2 deletions specs/wasm-emscripten.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ core solver builds and runs correctly under Emscripten.
- **The toolchain is hermetic and transition-driven.** `wasm_cc_binary` applies an
Emscripten **platform transition** to the underlying `cc_binary` — no
`--config=wasm` or `.bazelrc` profile is needed. The emsdk toolchain is
downloaded/cached by Bazel (pinned in `MODULE.bazel`, currently `emsdk 5.0.7`).
downloaded/cached by Bazel (pinned in `MODULE.bazel`, currently `emsdk 6.0.12`).
The transition is what makes the `//:build_wasm` config setting
(`@platforms//cpu:wasm32`) active — see [build-system](build-system.md).
- **WASM builds use pthreads.** Every `wasm_cc_binary` sets
Expand Down Expand Up @@ -75,7 +75,7 @@ core solver builds and runs correctly under Emscripten.
`dtest_wasm` is an additional harness port, not an example CLI.
- **No link-time LTO.** `-flto` applies at WASM compile time only
([build-system](build-system.md)); enabling it at link time was tried and
reverted because the `emsdk 5.0.7` toolchain pinned in `MODULE.bazel` ships a
reverted because the `emsdk` toolchain pinned in `MODULE.bazel` (checked again at 6.0.12) ships a
frozen, pre-built cache containing only non-LTO system libraries. Link-time
LTO requires LTO-bitcode variants of core sysroot libraries (e.g.
`libprintf_long_double`) that the frozen cache cannot build on demand inside
Expand Down
4 changes: 4 additions & 0 deletions web/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ WASM_WEB_LINKOPTS = WASM_LINKOPTS + [
"-sEXPORTED_FUNCTIONS=['_dds_web_calc_table','_dds_web_solve_leads','_dds_web_solve_plays','_malloc','_free']",
"-sEXPORTED_RUNTIME_METHODS=['ccall','getValue']",
"-sENVIRONMENT=web,worker,node",
# The Module properties createDdsModule() is called with (dds_web_solve.js,
# tests/dds_web_wasm_node.mjs). Emscripten >= 6.0.2 dropped wasmBinary from
# the default list: debug builds abort and release builds ignore the bytes.
"-sINCOMING_MODULE_JS_API=['wasmBinary']",
]

cc_binary(
Expand Down
4 changes: 2 additions & 2 deletions web/patch_web_wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
from pathlib import Path

# Keep in sync with bazel_dep(name = "emsdk", version = "...") in MODULE.bazel.
EXPECTED_EMSDK_BAZEL_DEP_VERSION = "5.0.7"
EXPECTED_EMSDK_BAZEL_DEP_VERSION = "6.0.12"

# Emscripten 5.x (emsdk 5.0.7): var isFileURI = filename => filename.startsWith("file://");
# Emscripten 5.x and 6.x (emsdk 6.0.12): var isFileURI = filename => filename.startsWith("file://");
# Older emsdk also emitted parentheses around the parameter.
UNPATCHED_IS_FILE_URI = re.compile(
r"var\s+isFileURI\s*=\s*(?:\(\s*)?(\w+)(?:\s*\))?\s*=>\s*"
Expand Down
Loading