Skip to content

Commit 2208efc

Browse files
committed
fix(asio): pin ASIO_HAS_THREADS for the llvm-on-Windows toolchain
With the symlink-free archive in place, the Windows job progressed to runtime failures: core and network crashed with 0xC0000409 and coroutine exited 1 while the thread-free tests (experimental/platform/surface) passed. Reproduced under mingw+wine: asio's thread detection keys off CRT macros (_MT/_REENTRANT/_POSIX_THREADS) the toolchain does not define, so it silently selects null_thread and the steady_timer wait thread throws operation_not_supported (10045, 'thread: asio.system error'). Pin ASIO_HAS_THREADS in the default standalone feature. asio only tests defined(ASIO_HAS_THREADS) and POSIX pthread selection still runs beneath it, so this is a no-op where detection already works. All six consumer tests pass under mingw+wine with the pin (platform's pipe path is a wine limitation, passes on real Windows), and the Linux member suite passes 6/6 cold with the define present in every consumer TU's compile command.
1 parent 3bb23bd commit 2208efc

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

.agents/docs/2026-07-17-add-asio-plan.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,18 @@ The default `standalone` feature contributes these public preprocessor defines:
8484

8585
- `ASIO_STANDALONE`;
8686
- `ASIO_HEADER_ONLY`;
87-
- `ASIO_DISABLE_BOOST_CONTEXT_FIBER`.
87+
- `ASIO_DISABLE_BOOST_CONTEXT_FIBER`;
88+
- `ASIO_HAS_THREADS` — asio's own thread detection keys off CRT macros
89+
(`_MT`/`_REENTRANT`/`_POSIX_THREADS`) that the workspace's llvm-on-Windows
90+
toolchain does not define. Without the pin asio silently selects
91+
`null_thread` and every internal-thread operation (notably the
92+
waitable-timer wait thread behind `steady_timer`) throws
93+
`operation_not_supported` (10045) at runtime — observed as the core,
94+
coroutine, and network consumer tests failing on the Windows runner while
95+
the thread-free tests passed. asio only ever tests
96+
`defined(ASIO_HAS_THREADS)`, and the POSIX pthread selection still runs
97+
beneath it, so the pin is a no-op on platforms where detection already
98+
works (re-verified by the Linux consumer suite).
8899

89100
mcpp 0.0.94 accepts feature `defines` in the current xpkg parser and propagates
90101
them to consumers. The Asio surface test rejects builds where any of these

pkgs/c/compat.asio.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,23 @@ int mcpp_compat_asio_headers_anchor(void) { return 0; }
6363
targets = { ["asio"] = { kind = "lib" } },
6464
-- Explicitly pin the package's public configuration. `standalone` is a
6565
-- default feature so its defines propagate to every consumer TU.
66+
--
67+
-- ASIO_HAS_THREADS: asio's own thread detection keys off CRT macros
68+
-- (_MT/_REENTRANT/_POSIX_THREADS) that the workspace's llvm-on-Windows
69+
-- toolchain does not define, so asio silently selects null_thread and
70+
-- every internal-thread operation (e.g. the waitable-timer wait thread)
71+
-- throws operation_not_supported (10045) at runtime. All supported
72+
-- targets are multithreaded; pin the detection result. asio only ever
73+
-- tests defined(ASIO_HAS_THREADS), and on POSIX the pthread selection
74+
-- below it still runs, so this is a no-op where detection already works.
6675
features = {
6776
["default"] = { implies = { "standalone" } },
6877
["standalone"] = {
6978
defines = {
7079
"ASIO_STANDALONE",
7180
"ASIO_HEADER_ONLY",
7281
"ASIO_DISABLE_BOOST_CONTEXT_FIBER",
82+
"ASIO_HAS_THREADS",
7383
},
7484
},
7585
},

0 commit comments

Comments
 (0)