Repository navigation
chore: update the Web Assembly CI job to Emscripten 6.0.13 - #16142
Draft
basvandijk wants to merge 14 commits into
Draft
basvandijk wants to merge 14 commits into
basvandijk wants to merge 14 commits into
Conversation
Contributor
Author
|
How this was tested:
|
Contributor
Author
|
changelog-no |
This was referenced Oct 31, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t `lean.js` links Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On Emscripten the shared libraries are dummies: `lean.js` links the static archives (`LEAN_EXE_LINKER_FLAGS`), and `src/CMakeLists.txt` only touches `libInit_shared.so`, `libleanshared_1.so`, `libleanshared_2.so` and `libleanshared.so`. The `lean` rule in `stdlib.make` still depended on them, so once per build, after `lib/temp/empty.c` had been created, `make` ran their recipes, that is `emcc -shared`, which Emscripten before 6.0 emulated with a static object file and a warning and which Emscripten 6 turns into a real side-module link of all of Lean. And because the dummies are touched on every build, `make install` relinked `lean.js`, nine of the Web Assembly job's sixty minutes. `lean.js` now depends on `libInit.a`, `libStd.a`, `libLean.a`, `libleancpp.a`, `libleanrt.a`, `libleanshell.a` and `libleanmain.a`, with the Lake `.trace` files of the first three like the other binaries, and the dummy `leanshared` target depends on `leanrt`, which nothing ordered before `lean.js` so far. The shared-library recipes are no longer reachable on Emscripten; the native rule is unchanged. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Since Emscripten 6.0.6, `emcc` links libc++ and libc++abi only when run as `em++` or with `-sDEFAULT_TO_CXX=1`, and it has always ignored `-lstdc++` for compatibility with GNU toolchains. `lean.js` is linked by `leanc.sh`, that is by `emcc`, with `ERROR_ON_UNDEFINED_SYMBOLS=0` and `MAIN_MODULE=1`, so on Emscripten 6 the link succeeds and `lean.js` fails when Node.js starts it. On Emscripten the C++ standard library flag is therefore `-sDEFAULT_TO_CXX=1`; before 6.0.6 the setting is on by default, so this changes nothing there. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
`-sALLOW_MEMORY_GROWTH=1` takes effect only when linking, but `EMSCRIPTEN_SETTINGS` passed it to every compilation as well, through `LEAN_EXTRA_CXX_FLAGS` and libuv's `CMAKE_C_FLAGS`, which emcc reports 147 times per build as `linker setting ignored during compilation`. The flags for compiling and linking, `-fwasm-exceptions -pthread -flto`, are now `EMSCRIPTEN_FLAGS` and the settings `EMSCRIPTEN_LINK_SETTINGS`; both go into `LEAN_EXTRA_LINKER_FLAGS`, which `leanc.sh` adds to every link, so `LEAN_EXE_LINKER_FLAGS` does not repeat them. Settings use the `-sKEY=VALUE` spelling that Emscripten documents. `LINKABLE=1` is dropped: `MAIN_MODULE=1` implies it in every Emscripten version from 3.1.44 to 6.0.13, and Emscripten 4.0.15 deprecated it, so newer versions warn about setting it explicitly. The comment quoting Emscripten's old advice to pass all `-s` flags at compile time went with it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Since Emscripten 4.0.11 the `libclang_rt.builtins` system library bundles LLVM's profiling runtime, and a main module (`-sMAIN_MODULE=1`) links its system libraries as whole archives, so the runtime's static initializer runs in every `lean.js` process and its `atexit` hook writes `default.profraw` into the current directory: 128 bytes after `lean --version`, 640 bytes after a test. That fails CI's check that the test suite leaves the source tree clean and would litter every user's working directory. `lean_main` now points the runtime at `/dev/null`. The symbol is weak, so Emscripten versions without the runtime, such as 3.1.44, link and behave as before. Reported upstream as emscripten-core/emscripten#28123. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Emscripten 3.1.44 is from July 2023; 6.0.13 is the current release. `setup-emsdk` installs it directly and keys its cache on the version. The previous commits cover the two changes in Emscripten 6 that affect this build: `-shared` builds real side modules, and `emcc` no longer links the C++ runtime by default. `lean.js` still runs on Node.js 26; emcc uses the Node.js bundled with the SDK for its own passes. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The page described the Lean 3 build (`emconfigure`, the `lean_js_js` and `lean_js_wasm` targets, lean-web-editor) and was linked from nowhere. It now describes the build as the Web Assembly CI job runs it: a native 32-bit stage 0 compiles the `.olean` files, Emscripten cross-compiles stage 1 into `lean.js` and `lean.wasm`, Node.js 24 or newer runs them through the `bin/lean` launcher, and the tests run one at a time. `ci.yml` and `build-template.yml` remain the authoritative source of the flags and the SDK version. `doc/make/index.md` links the page. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
basvandijk
force-pushed
the
wasm-emsdk-6
branch
from
November 2, 2026 11:41
d076816 to
e80c565
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates the Web Assembly CI job from Emscripten 3.1.44, released in July 2023, to 6.0.13, the current release, so that the WebAssembly build of
leanis checked against a maintained toolchain.Three changes in newer Emscripten versions affect
lean.js.emcclinks the C++ runtime only when asked to since 6.0.6 and has always ignored-lstdc++, so on Emscripten the C++ standard library flag is now-sDEFAULT_TO_CXX=1; without itlean.jslinks but fails to start, with 109 unresolved C++ runtime imports.-sharedbuilds a real side module since 6.0 instead of an object file, solean.jsnow depends on the static archives it links instead of on the dummylibInit_shared.so,libleanshared_1.so,libleanshared_2.soandlibleanshared.so, whose recipes no longer run; as the dummies are touched on every build, this also stopsmake installfrom relinkinglean.js, which took nine minutes of the job. Since 4.0.11 Emscripten's compiler-rt bundles LLVM's profiling runtime, which a main module links whole, so everylean.jsrun wrote adefault.profrawinto its working directory (emscripten-core/emscripten#28123);lean_mainnow points that runtime at/dev/null.The Emscripten
-ssettings are now passed only when linking, which removes the 147linker setting ignored during compilationwarnings, use the-sKEY=VALUEspelling, and no longer includeLINKABLE, whichMAIN_MODULE=1implies and Emscripten deprecated in 4.0.15.doc/make/emscripten.md, which still described the Lean 3lean_js_jsandlean_js_wasmtargets, now describes the WebAssembly build as the CI job runs it and is linked fromdoc/make/index.md.This PR is stacked on #16135 and carries its commits until that PR merges; it will be rebased onto master afterwards. Until then, the diff of this PR alone is basvandijk:wasm-ci...basvandijk:wasm-emsdk-6.
Claude Code, an AI coding assistant, helped with the investigation, the changes, the testing and this description. I reviewed and checked them.
🤖 Generated with Claude Code