Skip to content

Commit 0c1c2da

Browse files
committed
fix(windows): 栈探针从 compiler-rt 取,它是 .S 所以被 *.c 的 glob 漏掉了
编译器在足够大的帧之前发 ___chkstk_ms 的调用,而在这个格式上那是**编译器运行时** 的例程,不是 C 库的。compiler-rt 有它,在架构自己的目录里:x86_64/chkstk.S。 ⚠️ 实测 2026-08-22,openkal-musl 那侧把 -lgcc 从这个格式的链接线上拿掉之后 —— 那个归档是 GCC 的,它一直在悄悄供给这个符号给一条编译器是 clang 的链接: ld.lld: error: undefined symbol: ___chkstk_ms ⚠️ 只取这一个文件而不是整个目录:x86_64/ 里还有 floatdidf.c 等,上面的通用列表 已经供给了它们,整目录会让每个都定义两遍。
1 parent a54156d commit 0c1c2da

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

mcpp.toml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,24 @@ sources = [
291291
# block found the same wall at `_tlv_bootstrap`, which is why this line is a
292292
# copy of that one rather than a new idea.
293293
"llvm/compiler-rt/lib/builtins/emutls.c",
294+
# ⭐ THE STACK PROBE, AND IT IS `.S` RATHER THAN `.c` — WHICH IS WHY THE GLOB
295+
# ABOVE MISSES IT.
296+
#
297+
# The compiler emits a call to `___chkstk_ms` before a frame large enough to
298+
# skip a guard page, and on this format that is a routine of the compiler's
299+
# runtime rather than of the C library. compiler-rt has it, in the
300+
# architecture's own directory: `x86_64/chkstk.S`.
301+
#
302+
# ⚠️ Measured 2026-08-22, after `-lgcc` came off `openkal-musl`'s link line for
303+
# this format — that archive is GCC's, and it had been quietly supplying this
304+
# to a link whose compiler is clang:
305+
#
306+
# ld.lld: error: undefined symbol: ___chkstk_ms
307+
#
308+
# ⚠️ ONE FILE FROM THAT DIRECTORY AND NOT THE DIRECTORY. `x86_64/` also holds
309+
# `floatdidf.c` and its neighbours, which the generic list above already
310+
# supplies; taking the whole directory would define each of them twice.
311+
"llvm/compiler-rt/lib/builtins/x86_64/chkstk.S",
294312
"!llvm/compiler-rt/lib/builtins/atomic*.c",
295313
"!llvm/compiler-rt/lib/builtins/clear_cache.c",
296314
# ⚠️ AND THE EXCLUSION IS DELETED RATHER THAN LEFT BELOW THE INCLUSION — an

0 commit comments

Comments
 (0)