From 5ef1ab2a254a2c07f36cb3922c7488d713f15879 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Mon, 16 Nov 2026 07:30:36 +0100 Subject: [PATCH] fix(pace-cc): leave the machine's /usr/include out of a GNU toolchain's fingerprint Two Fedora 44 machines with identical compiler rpms (`rpm -V` clean) computed a different fingerprint for every toolchain -- g++ and gcc 16.2.1, clang 22.1.8, clang 20.1.8 -- so the fleet never dispatched between them. Banners, include-root lists and every compiler-owned tree were byte-identical; what differed was /usr/local/include (136 vs 8 files of hand installs) and /usr/include (12853 vs 13032 files, 137 vs 109 -devel packages). The fingerprint folded every root of the driver's `-v` search list, so it identified which LIBRARIES were installed beside the compiler rather than the compiler. Those trees cannot change a dispatched compile's object: the worker compiles text the client already preprocessed, as `-x c++-cpp-output` / `-x cpp-output`, and strace of a clean such compile under gcc 16.2, clang 22.1 and clang 20.1, C and C++, opens nothing beneath either directory (no stdc-predef.h pre-include on preprocessed input). gcc does open a header beneath them when a diagnostic note points into it, only to print the source excerpt; that reaches stderr, never the object. The cache key hashes the preprocessed text and does not fold the fingerprint at all, so no key relied on these trees. The GNU rows (`FingerprintTree::OwnTreeWhenTargetingMsvc`, renamed `OwnTrees`) now drop the roots in `SystemIncludeDirectories` -- /usr/local/include and /usr/include -- recognised by EQUALITY of what they RESOLVE to through a new `IToolchainHost::ResolveDirectory`, never by spelling and never by containment: libstdc++ resolves to /usr/include/c++/16, nested under a dropped root, and stays folded with the compiler's resource directory. Erring narrow: an unresolvable root, any root on a drive-relative host, a sysroot's usr/include, and Debian and Ubuntu's /usr/include/ stay folded -- so on Debian/Ubuntu two machines still need matching -dev sets (#1783). Discovery, the stamp and the node's evidence are unchanged. FingerprintSchema moves to toolchain-v4. A v3 node and a v4 node match nothing until both are upgraded. An operator's pinned `--toolchain==` is never re-derived, so a pin written under v3 silently matches nothing after the upgrade: re-derive it (`pace-cc --print-toolchain-fingerprint `) or remove it. No objkey-v*/manifest-v* bump, since no key folds the fingerprint. Measured with this build's `pace-cc --print-toolchain-fingerprint` on both machines: /usr/bin/{g++,gcc,clang,clang++,clang-20} fingerprint identically. Refs #1783 Signed-off-by: Christian Parpart --- .agent/rules/compile-cache.md | 3 + .agent/rules/distributed-compilation.md | 21 ++- AGENT.md | 6 +- .../distributed-compilation.md | 8 +- docs/how-it-works.md | 14 +- docs/tools/pace-node.md | 23 ++- .../CompileCache/ToolchainFingerprint.hpp | 12 +- src/Pace/Distributed/FingerprintDiff_test.cpp | 3 +- src/apps/pace-cc/CmdLine.cpp | 17 +- src/apps/pace-cc/CmdLine.hpp | 25 ++- src/apps/pace-cc/ToolchainHost.cpp | 25 +++ src/apps/pace-cc/ToolchainHost.hpp | 14 ++ src/apps/pace-cc/ToolchainHostTestUtils.hpp | 27 +++ src/apps/pace-cc/ToolchainHost_test.cpp | 43 +++++ src/apps/pace-cc/ToolchainProbe.cpp | 53 ++++-- src/apps/pace-cc/ToolchainProbe.hpp | 63 ++++++- src/apps/pace-cc/ToolchainProbe_test.cpp | 172 ++++++++++++++++++ src/apps/pace-node/McpToolchainTools_test.cpp | 2 +- 18 files changed, 488 insertions(+), 43 deletions(-) diff --git a/.agent/rules/compile-cache.md b/.agent/rules/compile-cache.md index 3ea6846ef..a0071586c 100644 --- a/.agent/rules/compile-cache.md +++ b/.agent/rules/compile-cache.md @@ -196,6 +196,9 @@ same on both — the same defect with no MSVC anywhere near it. platform. `toolchain-v2` and `toolchain-cache-name-v2` moved together. `toolchain-v3` (#1656, which trees are folded) moved alone, because the stamp folds the schema since then, so a bump misses every older cache entry without renaming the file. + `toolchain-v4` (the machine's `/usr/include` and `/usr/local/include` dropped) + moved alone for the same reason; no `objkey-v*` or `manifest-v*` moves with a + fingerprint bump, because no cache key folds the fingerprint. - A test staging two different include trees would pass under the bug. The banner and the file list are held EQUAL and the grammar is the only difference, with the same-grammar case asserted beside it — a digest that separated everything would pass diff --git a/.agent/rules/distributed-compilation.md b/.agent/rules/distributed-compilation.md index 4aed66f84..40f15a399 100644 --- a/.agent/rules/distributed-compilation.md +++ b/.agent/rules/distributed-compilation.md @@ -3159,8 +3159,19 @@ Which tree a fingerprint walks is `DriverSpec::fingerprintTree`, a column, never on the driver: `cl` folds **none** (its banner names toolset and target, #195), a clang whose `-v` probe names a `*-windows-msvc*` target folds only its resource directory (the `gcc` row too, since a `cc` that IS such a clang reaches it by its stem), and every -other GNU driver keeps its whole `-v` list — libstdc++ IS read, and two machines -can differ in it under one `--version`. +other GNU driver keeps its `-v` list — libstdc++ IS read, and two machines +can differ in it under one `--version` — **except the machine's own `/usr/local/include` +and `/usr/include`** (`SystemIncludeDirectories`, `toolchain-v4`). Those are glibc and +every `-devel` package; a clean preprocessed compile opens neither (strace-measured under +gcc 16.2, clang 22.1 and 20.1, C and C++), and gcc reads a header beneath them only to +print a diagnostic's source excerpt, which reaches stderr and never the object. Folding +them split two Fedora boxes with identical compiler rpms on every toolchain. A root is +recognised by what it RESOLVES to (`IToolchainHost::ResolveDirectory`) and by EQUALITY, +never containment: libstdc++ resolves to `/usr/include/c++/`, NESTED under a dropped +root, and a prefix match would drop it on every real Linux host. A sysroot's `usr/include` +deliberately is not recognised, and neither is Debian's `/usr/include/` +(#1783): a root that cannot be classified stays folded, so the Fedora measurement is the +whole of the claim. - **That makes the banner the whole of `cl`'s identity, so a FALLBACK banner is `NoEvidence` under `cl` whatever its layout** — a row that folds no tree BY CONSTRUCTION is judged as having none, or #195's "every MSVC is `cl`" comes back behind @@ -4351,3 +4362,9 @@ translation unit and every test green. deduplicated across machines that share a cache, so the same compile can be admitted twice. - **[#1731](https://github.com/LASTRADA-Software/pace/issues/1731)** — admission test gaps deferred by the #1728 reviews. +- **[#1783](https://github.com/LASTRADA-Software/pace/issues/1783)** — a GNU toolchain's + fingerprint still folds Debian and Ubuntu's `/usr/include/` (kernel headers, + glibc's architecture bits, `-dev` packages' architecture headers), so two such machines + with one compiler still split on their `-dev` sets. `SystemIncludeDirectories` drops only + the native `/usr/include` and `/usr/local/include`, by resolved EQUALITY; recognising the + multiarch directory needs the driver's own name for it, and a clang triple is not it. diff --git a/AGENT.md b/AGENT.md index f60404239..224ede7e3 100644 --- a/AGENT.md +++ b/AGENT.md @@ -307,6 +307,7 @@ launcher's cache key is made of. Before `apps/pace-cc/`, `CompileCache/`. later edit wins by its recorded BASELINE, never by comparing clocks (`BudgetOverrideApplier`). - A node SERVES while it identifies its toolchains: the cheap half at startup, the walk on the heartbeat thread's first round, registering NOTHING until the fingerprint is real (`ToolchainSurvey` travels beside the map, no default). +- A GNU fingerprint drops the machine's `/usr/include` by RESOLVED EQUALITY, never containment: libstdc++ is NESTED there. - Fingerprint inputs are CAPTURED, never re-gathered: `FINGERPRINT-INPUTS` reads what the survey published; ONE capture walk per process runs on a thread of its own, and no request starts one. - A node never reports a child's `ru_maxrss` as a compile's peak (Linux folds the spawner's RSS into it): a @@ -1486,9 +1487,8 @@ wrong quantity**. Record a table of conditions, not a number. - **The receiver owes one thing back: state what would FALSIFY a claim BEFORE opening the file to check it**, or reading for confirmation stops at the first line that matches. **A relayed diagnosis is relayed code.** -- **It does NOT reach a measurement's CONDITIONS — pin those, do not point at them**, - and say *why* they are pinned, or the next cleanup reverses it: the corrected comment - looks like the defect. +- **It does NOT reach a measurement's CONDITIONS — pin those, do not point at them**, and say + *why* they are pinned, or the next cleanup reverses it: the corrected comment looks like the defect. All three, with the measurements that produced them, are in [`.agent/rules/compile-cache.md`](.agent/rules/compile-cache.md). diff --git a/docs/getting-started/distributed-compilation.md b/docs/getting-started/distributed-compilation.md index dc69aa2e1..eb344c6ef 100644 --- a/docs/getting-started/distributed-compilation.md +++ b/docs/getting-started/distributed-compilation.md @@ -861,7 +861,13 @@ on nothing but an installed Visual Studio language pack (#1656). `clang-cl`, and the driver names when asked (`-print-resource-dir`), because they borrow the VC toolset and the SDK rather than owning them — so two machines with different SDKs or VS languages installed still match. A clang targeting anything else -carries every directory its `-v` search list names, as GCC does. None of them +carries every directory its `-v` search list names, as GCC does — except the +machine's own `/usr/local/include` and `/usr/include`, which hold its libraries +(glibc, every `-devel` package, hand installs) rather than its compiler. On Fedora, +where this was measured, two machines therefore need the same compiler packages, +not the same `-devel` set. Debian and Ubuntu also list `/usr/include/`, +which is still folded, so there two machines still need matching `-dev` sets +([#1783](https://github.com/LASTRADA-Software/pace/issues/1783)). None of them derives its fingerprint from `INCLUDE`, which is set per developer command prompt and never inherited by a service — so a worker installed as a service matches the launchers that talk to it. diff --git a/docs/how-it-works.md b/docs/how-it-works.md index 687fe4b57..8ce68691f 100644 --- a/docs/how-it-works.md +++ b/docs/how-it-works.md @@ -286,7 +286,19 @@ machine fetches. the resource directory the driver names when asked (`-print-resource-dir`). They *borrow* the VC toolset and the SDK rather than owning them, so two machines with different SDKs or VS languages installed still match. A clang targeting anything - else carries every directory its `-v` search list names, as GCC does. + else carries every directory its `-v` search list names, as GCC does — except + the machine's own `/usr/local/include` and `/usr/include`. +- **GCC and clang** leave out the machine's own `/usr/local/include` and + `/usr/include`, wherever a leading `/` names the filesystem root (measured on + Fedora Linux only). Those hold glibc and the headers of every `-devel` package + and hand install on the machine, not the compiler, and a worker reads neither to + generate code for a preprocessed compile. Folded, they split two Fedora machines + with byte-identical compiler packages on which libraries each had installed. + libstdc++ and the compiler's own `include` directory stay in, as does a sysroot's + `usr/include` — and so does Debian and Ubuntu's `/usr/include/`, + which holds architecture-specific library headers, so two such machines still + need matching `-dev` sets + ([#1783](https://github.com/LASTRADA-Software/pace/issues/1783)). None of them reads `INCLUDE` for its fingerprint. That variable is set by a developer command prompt and is never inherited by a Windows service — so a worker diff --git a/docs/tools/pace-node.md b/docs/tools/pace-node.md index ef439729b..09540293f 100644 --- a/docs/tools/pace-node.md +++ b/docs/tools/pace-node.md @@ -444,7 +444,12 @@ change, so it costs the fleet no re-registration. Two consequences worth knowing. An operator's pinned `=` is **never** re-derived: it is not probed in the first place, and pinning a digest by -hand is how you force a fleet to agree while a machine is being repaired. And a +hand is how you force a fleet to agree while a machine is being repaired. A pin +is also never re-derived across an UPGRADE that changes how fingerprints are +computed: after moving to the `toolchain-v4` schema, a pin written under v3 +advertises a digest no client computes any more, and that toolchain is silently +never matched. Re-derive such a pin (`pace-cc --print-toolchain-fingerprint +`) or remove it. And a machine whose only compiler an upgrade removed or broke keeps running while serving nothing, rather than exiting — the compiler may come back with the next package, and a routine upgrade must not be able to take a machine out of the fleet permanently. @@ -520,7 +525,17 @@ IntelliSense XML lands in the toolset's `include` directory (#1656). So two Windows machines need the same compiler *version*, not the same SDK or the same Visual Studio languages. The banner names the target as well as the version — `... Version 19.51.36252 for x64` — which is what tells the x86 and x64 `cl.exe` -of one toolset apart. Matching is +of one toolset apart. Under GCC and Clang the machine's own `/usr/local/include` +and `/usr/include` are left out for the same reason: they hold glibc and every +`-devel` package and hand install, not the compiler. libstdc++ and the compiler's +own `include` directory stay in, and so does every other directory the driver +lists. On a distribution that keeps its architecture headers in `/usr/include` +itself — Fedora, where this was measured — two machines therefore need the same +compiler packages rather than the same set of libraries. Debian and Ubuntu also +list `/usr/include/` (kernel headers, glibc's architecture bits, the +architecture-specific headers of `-dev` packages), which is still folded, so +there two machines still need matching `-dev` sets +([#1783](https://github.com/LASTRADA-Software/pace/issues/1783)). Matching is byte-identical and cannot be loosened: an over-strict match costs a local compile, an over-loose one produces a silently wrong object that is then stored under a key other machines fetch. @@ -529,7 +544,9 @@ Computing it walks that tree, which takes a few seconds the first time a machine sees a toolchain and is cached afterwards. **Which tree, per driver.** GCC and Clang are asked directly (`-E -v`) and fold -every directory they list — libstdc++, an Xcode SDK. A Clang whose target is +every directory they list — libstdc++, an Xcode SDK — except the machine's own +`/usr/local/include` and `/usr/include`, recognised by the directory they resolve +to. A Clang whose target is `*-windows-msvc*` folds only its own resource directory, as `clang-cl` does (`-print-resource-dir`): `\lib\clang\\include`. `cl` folds **no** tree: its banner names its toolset version and target, and everything its layout diff --git a/src/Pace/CompileCache/ToolchainFingerprint.hpp b/src/Pace/CompileCache/ToolchainFingerprint.hpp index b614f26b7..5f009212e 100644 --- a/src/Pace/CompileCache/ToolchainFingerprint.hpp +++ b/src/Pace/CompileCache/ToolchainFingerprint.hpp @@ -57,7 +57,13 @@ struct ToolchainFile /// own resource directory (`FingerprintTree`), so the same toolchain digests /// differently under v2 and v3. The fingerprint cache's stamp folds this tag, so an /// entry written under v2 is a miss rather than a v2 value served as a v3 one. -inline constexpr std::string_view FingerprintSchema = "toolchain-v3"; +/// +/// v4: a GNU-family driver no longer folds the machine's own `/usr/local/include` and +/// `/usr/include` (`SystemIncludeDirectories` in the launcher), which split machines +/// with byte-identical compiler packages on which `-devel` packages each had installed. +/// The same toolchain digests differently under v3 and v4, so a v3 node and a v4 node +/// match nothing until both are upgraded -- the safe direction, a local compile. +inline constexpr std::string_view FingerprintSchema = "toolchain-v4"; /// Everything a toolchain fingerprint is computed from, as the digest saw it. /// @@ -133,7 +139,9 @@ struct FingerprintInputs /// BORROWS (the VC toolset and the Windows SDK, under `cl` and under any clang /// targeting MSVC) is never passed, because a worker opens no header from it for a /// preprocessed compile, and passing it split machines on an installed VS language -/// pack's IntelliSense XML (#1656). A banner alone is what the cache key +/// pack's IntelliSense XML (#1656). Nor is the machine's own `/usr/include` or +/// `/usr/local/include` under a GNU driver (v4): glibc and every `-devel` package, which +/// split machines on what was installed BESIDE the compiler. A banner alone is what the cache key /// already uses, and it is too weak here: two machines can print an identical /// `--version` while resolving different libstdc++ headers, and for *distribution* /// that produces a silently wrong object rather than the stale path a replay guard diff --git a/src/Pace/Distributed/FingerprintDiff_test.cpp b/src/Pace/Distributed/FingerprintDiff_test.cpp index eccfad08b..38c3de2f6 100644 --- a/src/Pace/Distributed/FingerprintDiff_test.cpp +++ b/src/Pace/Distributed/FingerprintDiff_test.cpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -153,7 +154,7 @@ TEST_CASE("Diff names a schema and a grammar difference as facts", "[distributed CHECK(diff.schemaDiffers); REQUIRE(diff.grammar.has_value()); CHECK(Unwrap(diff.grammar).second == "msvc"); - CHECK(diff.verdict.contains("the fingerprint schemas differ (toolchain-v3 vs toolchain-v2)")); + CHECK(diff.verdict.contains(std::format("the fingerprint schemas differ ({} vs toolchain-v2)", Cc::FingerprintSchema))); CHECK(diff.verdict.contains("the driver grammars differ (gnu vs msvc)")); CHECK_FALSE(diff.inferred); } diff --git a/src/apps/pace-cc/CmdLine.cpp b/src/apps/pace-cc/CmdLine.cpp index fbc29718f..fa2f78ffc 100644 --- a/src/apps/pace-cc/CmdLine.cpp +++ b/src/apps/pace-cc/CmdLine.cpp @@ -406,10 +406,12 @@ namespace // version string covers x86_64 and aarch64 alike, and an arch-independent // translation unit keys the same on both. .targetDiscovery = TargetDiscovery::GnuTargetLine, - // No gcc targets MSVC, so this keeps every root for gcc itself. It is the - // Clang row's answer because a `cc`/`c++` that IS an MSVC-targeting clang - // reaches this row by its stem, and must fingerprint as the Clang row does. - .fingerprintTree = FingerprintTree::OwnTreeWhenTargetingMsvc, + // No gcc targets MSVC, so for gcc itself this keeps every root but the + // machine's `/usr/local/include` and `/usr/include`: libstdc++ and gcc's own + // `include` stay folded. It is the Clang row's answer because a `cc`/`c++` + // that IS an MSVC-targeting clang reaches this row by its stem, and must + // fingerprint as the Clang row does. + .fingerprintTree = FingerprintTree::OwnTrees, .dispatchMacros = DispatchMacros::Expanded, .includeProbeFlags = GnuIncludeProbe, .targetProbeFlags = GnuTargetProbe, @@ -428,9 +430,10 @@ namespace .targetDiscovery = TargetDiscovery::ClangDriverLine, // On Windows its `-v` list is clang's resource directory plus the VC // toolset and the SDK it borrows, which it is identified without, as - // `clang-cl` is; anywhere else the list is libstdc++ or an SDK it reads, - // and stays folded (#1656). - .fingerprintTree = FingerprintTree::OwnTreeWhenTargetingMsvc, + // `clang-cl` is (#1656); anywhere else the list is libstdc++ or an SDK it + // reads, and stays folded -- all but the machine's own `/usr/local/include` + // and `/usr/include`, which hold its libraries rather than its compiler. + .fingerprintTree = FingerprintTree::OwnTrees, .dispatchMacros = DispatchMacros::Expanded, .includeProbeFlags = GnuIncludeProbe, .targetProbeFlags = GnuTargetProbe, diff --git a/src/apps/pace-cc/CmdLine.hpp b/src/apps/pace-cc/CmdLine.hpp index 320558fb5..908743711 100644 --- a/src/apps/pace-cc/CmdLine.hpp +++ b/src/apps/pace-cc/CmdLine.hpp @@ -230,19 +230,30 @@ enum class FingerprintTree : std::uint8_t /// discovery finds -- the toolset it lives in, the newest SDK -- is one a worker /// never opens for a dispatched compile. None, - /// The driver's own resource directory when it targets MSVC, exactly as - /// `clang-cl` is identified -- and every discovered root otherwise. A GNU-grammar - /// clang on Windows lists the VC toolset and the SDK in its `-v` search list; on - /// Linux it lists libstdc++, which it does read, and that stays folded. Decided by - /// the target the include probe's own output names, so it costs no spawn on a - /// driver that targets anything else. + /// The trees the toolchain OWNS, out of a GNU-family `-v` search list. + /// + /// When the driver targets MSVC, its own resource directory, exactly as `clang-cl` + /// is identified: a GNU-grammar clang on Windows lists the VC toolset and the SDK + /// it borrows. Decided by the target the include probe's own output names, so it + /// costs no spawn on a driver that targets anything else. + /// + /// Otherwise every discovered root but the MACHINE's own include directories -- + /// `SystemIncludeDirectories`, `/usr/local/include` and `/usr/include`, recognised + /// by what they resolve to. Those hold glibc and every `-devel` package and hand + /// install, never the compiler, so two machines with one compiler package split on + /// which libraries were installed beside it. libstdc++ and the compiler's resource + /// directory are listed as roots of their own and stay folded, as does any root + /// that cannot be classified. A SYSROOT's `usr/include` is deliberately not + /// recognised: a driver reads more of a sysroot than its headers -- Apple clang + /// derives `-target-sdk-version` from the SDK's `SDKSettings.json` -- so its tree + /// is the only evidence of which SDK a worker would compile against. /// /// The `gcc` row carries it too, although no gcc targets MSVC. One binary reaches /// both rows -- the node and `--print-toolchain-fingerprint` classify a driver by /// its STEM, the launcher corrects that by its banner, and both share one cache /// file per grammar -- so a `cc` that is really an MSVC-targeting clang must /// fingerprint alike under either row, or a worker and its clients split. - OwnTreeWhenTargetingMsvc, + OwnTrees, }; /// True when two family sets overlap. diff --git a/src/apps/pace-cc/ToolchainHost.cpp b/src/apps/pace-cc/ToolchainHost.cpp index 36a85bc53..586424f01 100644 --- a/src/apps/pace-cc/ToolchainHost.cpp +++ b/src/apps/pace-cc/ToolchainHost.cpp @@ -219,6 +219,31 @@ namespace return std::filesystem::is_directory(*directory, ec) && !ec; } + std::optional ResolveDirectory(std::string_view path) override + { + auto const opened = PathFromNarrowText(path); + if (!opened.has_value()) + return std::nullopt; + + // `canonical`, never `weakly_canonical`: a path that does not exist must be no + // answer rather than its own lexical normalization, or two missing spellings + // that normalize alike would be reported as one directory. + std::error_code ec; + auto const resolved = std::filesystem::canonical(*opened, ec); + if (ec || !std::filesystem::is_directory(resolved, ec) || ec) + return std::nullopt; + + // `PathBytes`, never `generic_string()`, which THROWS on Windows for a name + // holding an unpaired surrogate. The native separator is then folded to `/` + // by hand, which is all `generic_string()` added -- and only where it IS a + // separator: on POSIX a `\` is a byte of a name, and folding it would make + // `/usr\include` the same directory as `/usr/include`. + auto bytes = PathBytes(resolved); + if constexpr (std::filesystem::path::preferred_separator != '/') + std::ranges::replace(bytes, static_cast(std::filesystem::path::preferred_separator), '/'); + return bytes; + } + bool ExecutableExists(std::string_view path) override { auto const opened = PathFromNarrowText(path); diff --git a/src/apps/pace-cc/ToolchainHost.hpp b/src/apps/pace-cc/ToolchainHost.hpp index 1917f628d..67dc40e1b 100644 --- a/src/apps/pace-cc/ToolchainHost.hpp +++ b/src/apps/pace-cc/ToolchainHost.hpp @@ -109,6 +109,20 @@ class IToolchainHost /// @return True when it exists and is a directory. [[nodiscard]] virtual bool DirectoryExists(std::string_view path) = 0; + /// The directory @p path names, with every symbolic link and `..` resolved. + /// + /// For asking whether two spellings name ONE directory -- the question a path is + /// classified by, since a path is what it RESOLVES to and never how it is spelled. + /// A compiler lists `/usr/include` as `/usr/lib/gcc///../../../../include` + /// on one machine, and `/usr/local` is a link into `/var` on an image-based one, so + /// neither spelling can be compared as text. + /// + /// @param path Directory path, in any spelling. + /// @return Its resolved, `/`-separated path; `std::nullopt` when it does not exist, + /// is not a directory, or cannot be resolved -- so a caller comparing two + /// answers never finds two unresolvable paths equal. + [[nodiscard]] virtual std::optional ResolveDirectory(std::string_view path) = 0; + /// Whether @p path names a file this host would run. /// /// On POSIX that is a regular file with an execute bit set for somebody; on diff --git a/src/apps/pace-cc/ToolchainHostTestUtils.hpp b/src/apps/pace-cc/ToolchainHostTestUtils.hpp index 586ae840f..348a49dae 100644 --- a/src/apps/pace-cc/ToolchainHostTestUtils.hpp +++ b/src/apps/pace-cc/ToolchainHostTestUtils.hpp @@ -5,6 +5,7 @@ #include #include +#include #include #include #include @@ -179,6 +180,31 @@ class ScriptedToolchainHost final: public IToolchainHost return _directories.contains(Normalize(path)); } + /// Make @p link resolve to @p target, as a symbolic link to a directory does. + /// + /// The scripted half of `ResolveDirectory`: a case that needs a well-known system + /// path such as `/usr/include` to name a directory it wrote somewhere else says so + /// here, which is exactly the shape of a real machine whose `/usr/local` is a link. + /// @param link The spelling that is resolved. + /// @param target The directory it resolves to; it must be added as a directory + /// for the link to resolve at all. + /// @return This host, for chaining. + ScriptedToolchainHost& AddDirectoryLink(std::string_view link, std::string_view target) + { + _directoryLinks.insert_or_assign(Normalize(link), Normalize(target)); + return *this; + } + + std::optional ResolveDirectory(std::string_view path) override + { + auto key = Normalize(path); + if (auto const link = _directoryLinks.find(key); link != _directoryLinks.end()) + key = link->second; + if (!_directories.contains(key)) + return std::nullopt; + return key; + } + bool ExecutableExists(std::string_view path) override { return _executables.contains(Normalize(path)); @@ -338,6 +364,7 @@ class ScriptedToolchainHost final: public IToolchainHost std::set _directories; std::set _executables; + std::map _directoryLinks; bool _leadingSlashIsDriveRelative { false }; /// `X64` by default because it is what nearly every case means by "a machine", /// and a case about architecture says so with `WithNativeArchitecture`. diff --git a/src/apps/pace-cc/ToolchainHost_test.cpp b/src/apps/pace-cc/ToolchainHost_test.cpp index bde29ae1c..617307703 100644 --- a/src/apps/pace-cc/ToolchainHost_test.cpp +++ b/src/apps/pace-cc/ToolchainHost_test.cpp @@ -11,8 +11,10 @@ #include #include #include +#include #include #include +#include #if defined(_WIN32) #include @@ -341,3 +343,44 @@ TEST_CASE("The real host reads the environment through the shared leaf", "[toolc CHECK_FALSE(host->Environment("PACE_TOOLCHAIN_HOST_ABSENT").has_value()); } + +TEST_CASE("The real host resolves a directory through .. and a link, and nothing else", "[toolchain-host]") +{ + Pace::Testing::ScratchDirectory tree { "pace-tch-resolve" }; + tree.Write("usr/include/stdio.h", "#pragma once\n"); + tree.Write("usr/lib/gcc/16/marker.txt", "x"); + + auto const host = MakeToolchainHost(); + auto const expected = host->ResolveDirectory((tree.Path() / "usr" / "include").string()); + REQUIRE(expected.has_value()); + + // gcc's own spelling of `/usr/include` resolves to the same directory. + CHECK(host->ResolveDirectory((tree.Path() / "usr/lib/gcc/16/../../../include").string()) == expected); + + // A path that is not there, and a FILE, are no answer -- so two of them can never + // compare equal to each other or to a directory. + CHECK_FALSE(host->ResolveDirectory((tree.Path() / "absent").string()).has_value()); + CHECK_FALSE(host->ResolveDirectory((tree.Path() / "usr/include/stdio.h").string()).has_value()); + +#if !defined(_WIN32) + // A link -- the shape of an image-based system's `/usr/local` -- resolves to its + // target. POSIX only: creating one on Windows needs a privilege a runner may lack. + std::error_code ec; + std::filesystem::create_directory_symlink(tree.Path() / "usr" / "include", tree.Path() / "linked", ec); + REQUIRE_FALSE(ec); + CHECK(host->ResolveDirectory((tree.Path() / "linked").string()) == expected); +#endif +} + +TEST_CASE("The scripted host resolves a directory through a link it was given", "[toolchain-host]") +{ + ScriptedToolchainHost host; + host.AddDirectory("/scratch/usr/include").AddDirectoryLink("/usr/include", "/scratch/usr/include"); + + CHECK(host.ResolveDirectory("/usr/include") == std::optional { "/scratch/usr/include" }); + CHECK(host.ResolveDirectory("/scratch/usr/include/") == std::optional { "/scratch/usr/include" }); + // A link to nothing resolves to nothing, as a dangling link does. + host.AddDirectoryLink("/usr/local/include", "/scratch/absent"); + CHECK_FALSE(host.ResolveDirectory("/usr/local/include").has_value()); + CHECK_FALSE(host.ResolveDirectory("/never/added").has_value()); +} diff --git a/src/apps/pace-cc/ToolchainProbe.cpp b/src/apps/pace-cc/ToolchainProbe.cpp index 459750e56..007356e92 100644 --- a/src/apps/pace-cc/ToolchainProbe.cpp +++ b/src/apps/pace-cc/ToolchainProbe.cpp @@ -1107,18 +1107,45 @@ IncludeSearchRoots FingerprintIncludeRoots(IProcessRunner& runner, // and the grammar by construction, not because a probe came back empty. return IncludeSearchRoots { .roots = {}, .targetTriple = {}, .answered = true }; - case FingerprintTree::OwnTreeWhenTargetingMsvc: - // A target the probe did not name keeps every root, which is the direction - // that can only cost a match: the borrowed trees stay in and two machines - // may split, as they did before #1656, rather than a tree being dropped on - // a guess. + case FingerprintTree::OwnTrees: + // A target the probe did not name keeps every root but the machine's own, + // which is the direction that can only cost a match: the borrowed trees stay + // in and two machines may split, as they did before #1656, rather than a + // tree being dropped on a guess. The machine's own roots go whatever the + // target, because they are recognised by what they RESOLVE to and no MSVC + // tree resolves to `/usr/include`. if (!TargetsMsvc(discovered.targetTriple)) - return discovered; + return WithoutSystemIncludeRoots(host, discovered); return ClangResourceIncludeRoots(runner, host, compiler); } return {}; } +bool IsSystemIncludeRoot(IToolchainHost& host, std::string_view root) +{ + // The rows are POSIX paths, and on a host where a leading `/` is drive-relative they + // name whatever the current drive holds there -- not the directory a driver meant. + // Nothing is recognised, so everything stays folded. + if (host.LeadingSlashIsDriveRelative()) + return false; + + // Unresolvable is NOT a system root: two answers of `nullopt` must never compare + // equal, and a root that cannot be classified stays folded. + auto const resolved = host.ResolveDirectory(root); + if (!resolved.has_value()) + return false; + + return std::ranges::any_of(SystemIncludeDirectories, [&](SystemIncludeDirectory const& row) { + return host.ResolveDirectory(row.path) == resolved; + }); +} + +IncludeSearchRoots WithoutSystemIncludeRoots(IToolchainHost& host, IncludeSearchRoots discovered) +{ + std::erase_if(discovered.roots, [&host](std::string const& root) { return IsSystemIncludeRoot(host, root); }); + return discovered; +} + std::string ParseDriverTargetTriple(std::string_view driverOutput) { // No frontend line, or one naming nothing this can trust, yields empty -- the @@ -1366,10 +1393,12 @@ ToolchainIdentity CachedToolchainFingerprint(IProcessRunner& runner, // layout -- the #195 identity of every MSVC ever installed. // // Every other row is judged here on DISCOVERY's roots, because this runs before - // the cache read and the folded tree of `OwnTreeWhenTargetingMsvc` is only known + // the cache read and the folded tree of `OwnTrees` is only known // on the walk. The walk asks the question again of the tree it folded -- see // `foldedNothing` below -- so an MSVC-targeting clang whose banner fell back and - // whose resource probe named no directory is refused there, never served. + // whose resource probe named no directory, or a GNU driver whose fallback banner + // sits over nothing but the machine's own include directories, is refused there, + // never served. auto const foldsNoTree = spec.fingerprintTree == FingerprintTree::None || roots.empty(); if (spec.includeDiscovery != IncludeDiscovery::None && foldsNoTree && banner == NormalizedCompilerName(compiler)) return IdentityDefect::NoEvidence; @@ -1463,9 +1492,11 @@ ToolchainIdentity CachedToolchainFingerprint(IProcessRunner& runner, // `NoEvidence` asked again, of the tree the digest FOLDED, which only the walk // knows. It differs from `probeDefect` only where the walk selected fewer roots // than discovery found -- an MSVC-targeting clang whose resource probe named no - // directory -- and there a fallback banner over no tree is the string `clang++` - // and its grammar, every such install alike. Not cached, for the reason it was - // not caught above: a later HIT asks only discovery's roots, and would serve it. + // directory, or a GNU driver whose every discovered root was one of the machine's + // own (`SystemIncludeDirectories`) -- and there a fallback banner over no tree is + // the driver's name and its grammar, every such install alike. Not cached, for the + // reason it was not caught above: a later HIT asks only discovery's roots, and + // would serve it. auto const foldedNothing = probeDefect == IdentityDefect::None && walked.answered && spec.includeDiscovery != IncludeDiscovery::None && walked.roots.empty() && banner == NormalizedCompilerName(compiler); diff --git a/src/apps/pace-cc/ToolchainProbe.hpp b/src/apps/pace-cc/ToolchainProbe.hpp index 49e0ded54..97d305fd1 100644 --- a/src/apps/pace-cc/ToolchainProbe.hpp +++ b/src/apps/pace-cc/ToolchainProbe.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -475,7 +476,7 @@ struct IncludeSearchRoots /// /// Only `IncludeDiscovery::GnuVerbose` fills it: `-E -v` prints the `-cc1` line and /// the `Target:` header beside the search list, so this costs no spawn. It is what - /// `FingerprintTree::OwnTreeWhenTargetingMsvc` decides on -- and it is NOT the cache + /// `FingerprintTree::OwnTrees` decides on -- and it is NOT the cache /// key's target, which `DiscoverTargetTriple` asks for per invocation. std::string targetTriple; @@ -503,12 +504,66 @@ struct IncludeSearchRoots /// @return True when a driver generating for it borrows the VC toolset and the SDK. [[nodiscard]] bool TargetsMsvc(std::string_view triple) noexcept; +/// One include directory a GNU-family driver searches that belongs to the MACHINE rather +/// than to the toolchain. +struct SystemIncludeDirectory +{ + /// The directory, as an absolute POSIX path. Compared by what it resolves to. + std::string_view path; + /// Which of GCC's configuration values places it there -- documentation, never read. + std::string_view origin; +}; + +/// The machine's own include directories, which no toolchain fingerprint folds. +/// +/// They hold glibc's headers and those of every `-devel` package and hand install on the +/// machine -- never the compiler's. A worker compiles text the client ALREADY preprocessed +/// and reads no header from either directory to generate code (measured: a clean +/// preprocessed compile under gcc 16.2 and clang 22.1 and 20.1, C and C++, opens nothing +/// beneath them; gcc opens one only to print the source excerpt of a diagnostic that points +/// into it, which reaches stderr and never the object), and the cache key hashes that text, +/// so what was installed beside the compiler is covered where it matters. Folded, the two directories split machines with +/// byte-identical compiler packages on how many `-devel` packages each had installed, and nothing dispatched between them. +/// +/// Recognised by EQUALITY of resolved paths, never containment: libstdc++ resolves to +/// `/usr/include/c++/`, nested under a row, and must stay folded. Debian's +/// `/usr/include/` is likewise not a row and stays folded (#1783). +/// +/// Exactly the native paths, never a sysroot's spelling of them, and that is the narrow +/// direction: a sysroot is more than headers to a driver (Apple clang derives +/// `-target-sdk-version` from the SDK's `SDKSettings.json`), so its tree stays folded as the evidence of +/// which SDK a worker would build against. libstdc++ and the compiler's resource +/// directory are roots of their own in every `-v` list and are untouched by this table. +inline constexpr std::array SystemIncludeDirectories { { + { .path = "/usr/local/include", .origin = "LOCAL_INCLUDE_DIR" }, + { .path = "/usr/include", .origin = "NATIVE_SYSTEM_HEADER_DIR" }, +} }; + +/// Whether @p root is one of `SystemIncludeDirectories`, judged by what both resolve to. +/// +/// Resolved rather than compared as text, because neither spelling is stable: gcc lists +/// libstdc++ as `/usr/lib/gcc///../../../../include/c++/`, and +/// an image-based system links `/usr/local` into `/var`. A root that cannot be resolved, +/// and every root on a host where a leading `/` is drive-relative, is NOT a system root -- +/// the direction that keeps a tree folded rather than drops one on a guess. +/// @param host The machine's filesystem. +/// @param root A root as the driver listed it. +/// @return True when it resolves to the same directory as a table row does. +[[nodiscard]] bool IsSystemIncludeRoot(IToolchainHost& host, std::string_view root); + +/// @p discovered with every root `IsSystemIncludeRoot` recognises removed, order kept. +/// @param host The machine's filesystem. +/// @param discovered What discovery answered. +/// @return The same answer -- target and `answered` included -- over the toolchain's roots. +[[nodiscard]] IncludeSearchRoots WithoutSystemIncludeRoots(IToolchainHost& host, IncludeSearchRoots discovered); + /// The include roots a toolchain FINGERPRINT walks, chosen from those discovery found. /// /// Dispatches on `spec.fingerprintTree` with no `default:`. The answer is a subset of /// the toolchain's trees, never a superset, so it can only make two machines AGREE -/// where they disagreed on a tree the driver does not own (#1656); the banner and the -/// grammar still separate one compiler from another. +/// where they disagreed on a tree the driver does not own -- the MSVC it borrows +/// (#1656), the machine's `/usr/include` (`SystemIncludeDirectories`); the banner, the +/// grammar and the trees the driver does own still separate one compiler from another. /// /// Called on the walk's path only, so a cache hit spawns nothing for it. A clang that /// targets MSVC is asked `-print-resource-dir` here -- one spawn, on a miss, and only on @@ -553,7 +608,7 @@ struct IncludeSearchRoots /// `cl`'s banner names its toolset and target since #195, so `cl` folds none of /// those trees either (`FingerprintTree::None`), and a GNU-grammar clang targeting /// MSVC folds this directory and nothing else -/// (`FingerprintTree::OwnTreeWhenTargetingMsvc`). +/// (`FingerprintTree::OwnTrees`). /// /// @param runner Process-spawning seam. /// @param host The machine's filesystem. diff --git a/src/apps/pace-cc/ToolchainProbe_test.cpp b/src/apps/pace-cc/ToolchainProbe_test.cpp index 6682ce885..508e330d9 100644 --- a/src/apps/pace-cc/ToolchainProbe_test.cpp +++ b/src/apps/pace-cc/ToolchainProbe_test.cpp @@ -2958,6 +2958,178 @@ TEST_CASE("A clang targeting anything else still folds every tree it searches", CHECK(oneRunner.ResourceProbes() == 0); } +namespace +{ +/// What one Linux machine's GNU-driver include trees say, file by file. +struct LinuxTrees +{ + std::string_view libstdcxx { "// libstdc++ 16\n" }; ///< `c++/16/vector`, a root of its own. + std::string_view resource { "// clang 22\n" }; ///< The compiler's `stddef.h`. + std::string_view usrInclude { "// glibc\n" }; ///< `/usr/include/stdio.h`. + std::string_view usrLocal { "// refs\n" }; ///< `/usr/local/include/gsl.h`. + std::string_view sysroot { "// sysroot libc\n" }; ///< A sysroot's `usr/include/stdio.h`. + bool extraDevelPackage { false }; ///< One more header under `/usr/include`. +}; + +/// A Linux clang whose `-v` list is libstdc++, its resource directory, the machine's +/// `/usr/local/include` and `/usr/include`, and a sysroot's `usr/include` -- the last +/// one a root nothing classifies. +/// +/// The machine's two directories are written under the scratch tree and the scripted +/// host LINKS `/usr/include` and `/usr/local/include` to them, which is how a real +/// machine's are recognised too: by what they resolve to. +/// +/// libstdc++ sits where production puts it, NESTED under the machine's `/usr/include` +/// (`usr/include/c++/16`), and resolves: a classifier that dropped every root UNDER a +/// system directory, rather than the directory itself, would drop it here as it would on +/// every real Linux host, and the separation case below would go red. +/// @param machine Where it lives. +/// @param host The scripted machine. +/// @param trees What each tree says. +/// @return The install. +[[nodiscard]] ClangMachine WriteLinuxClang(Pace::Testing::ScratchDirectory const& machine, + ScriptedToolchainHost& host, + LinuxTrees const& trees) +{ + auto clang = WriteClangInstall(machine, host, trees.resource, "usr/include/c++/16", trees.libstdcxx); + host.AddDirectory((machine / "usr/include/c++/16").generic_string()); + auto const addRoot = [&](std::string_view relative, std::string_view file, std::string_view content) { + machine.Write(std::string { relative } + "/" + std::string { file }, content); + auto const root = (machine / std::string { relative }).generic_string(); + host.AddDirectory(root); + clang.roots.push_back(root); + return root; + }; + host.AddDirectoryLink("/usr/local/include", addRoot("usr/local/include", "gsl.h", trees.usrLocal)); + host.AddDirectoryLink("/usr/include", addRoot("usr/include", "stdio.h", trees.usrInclude)); + addRoot("sysroot/usr/include", "stdio.h", trees.sysroot); + if (trees.extraDevelPackage) + machine.Write("usr/include/openssl/ssl.h", "// openssl-devel\n"); + return clang; +} + +/// A Linux clang's fingerprint under @p flavor's row, refreshed. +/// @param machine Where it lives. +/// @param trees What each tree says. +/// @param flavor Which driver row identifies it. +/// @return The identity. +[[nodiscard]] ToolchainIdentity LinuxClangIdentity(Pace::Testing::ScratchDirectory const& machine, + LinuxTrees const& trees, + Flavor flavor = Flavor::Clang) +{ + ScriptedToolchainHost host; + auto const clang = WriteLinuxClang(machine, host, trees); + ClangProbeRunner runner { ClangVerbose(LinuxTriple, LinuxTriple, clang.roots), clang.resourceDir }; + return CachedFingerprintSerially(runner, host, clang.compiler, Clang22Banner, DriverOf(flavor), /*forceRefresh=*/true); +} +} // namespace + +TEST_CASE("A GNU driver is identified without the machine's /usr/include and /usr/local/include", + "[toolchain-probe][fingerprint-tree][system-include]") +{ + // Two Fedora machines with byte-identical compiler packages split on every toolchain: + // one had 137 `-devel` packages and hand-installed headers in `/usr/local/include`, + // the other 109 and a different hand install. Neither directory is the compiler's, + // and a worker opens neither for a preprocessed compile, so they agree now. + Pace::Testing::ScratchDirectory one { "pace-tcp-sysinc-1" }; + Pace::Testing::ScratchDirectory two { "pace-tcp-sysinc-2" }; + Pace::Testing::ScratchDirectory state { "pace-tcp-sysinc-state" }; + Pace::Testing::ScopedEnv const env { StateVariable, state.Path().string() }; + + auto const a = LinuxClangIdentity(one, LinuxTrees {}); + auto const b = LinuxClangIdentity( + two, + LinuxTrees { .usrInclude = "// glibc, other -devel set\n", .usrLocal = "// glaze\n", .extraDevelPackage = true }); + REQUIRE(a.Usable()); + REQUIRE(b.Usable()); + CHECK(a.fingerprint == b.fingerprint); + + // The gcc row selects alike: one binary reaches both rows by its stem. + Pace::Testing::ScratchDirectory three { "pace-tcp-sysinc-3" }; + Pace::Testing::ScratchDirectory four { "pace-tcp-sysinc-4" }; + CHECK(LinuxClangIdentity(three, LinuxTrees {}, Flavor::Gcc).fingerprint + == LinuxClangIdentity(four, LinuxTrees { .usrInclude = "// other glibc\n" }, Flavor::Gcc).fingerprint); + + // Only the digest narrowed: the roots are still the evidence the stamp and the node's + // re-survey watch, so installing a `-devel` package still restamps. + REQUIRE(b.evidence.has_value()); + CHECK(Pace::Testing::Unwrap(b.evidence).roots.size() == 5); + // And the record a node explains a fingerprint from names no file of those trees. + REQUIRE(b.inputs.has_value()); + CHECK_FALSE(HasPath(Pace::Testing::Unwrap(b.inputs).files, "gsl.h")); + CHECK(HasPath(Pace::Testing::Unwrap(b.inputs).files, "vector")); +} + +TEST_CASE("libstdc++ and the compiler's resource directory still separate two GNU toolchains", + "[toolchain-probe][fingerprint-tree][system-include]") +{ + // The direction the drop must not break: the trees the compiler OWNS are its + // identity beyond the banner, and two builds under one version line differ there. + Pace::Testing::ScratchDirectory base { "pace-tcp-sysinc-own-base" }; + Pace::Testing::ScratchDirectory stdlib { "pace-tcp-sysinc-own-stdlib" }; + Pace::Testing::ScratchDirectory resource { "pace-tcp-sysinc-own-resource" }; + Pace::Testing::ScratchDirectory same { "pace-tcp-sysinc-own-same" }; + Pace::Testing::ScratchDirectory state { "pace-tcp-sysinc-own-state" }; + Pace::Testing::ScopedEnv const env { StateVariable, state.Path().string() }; + + auto const reference = LinuxClangIdentity(base, LinuxTrees {}).fingerprint; + CHECK(reference != LinuxClangIdentity(stdlib, LinuxTrees { .libstdcxx = "// libstdc++ 16, patched\n" }).fingerprint); + CHECK(reference != LinuxClangIdentity(resource, LinuxTrees { .resource = "// clang 22, patched\n" }).fingerprint); + // The control: identical trees agree, so the two splits are the CONTENT's doing. + CHECK(reference == LinuxClangIdentity(same, LinuxTrees {}).fingerprint); +} + +TEST_CASE("An include root that cannot be classified stays folded", "[toolchain-probe][fingerprint-tree][system-include]") +{ + // Err narrow. A sysroot's `usr/include` is spelled like the machine's but resolves + // elsewhere, and a driver reads more of a sysroot than its headers, so it is not + // recognised and still separates. + Pace::Testing::ScratchDirectory one { "pace-tcp-sysinc-unknown-1" }; + Pace::Testing::ScratchDirectory two { "pace-tcp-sysinc-unknown-2" }; + Pace::Testing::ScratchDirectory state { "pace-tcp-sysinc-unknown-state" }; + Pace::Testing::ScopedEnv const env { StateVariable, state.Path().string() }; + + CHECK(LinuxClangIdentity(one, LinuxTrees {}).fingerprint + != LinuxClangIdentity(two, LinuxTrees { .sysroot = "// another sysroot libc\n" }).fingerprint); +} + +TEST_CASE("A system include root is recognised by what it resolves to", "[toolchain-probe][system-include]") +{ + ScriptedToolchainHost host; + host.AddDirectory("/scratch/usr/include").AddDirectoryLink("/usr/include", "/scratch/usr/include"); + host.AddDirectory("/scratch/sysroot/usr/include"); + host.AddDirectory("/scratch/usr/include/c++/16"); + + // Any spelling resolving to the row's directory is the row. + CHECK(IsSystemIncludeRoot(host, "/usr/include")); + CHECK(IsSystemIncludeRoot(host, "/scratch/usr/include")); + + // libstdc++ resolves to a directory NESTED under the row's, and is not the row. + CHECK_FALSE(IsSystemIncludeRoot(host, "/scratch/usr/include/c++/16")); + + // A sysroot's spelling is not, nor is a root that resolves to nothing -- and neither + // is `/usr/local/include`, which this machine does not have: two unresolvable paths + // must never compare equal. + CHECK_FALSE(IsSystemIncludeRoot(host, "/scratch/sysroot/usr/include")); + CHECK_FALSE(IsSystemIncludeRoot(host, "/usr/local/include")); + CHECK_FALSE(IsSystemIncludeRoot(host, "/nowhere")); + + // Order and everything but the roots survive the filter. + auto const kept = WithoutSystemIncludeRoots( + host, + IncludeSearchRoots { .roots = { "/scratch/usr/include/c++/16", "/usr/include", "/scratch/sysroot/usr/include" }, + .targetTriple = std::string { LinuxTriple }, + .answered = true }); + CHECK(kept.roots == std::vector { "/scratch/usr/include/c++/16", "/scratch/sysroot/usr/include" }); + CHECK(kept.targetTriple == LinuxTriple); + CHECK(kept.answered); + + // On a host where a leading `/` is drive-relative the rows name nothing this driver + // meant, so nothing is recognised. + host.WithDriveRelativeSlash(); + CHECK_FALSE(IsSystemIncludeRoot(host, "/usr/include")); +} + TEST_CASE("An MSVC-targeting clang whose resource probe cannot run is refused and not cached", "[toolchain-probe][fingerprint-tree]") { diff --git a/src/apps/pace-node/McpToolchainTools_test.cpp b/src/apps/pace-node/McpToolchainTools_test.cpp index 6aa5b89c7..816435bd5 100644 --- a/src/apps/pace-node/McpToolchainTools_test.cpp +++ b/src/apps/pace-node/McpToolchainTools_test.cpp @@ -1341,7 +1341,7 @@ TEST_CASE("toolchain_diff refuses a side digested under another schema, naming b Cc::ComputeToolchainFingerprint(foreign))); CHECK(result.isError); CHECK(result.text.contains("schema skew")); - CHECK(result.text.contains("pace-node 1.0.0 under fingerprint schema toolchain-v3")); + CHECK(result.text.contains(std::format("pace-node 1.0.0 under fingerprint schema {}", Cc::FingerprintSchema))); CHECK(result.text.contains("pace-node 0.9.0 under toolchain-v2")); }