From b81892b7235d7f5261967b57d0069e2b79ec93e7 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Mon, 21 Sep 2026 05:30:55 +0800 Subject: [PATCH] register openkal-llvm-runtime 0.15.0 `thread_local` destructors run, on every target this package builds for. The defect had three layers and the first two fail differently, which is why fixing only the first would have been worse than leaving it: 1. EXPORT. Upstream libc++abi exports `__cxa_thread_atexit` on Linux and Fuchsia only, because elsewhere another runtime already does --- an ordinary MinGW target gets it from `libmingw32.a`. openkal replaces the C library and its runtime together, so both sides assumed the other would. `doctest` and `spdlog` in this repository's own compatibility suite stop at `ld.lld: error: undefined symbol: __cxa_thread_atexit`. 2. STORAGE. With the guard open the link succeeded AND NOTHING WAS DESTROYED. The fallback keeps its pending-destructor list in a `__thread` variable; this runtime is built with `-femulated-tls` for PE, and emutls keeps its per-thread blocks behind a pthread key of its own whose destructor had already released this thread's block. Measured under wine, one thread: registered dtor, dtors=0x7ffffe994680, &dtors=0x7ffffe9946a8 run_dtors called, dtors=0, &dtors=0x7ffffe9946c8 The list now lives in the TLS key's own value, which no other key's teardown can reach. 3. APPLE. Surfaced by the criterion written for layer two: clang lowers a `thread_local` with a destructor to `_tlv_atexit` on Mach-O, and then the weak-symbol probe for `__cxa_thread_atexit_impl` --- an ELF idiom ld64 does not honour in a static link --- became the error itself. Criterion, two conditions and neither sufficient, in `examples/cxx` on x86_64-linux-gnu and x86_64-windows-gnu (wine), `failures: 0`: ok: a thread_local is constructed in a spawned thread ok: and its destructor runs when that thread ends Cross-verified against mcpp 2026.9.21.2 before that engine merged: five jobs green, including both host-dimension rows. Registration only; nothing is re-pinned onto it by this change. --- pkgs/o/openkal-llvm-runtime.lua | 37 +++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/pkgs/o/openkal-llvm-runtime.lua b/pkgs/o/openkal-llvm-runtime.lua index 83ecc978..4e39047f 100644 --- a/pkgs/o/openkal-llvm-runtime.lua +++ b/pkgs/o/openkal-llvm-runtime.lua @@ -27,6 +27,22 @@ -- favour of definitions the package's own manifest now gives per target -- (design ยง3.4). Neither the release nor its sha256 exist yet -- this -- comment marks the entry as prepared and blocked, not as data to invent. +-- 0.15.0 makes `thread_local` destructors run. Upstream libc++abi exports +-- `__cxa_thread_atexit` on Linux and Fuchsia only, because elsewhere another +-- runtime already does --- `libmingw32.a` on an ordinary MinGW target. openkal +-- replaces the C library and its runtime together, so both sides assumed the +-- other would: `doctest` and `spdlog` stopped at `undefined symbol` on +-- x86_64-windows-gnu. +-- +-- EXPORTING IT WAS NOT ENOUGH. The fallback kept its pending-destructor list +-- in a `__thread` variable, and this runtime is built with `-femulated-tls` +-- for PE; emutls releases the thread's block behind a key of its own, before +-- the key that walks the list. Measured: `&dtors` differs between +-- registration and the destructor, in one thread. The list now lives in the +-- TLS key's own value. A third layer surfaced on Apple, where clang lowers to +-- `_tlv_atexit` and the weak-symbol probe is an ELF idiom ld64 does not +-- honour. +-- -- 0.14.0 reads `__MCPP_TARGET_WINDOWS__` in `__libunwind_config.h`, the -- INSTALLED header that sizes `unw_context_t` by the target's register save -- area, keeping `|| defined(__CYGWIN__)` beside it. Two operands cover every @@ -51,6 +67,13 @@ package = { xpm = { linux = { + ["0.15.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.15.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/openkal-llvm-runtime/releases/download/0.15.0/openkal-llvm-runtime-0.15.0.tar.gz", + }, + sha256 = "acd3a54fe6dca5504a6751c3fc1543a1d3f4c26bf6e142e15ac8fd90d8bee496", + }, ["0.14.0"] = { url = { GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.14.0.tar.gz", @@ -228,6 +251,13 @@ package = { }, }, macosx = { + ["0.15.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.15.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/openkal-llvm-runtime/releases/download/0.15.0/openkal-llvm-runtime-0.15.0.tar.gz", + }, + sha256 = "acd3a54fe6dca5504a6751c3fc1543a1d3f4c26bf6e142e15ac8fd90d8bee496", + }, ["0.14.0"] = { url = { GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.14.0.tar.gz", @@ -405,6 +435,13 @@ package = { }, }, windows = { + ["0.15.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.15.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/openkal-llvm-runtime/releases/download/0.15.0/openkal-llvm-runtime-0.15.0.tar.gz", + }, + sha256 = "acd3a54fe6dca5504a6751c3fc1543a1d3f4c26bf6e142e15ac8fd90d8bee496", + }, ["0.14.0"] = { url = { GLOBAL = "https://github.com/mcpplibs/openkal-llvm-runtime/archive/refs/tags/0.14.0.tar.gz",