Skip to content

Commit 774b827

Browse files
committed
fix: include MSVC effective triple in fingerprint (Windows)
Clang on Windows auto-detects the MSVC version at compile time and embeds it in module AST files (e.g. x86_64-pc-windows-msvc19.44.35227). But -dumpmachine returns just x86_64-pc-windows-msvc (no version). When MSVC updates a patch version (35226 → 35227), the fingerprint didn't change, so mcpp reused cached std.pcm compiled for the old version → "AST file was compiled for different target" error. Fix: probe clang's -print-effective-triple which includes the MSVC version, and append to driverIdent for fingerprint computation. Also: ensure sysroot complete by symlinking linux kernel headers from payload xpkgs into the GCC sysroot directory.
1 parent a2b18b8 commit 774b827

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/toolchain/detect.cppm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ detect(const std::filesystem::path& explicit_compiler) {
6969
tc.targetTriple = *triple;
7070
}
7171

72+
#if defined(_WIN32)
73+
// On Windows, Clang targeting MSVC auto-detects the MSVC version at
74+
// compile time and bakes it into the module AST. The -dumpmachine triple
75+
// doesn't include this version, so fingerprints don't change when MSVC
76+
// patches (e.g. 19.44.35226 → 35227), causing stale BMI cache hits.
77+
// Query the effective triple which includes the actual MSVC version.
78+
if (tc.compiler == CompilerId::Clang
79+
&& tc.targetTriple.find("msvc") != std::string::npos) {
80+
auto vr = run_capture(std::format(
81+
"{}{} -print-effective-triple 2>NUL",
82+
envPrefix,
83+
mcpp::xlings::shq(tc.binaryPath.string())));
84+
if (vr) {
85+
auto effective = trim_line(*vr);
86+
if (!effective.empty() && effective != tc.targetTriple)
87+
tc.driverIdent += "\neffective-triple: " + effective;
88+
}
89+
}
90+
#endif
91+
7292
if (tc.compiler == CompilerId::GCC) {
7393
mcpp::toolchain::gcc::enrich_toolchain(tc);
7494
} else if (tc.compiler == CompilerId::Clang) {

0 commit comments

Comments
 (0)