fix: add missing release() and adopt_lock_t to single-threaded unique_lock stub#13233
Open
kjsdesigns wants to merge 1 commit intoleanprover:masterfrom
Open
fix: add missing release() and adopt_lock_t to single-threaded unique_lock stub#13233kjsdesigns wants to merge 1 commit intoleanprover:masterfrom
kjsdesigns wants to merge 1 commit intoleanprover:masterfrom
Conversation
…_lock stub When building with LEAN_MULTI_THREAD undefined (required for Emscripten/ WASM targets), the stub unique_lock<T> in thread.h is missing: - release() — called by runtime code, causes compile error - unique_lock(T const &, std::adopt_lock_t) — required by code that acquires a lock before constructing the unique_lock The real std::unique_lock provides both. The stub should too. Discovered while building Lean4 to WASM via Emscripten for a production project (specify-lean) since v4.27.0. The fix has been proven stable across multiple Lean version bumps.
|
Mathlib CI status (docs):
|
Collaborator
|
Reference manual CI status:
|
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.
Problem
When building with
LEAN_MULTI_THREADundefined (required for Emscripten/WASM targets), the stubunique_lock<T>insrc/runtime/thread.his missing two members that the realstd::unique_lockprovides:release()— called by runtime code paths, causes a compile error when the stub is activeunique_lock(T const &, std::adopt_lock_t)— required by code that acquires a lock before constructing theunique_lockThe other stubs in this file (
mutex,lock_guard,condition_variable) are complete; onlyunique_lockis missing API surface.Fix
Add the two missing members to the single-threaded
unique_lockstub:Both are no-ops, matching the semantics of a single-threaded environment.
release()returnsnullptr(no mutex to release). Theadopt_lock_tconstructor is a no-op (no lock to adopt).Evidence
I've been using this fix in a production project (specify-lean) since v4.27.0 to build the Lean4 runtime to WASM via Emscripten. The fix has been stable across multiple Lean version bumps.
I posted about this on Zulip on 2026-03-21.