Skip to content

Commit 2cb595d

Browse files
committed
fix: 判据改用 MCPP_TARGET_REQUESTED —— MCPP_TARGET 从不为空
ld64.lld: error: undefined symbol: wcslen / strtoul / __error (本包自己的 conformance,本机 macOS) MCPP_TARGET 在没给 --target 时用宿主填上,所以「非空」恒真,于是这个 stub 上了一条 **本机**链接线,而那里 SDK 完整的那份本来就在,我们这份把它遮蔽了。 MCPP_TARGET_REQUESTED 是同一个值未被填充的形态:恰好在这是一次普通本机构建时为空。 ⭐ 太旧而不设这个变量的 mcpp 会读到空,而那对它是正确答案:它没有「目标侧来自图」 这回事,系统永远在链接线上。 本机双向复验:交叉到 aarch64-macos 供给 stub 并产出;用已发布的 2026.8.19.1 走本机 路径构建本包,不供给,通过。
1 parent 2468170 commit 2cb595d

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

build.mcpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,22 @@ int main() {
7474
// the only thing that can name one. When it was not — a native build, which
7575
// is what this package's own conformance suite does — the SDK is on the
7676
// link and is the complete answer.
77-
const char* target = std::getenv("MCPP_TARGET");
78-
if (target && *target)
77+
// ⚠️ `MCPP_TARGET_REQUESTED` AND NOT `MCPP_TARGET`. The second is filled in
78+
// with the host when nobody named a target, so it is never empty and the
79+
// test was always true — which put this stub on a NATIVE link, where the
80+
// SDK's complete one was already there and ours shadowed it:
81+
//
82+
// ld64.lld: error: undefined symbol: wcslen / strtoul / __error
83+
//
84+
// The first is the value unfilled: empty exactly when this is an ordinary
85+
// native build. See mcpp's `build_program.cppm` for why the two are
86+
// different questions even when the triples are equal.
87+
//
88+
// ⭐ An mcpp too old to set it leaves it empty, and that is the right answer
89+
// for such a build tool: it has no graph-supplied target side, so the
90+
// system is always on the link.
91+
const char* requested = std::getenv("MCPP_TARGET_REQUESTED");
92+
if (requested && *requested)
7993
mcpp::link_search("port");
8094
mcpp::rerun_if_changed("port/libSystem.tbd");
8195
return 0;

0 commit comments

Comments
 (0)