Skip to content

Commit b3d3e88

Browse files
committed
fix: add target-specific libc++ include path for --no-default-config
When bypassing clang++.cfg with --no-default-config, we must provide both libc++ include paths that the cfg originally supplied: -isystem <llvmRoot>/include/c++/v1 -isystem <llvmRoot>/include/<triple>/c++/v1 The target-specific path contains __config_site which is required by __config. Without it, std module precompilation fails with '__config_site' file not found.
1 parent 0f8d0e8 commit b3d3e88

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

src/build/flags.cppm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ CompileFlags compute_flags(const BuildPlan& plan) {
102102
auto libcxxInclude = llvmRoot / "include" / "c++" / "v1";
103103
sysroot_flag = " --no-default-config";
104104
sysroot_flag += " -isystem" + escape_path(libcxxInclude);
105+
// Target-specific libc++ headers (e.g. __config_site) live under
106+
// include/<triple>/c++/v1/. Add if present.
107+
if (!plan.toolchain.targetTriple.empty()) {
108+
auto targetInclude = llvmRoot / "include"
109+
/ plan.toolchain.targetTriple / "c++" / "v1";
110+
if (std::filesystem::exists(targetInclude))
111+
sysroot_flag += " -isystem" + escape_path(targetInclude);
112+
}
105113
if (!plan.toolchain.sysroot.empty())
106114
sysroot_flag += " --sysroot=" + escape_path(plan.toolchain.sysroot);
107115
else if (auto sdk = mcpp::platform::macos::sdk_path())

src/toolchain/stdmod.cppm

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ std::expected<StdModule, StdModError> ensure_built(
109109
auto libcxxInclude = llvmRoot / "include" / "c++" / "v1";
110110
sysroot_flag = " --no-default-config";
111111
sysroot_flag += std::format(" -isystem'{}'", libcxxInclude.string());
112+
// Target-specific libc++ headers (e.g. __config_site) live under
113+
// include/<triple>/c++/v1/. Add if present.
114+
if (!tc.targetTriple.empty()) {
115+
auto targetInclude = llvmRoot / "include"
116+
/ tc.targetTriple / "c++" / "v1";
117+
if (std::filesystem::exists(targetInclude))
118+
sysroot_flag += std::format(" -isystem'{}'", targetInclude.string());
119+
}
112120
if (!tc.sysroot.empty())
113121
sysroot_flag += std::format(" --sysroot='{}'", tc.sysroot.string());
114122
else if (auto sdk = mcpp::platform::macos::sdk_path())

0 commit comments

Comments
 (0)