Skip to content

Commit 5a0d70e

Browse files
committed
fix: align ARM64 host std modules with compiler runtime selection
1 parent b67e928 commit 5a0d70e

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

‎.agents/docs/2026-10-08-llvm-2313-part2-execution-and-dependencies.md‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,3 +297,29 @@ SubOS、GNU 默认构建、打包部署、四个索引成员及 openkal;三个
297297
交叉产物由对应目标 runner 实际运行。sandbox backend 明确记录
298298
为发行版 CI 基础设施,不冒充索引尚未交付的 ARM64 backend 包。
299299
该工作流须待正式发布、镜像与索引就绪后执行。
300+
301+
## 14. 2026-10-08 原生 GNU 完整通过与 openkal 宿主模块更正
302+
303+
提交 b67e9283 的原生候选门通过 GNU 自举、完整单测 147/147、
304+
804 的 LLVM 宿主工具案例及 cjson、sqlite3、fmtlib.fmt、nlohmann.json
305+
四个真实索引成员。此前 ELF 动态导出与显式 GCC 请求的载荷映射
306+
失败均已消除。最后的 openkal 原生门仍失败:openkal-musl 的
307+
build.mcpp 导入宿主 std.pcm 时,Clang 报目标特征 `-fmv` 不一致。
308+
这不是目标 musl 源码缺失,也不作为资源或基础设施豁免。
309+
310+
宿主 std PCM 只使用 host_compile_tokens;build.mcpp 在同一次
311+
驱动调用中组合 host_compile_tokens 与 host_link_tokens。后者的
312+
`--rtlib=compiler-rt` 在 AArch64 还影响代码生成特征,因此此前
313+
两者的配置不同。现由 cfg bypass 且使用 payload C++ runtime
314+
的共享编译参数生产者同时声明这一运行时选择,使 std PCM 与
315+
宿主程序一致。图供应的目标 runtime、SDK sysroot、GCC、x86
316+
及信任 cfg 的路径保持各自选择;未向宿主导入目标平台参数。
317+
新版缓存身份从实际 std 构建命令导出,无须复用配置不相容的 PCM。
318+
完整原生门及 openkal 生态消费仍须新提交验证。
319+
320+
共享生产者的 HostFlags 聚焦单测 29/29 通过。实际 ARM64 std.cppm
321+
对照使用受管 libc++、glibc 与 UAPI 头文件:旧 PCM 构建成功,但
322+
带 compiler-rt 的导入者重现 FMV/outline-atomics 不一致;两边统一
323+
后,PCM、std 对象与同一导入者均编译成功,并以候选 ARM64 运行时
324+
链接后在 QEMU 下运行成功。该结果验证配置一致性的根因修复,
325+
原生 openkal 全量构建仍作为独立准入门。

‎src/toolchain/hostflags.cppm‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,12 @@ std::vector<std::string> host_compile_tokens(const Toolchain& tc,
411411
if (bypassCfg && !graphSuppliesTarget && cxxFromPayload) {
412412
for (auto& t : dm.compile_tokens(esc, opt.clangStdlibSelect))
413413
out.push_back(t);
414+
// On AArch64 the runtime choice changes FMV/outline-atomics codegen.
415+
// The std BMI must match a one-shot host compile/link, whose link
416+
// tokens select compiler-rt after the same cfg bypass.
417+
if (auto target = triple::parse(tc.targetTriple);
418+
target && target->arch == "aarch64")
419+
out.emplace_back("--rtlib=compiler-rt");
414420
} else if (bypassCfg) {
415421
// THE BYPASS IS NOT PART OF THE PAYLOAD'S HEADER SET, AND IT WAS
416422
// BEING SUPPRESSED WITH IT.

‎tests/unit/test_hostflags.cpp‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,16 @@ TEST(HostFlags, TheCxxLayerDecidesWhoseLibcxxHeadersAreEmitted) {
706706
const auto a = mcpp::toolchain::host_compile_tokens(tc, payload, mcpp::toolchain::no_escape);
707707
EXPECT_TRUE(any_payload_cxx(a));
708708
EXPECT_TRUE(has(a, "-nostdinc++"));
709+
EXPECT_FALSE(has(a, "--rtlib=compiler-rt"));
710+
711+
// Runtime selection affects AArch64 PCM compatibility even on a compile
712+
// without a link. The host std producer and one-shot helper must agree.
713+
auto arm = tc;
714+
arm.targetTriple = "aarch64-linux-gnu";
715+
auto armCompile = mcpp::toolchain::host_compile_tokens(arm, payload, mcpp::toolchain::no_escape);
716+
auto armLink = mcpp::toolchain::host_link_tokens(arm, payload, mcpp::toolchain::no_escape);
717+
EXPECT_TRUE(has(armCompile, "--rtlib=compiler-rt"));
718+
EXPECT_TRUE(has(armLink, "--rtlib=compiler-rt"));
709719

710720
// A graph C++ runtime over the same prebuilt C library: the payload's
711721
// headers are withheld and the driver's own search is closed, since the
@@ -716,6 +726,10 @@ TEST(HostFlags, TheCxxLayerDecidesWhoseLibcxxHeadersAreEmitted) {
716726
EXPECT_FALSE(any_payload_cxx(b));
717727
EXPECT_TRUE(has(b, "-nostdinc++"));
718728
EXPECT_TRUE(has(b, "--no-default-config"));
729+
// A graph owns its runtime/codegen broadcast; payload selection must not
730+
// be introduced merely because the target architecture is AArch64.
731+
EXPECT_FALSE(has(mcpp::toolchain::host_compile_tokens(arm, graph, mcpp::toolchain::no_escape),
732+
"--rtlib=compiler-rt"));
719733

720734
// An Apple cross target whose runtime is the SDK's libc++ and whose graph
721735
// does not import `std`: prepare chose the SDK's headers, named

0 commit comments

Comments
 (0)