diff --git a/.agent/rules/compile-cache.md b/.agent/rules/compile-cache.md
index a0071586c..c34a3d539 100644
--- a/.agent/rules/compile-cache.md
+++ b/.agent/rules/compile-cache.md
@@ -15,22 +15,29 @@ rule below has already been at least one of the two.
## The five rules the end-to-end tests assert
-
+
`pace-kv` and `pace-cc` are both installed. Three things the launcher's
cache key depends on, each of which has already caused a silent hit-rate
collapse or a mis-serve and is now covered by regression tests:
-- **Preprocessing must suppress line markers** (`/EP` on MSVC, `-E -P` on GNU).
- A `# 1 "/abs/path.cpp"` marker embeds the checkout path in the hashed text.
- On MSVC that is `/EP` **alone**: `/EP` and `/P` are alternatives, not modifiers
- — `/EP` preprocesses to stdout, `/P` to a `.i` file, and MSVC documents
- the pair as "to the file, without `#line`". Passing both left the launcher
- hashing an empty stdout, so a Windows key carried nothing from the source and
- an edited file was answered with the object built from the previous revision.
- That is a wrong build rather than a cold cache, and direct mode hid it, since
- its manifest hashes the source's own bytes — hence the e2e case that edits a
- source with `PACE_NO_DIRECT=1` and requires a MISS.
+- **Preprocessing KEEPS line markers (`/E` on MSVC, `-E` on GNU), and the key keeps
+ their line numbers while dropping their paths** (`KeyedPreprocessedText`). A
+ `# 1 "/abs/path.cpp"` marker embeds the checkout path, which is why the probe used to
+ suppress markers outright (`/EP`, `-E -P`) -- and that threw the LINE STRUCTURE away
+ with the path: `-P` collapses blank and comment lines, so a comment inserted above a
+ function left the hashed text byte-identical while `std::source_location`,
+ `__builtin_LINE` and every `-g` line table moved. Measured end to end: the edited file
+ got a HIT whose function reported line 2 where the source said 5 (`objkey-v10` fixed it).
+ The path is safe to drop because nothing a key could see depends on it: `__FILE__` is
+ already expanded in the text, and a name recorded after preprocessing is root binding's
+ and the prefix maps' to answer.
+ - On MSVC never `/P` beside it: `/P` preprocesses to a `.i` file rather than
+ stdout, and `/EP /P` left the launcher hashing an empty stdout, so a Windows key
+ carried nothing from the source and an edited file was answered with the object
+ built from the previous revision. Direct mode hid it, since its manifest hashes the
+ source's own bytes — hence the e2e case that edits a source with
+ `PACE_NO_DIRECT=1` and requires a MISS.
- **`/` introduces an option only on Windows.** On POSIX it starts an absolute
path, and treating it as an option leaves absolute paths unrelativized.
- **Only machine-independent dependency paths may be hashed.** The dependency set
@@ -344,8 +351,8 @@ same on both — the same defect with no MSVC anywhere near it.
-- **A key determines two artefacts, so it must be a function of both.** Preprocessing
- suppresses line markers (`-E -P`, `/EP`) so a checkout path never reaches the key —
+- **A key determines two artefacts, so it must be a function of both.** The keyed text
+ carries no checkout path (each line marker is reduced to its line number) —
which is what makes a key portable, and equally what made it *invariant under a header
move*. Move a header without changing a byte of it and the token stream is identical:
the object is still correct and was served, while the depfile, which is nothing but
@@ -702,7 +709,9 @@ same on both — the same defect with no MSVC anywhere near it.
**The channel follows the FLAG, not the driver.** Both drivers put the notes on
stdout when compiling and move them to stderr under `/EP`, where stdout carries the
- preprocessed text and a note on it would corrupt that text. The three sites said
+ preprocessed text and a note on it would corrupt that text. The probe has since moved
+ to `/E` (`objkey-v9`), whose channel nobody here has MEASURED; it decides nothing,
+ because the probe reads notes from both streams and splits stdout unconditionally. The three sites said
"`cl` on stderr"; #700 and the #821 review said "`cl` on stdout"; each was half
right and neither had the rule. That is what makes a claim restated in three places
dangerous — none of the three was placed to notice the question had a second
diff --git a/AGENT.md b/AGENT.md
index 224ede7e3..e9798ce46 100644
--- a/AGENT.md
+++ b/AGENT.md
@@ -160,7 +160,7 @@ the only place it is written down.
**[`.agent/rules/compile-cache.md`](.agent/rules/compile-cache.md)** — what the
launcher's cache key is made of. Before `apps/pace-cc/`, `CompileCache/`.
-- Preprocess with line markers suppressed — `/EP` **alone** on MSVC, never `/EP /P`.
+- Preprocess KEEPING line markers; the key keeps their line numbers and drops their paths — `/E`, never `/P`.
- `/` introduces an option only on a Windows layout; on POSIX it starts a path.
- Only machine-independent dependency paths are hashed, and a path is classified
by what it *resolves to*, never by its spelling. A CPM cache is a ROOT (``, `PACE_DEPS_DIR`).
diff --git a/docs/tools/pace-cc.md b/docs/tools/pace-cc.md
index 72880014f..4a2181aec 100644
--- a/docs/tools/pace-cc.md
+++ b/docs/tools/pace-cc.md
@@ -70,6 +70,12 @@ preprocess-only run moves the notes (clang-cl puts them on stderr under `/EP`,
so that they do not corrupt the preprocessed stdout), so the probe splits stdout
unconditionally and reads notes from both streams rather than guessing.
+The probe keeps its line markers (`-E`, `/E`) and the key keeps their line numbers
+while dropping their paths. Suppressing the markers (`-E -P`, `/EP`) collapsed blank
+and comment lines, so a comment inserted above a function kept the key while
+`std::source_location`, `__builtin_LINE` and the `-g` line tables moved, and the
+edited file was served the object built before the edit.
+
Version-suffixed (`g++-14`, `clang-18`) and `.exe` forms are recognised. Any
other `argv[0]` is treated as unknown and passed straight through uncached.
diff --git a/src/apps/pace-cc/CacheKey.cpp b/src/apps/pace-cc/CacheKey.cpp
index 67680fc7f..e7856810f 100644
--- a/src/apps/pace-cc/CacheKey.cpp
+++ b/src/apps/pace-cc/CacheKey.cpp
@@ -7,6 +7,7 @@
#include
#include
+#include
#include
#include
#include
@@ -214,6 +215,74 @@ std::optional UnkeyableArgument(std::span args,
return std::nullopt;
}
+namespace
+{
+ /// The marker a line opens with, reduced to what the key keeps, or nothing when the
+ /// line is not a marker.
+ /// @param line One line without its terminator.
+ /// @return The line as written up to its line number, then what followed the quoted
+ /// path, or nullopt.
+ [[nodiscard]] std::optional ReducedMarker(std::string_view line)
+ {
+ auto rest = line;
+ if (!rest.starts_with('#'))
+ return std::nullopt;
+ rest.remove_prefix(1);
+ auto const skipBlanks = [&rest] {
+ while (!rest.empty() && (rest.front() == ' ' || rest.front() == '\t'))
+ rest.remove_prefix(1);
+ };
+ skipBlanks();
+ if (rest.starts_with("line") && rest.size() > 4 && (rest[4] == ' ' || rest[4] == '\t'))
+ {
+ rest.remove_prefix(4);
+ skipBlanks();
+ }
+ auto const digits = rest.substr(0, rest.find_first_not_of("0123456789"));
+ if (digits.empty())
+ return std::nullopt;
+ rest.remove_prefix(digits.size());
+ auto const throughLineNumber = line.substr(0, line.size() - rest.size());
+ skipBlanks();
+ if (!rest.starts_with('"'))
+ return std::nullopt;
+ // The path is a C string literal: a backslash escapes the next byte, so `\"` does not
+ // end it, and MSVC doubles every separator (`c:\\src\\a.cpp`).
+ auto at = std::size_t { 1 };
+ while (at < rest.size() && rest[at] != '"')
+ at += rest[at] == '\\' ? 2 : 1;
+ if (at >= rest.size())
+ return std::nullopt;
+ rest.remove_prefix(at + 1);
+ return std::format("{}{}", throughLineNumber, rest);
+ }
+} // namespace
+
+std::string KeyedPreprocessedText(std::string_view text)
+{
+ std::string out;
+ out.reserve(text.size());
+ while (!text.empty())
+ {
+ auto const end = text.find('\n');
+ auto const length = end == std::string_view::npos ? text.size() : end + 1;
+ auto const line = text.substr(0, length);
+ // The terminator (`\n`, or `\r\n`) is kept as written, so only the marker's path moves.
+ // `\r\n` ends with `\n` too, so the two tests sum to 2 for it, 1 for a bare `\n`, 0 for none.
+ auto const terminatorSize = std::size_t { line.ends_with('\n') } + std::size_t { line.ends_with("\r\n") };
+ auto const body = line.substr(0, line.size() - terminatorSize);
+ if (auto const reduced = ReducedMarker(body))
+ {
+ out.append(*reduced);
+ out.append(line.substr(body.size()));
+ }
+ else
+ out.append(line);
+ text.remove_prefix(length);
+ }
+ return out;
+}
+
std::string CacheCompilerId(std::string_view banner, std::string_view targetTriple)
{
if (targetTriple.empty())
@@ -351,7 +420,16 @@ std::string ComputeKey(KeyInputs const& inputs)
// rather than merely old and nothing in a value says which ones are -- v6's argument. This
// construction is unchanged and the golden vector moved for the tag alone; `manifest-v10`
// moves with it, in the lock-step ComputeManifestKey records.
- KeyDigest digest { "objkey-v9" };
+ //
+ // v10 is the line structure. `preprocessed` was `-E -P` / `/EP` output, which collapses
+ // blank and comment lines, so a comment inserted above a function kept the key while
+ // `source_location`, `__builtin_LINE` and the `-g` line tables moved: the edited file was
+ // served the object from before the edit (measured end to end: a HIT whose function
+ // reported line 2 where the source said 5). It is now `KeyedPreprocessedText` over output
+ // that keeps its markers. Every key moves, so the tag moves with them rather than leaving
+ // a v9 cache whose entries no current key can reach to be explained later. `manifest-v12`
+ // moves with it, in the lock-step ComputeManifestKey records.
+ KeyDigest digest { "objkey-v10" };
digest.Field(inputs.compilerId);
digest.Field(inputs.preprocessed);
for (auto const& arg: inputs.relativizedArgs)
diff --git a/src/apps/pace-cc/CacheKey.hpp b/src/apps/pace-cc/CacheKey.hpp
index 38c984083..788543bb2 100644
--- a/src/apps/pace-cc/CacheKey.hpp
+++ b/src/apps/pace-cc/CacheKey.hpp
@@ -148,6 +148,25 @@ struct KeyInputs
std::string_view buildTree,
PathCanon::PathTransform const& resolve = {});
+/// The preprocessed text the key hashes: the probe's output with every line marker's PATH
+/// removed and its line number and flags kept.
+///
+/// The probe keeps its markers (`-E`, `/E`) because they carry the line structure: without
+/// them a comment inserted above a function left the text byte-identical while
+/// `std::source_location`, `__builtin_LINE` and every `-g` line table moved, so the edited
+/// file was served the object built before the edit. The marker's path is what made it
+/// unportable -- it is the checkout's absolute path -- and nothing in the object depends on
+/// it that a key could see: `__FILE__` is already expanded in the text, and a file name the
+/// compiler records after preprocessing (`source_location::file_name`, debug records) is
+/// root binding's and the prefix maps' to answer.
+///
+/// Both spellings are recognised: GNU's `# "" ` and MSVC's
+/// `#line ""`. A line that is not a marker of either shape -- a `#pragma`, an
+/// assembler comment -- is kept verbatim, as is every other byte.
+/// @param text The probe's stdout.
+/// @return The text with each marker reduced to its line number and flags.
+[[nodiscard]] std::string KeyedPreprocessedText(std::string_view text);
+
/// `RelativizeArgs` over a whole layout, its dependency root included: a path under
/// `layout.dependencyRoot` becomes a `` token, so an include directory into a
/// per-user dependency cache stops keeping the user's home in every key.
diff --git a/src/apps/pace-cc/CacheKey_test.cpp b/src/apps/pace-cc/CacheKey_test.cpp
index 300d5560b..b275c4a1b 100644
--- a/src/apps/pace-cc/CacheKey_test.cpp
+++ b/src/apps/pace-cc/CacheKey_test.cpp
@@ -433,7 +433,7 @@ TEST_CASE("ComputeKey's value is pinned, so changing the construction is deliber
// to disagree about what was hashed, and the retirement check would go vacuous
// in the one edit it exists to catch.
auto const key = ComputeKey(inputs);
- CHECK(key == "ccb841c6012c541ddf44ebaefe48132b");
+ CHECK(key == "0fc3b62f1f1ddc380c8517b715d4f018");
// What the vector alone cannot say: that the tag has not been put BACK. See
// Generation -- reverting the tag and re-pasting the vector is one edit
@@ -449,6 +449,9 @@ TEST_CASE("ComputeKey's value is pinned, so changing the construction is deliber
{ .key = "objkey-v7", .digest = "7323057f60d9ffaca969b16ef293ceaa" },
// The v8 -> v9 bump (a clang worker's dropped macro map) changed nothing but the tag.
{ .key = "objkey-v8", .digest = "e86dc84efc6cb5de598620cc334f4ee7" },
+ // The v9 -> v10 bump (the line structure) moved what `preprocessed` holds, not how it is
+ // folded, so this is the outgoing vector.
+ { .key = "objkey-v9", .digest = "ccb841c6012c541ddf44ebaefe48132b" },
});
RequireNoRetiredDigest(key, Retired);
}
@@ -814,6 +817,59 @@ TEST_CASE("A prefix-map flag's root is relativized, so two checkouts still share
CHECK(keyFor(RootA, {}) == keyFor(RootB, {}));
}
+TEST_CASE("The keyed text keeps every marker's line and drops its path")
+{
+ // `-E -P` collapsed blank and comment lines, so a comment inserted above a function left
+ // the key unchanged while `source_location`, `__builtin_LINE` and the `-g` line tables
+ // moved -- measured on g++ and clang++, one key and two objects. The probe keeps its
+ // markers now and the key keeps their line numbers; the paths, which differ per checkout,
+ // go.
+ SECTION("GNU markers, flags kept, every other byte untouched")
+ {
+ std::string const in = "# 0 \"/home/a/src/t.cpp\"\n"
+ "# 1 \"/usr/include/c++/16/vector\" 1 3\n"
+ "#pragma GCC diagnostic push\n"
+ "int f() { return 1; }\n"
+ "# 12 \"/home/a/src/t.cpp\" 2\n";
+ CHECK(KeyedPreprocessedText(in)
+ == "# 0\n"
+ "# 1 1 3\n"
+ "#pragma GCC diagnostic push\n"
+ "int f() { return 1; }\n"
+ "# 12 2\n");
+ }
+ SECTION("MSVC #line, doubled separators and CRLF")
+ {
+ std::string const in = "#line 1 \"c:\\\\src\\\\t.cpp\"\r\nint g();\r\n#line 40 \"c:\\\\src\\\\t.cpp\"\r\n";
+ CHECK(KeyedPreprocessedText(in) == "#line 1\r\nint g();\r\n#line 40\r\n");
+ }
+ SECTION("an escaped quote does not end the path")
+ {
+ CHECK(KeyedPreprocessedText("# 3 \"/w/odd\\\"name.h\" 1\n") == "# 3 1\n");
+ }
+ SECTION("what is not a marker stays verbatim")
+ {
+ for (std::string_view const line: { "#pragma once\n",
+ "# not a marker\n",
+ "#line x \"a\"\n",
+ "# 7 unquoted\n",
+ "# 7 \"unterminated\n",
+ "#define X 1\n",
+ " # 5 \"/a\"\n" })
+ {
+ INFO(line);
+ CHECK(KeyedPreprocessedText(line) == line);
+ }
+ }
+
+ // The property, stated on its own: two checkouts' markers agree, and a moved line does not.
+ auto const at = [](std::string_view root, int line) {
+ return KeyedPreprocessedText(std::format("# {} \"{}/src/t.cpp\"\nint h();\n", line, root));
+ };
+ CHECK(at("/home/alice/work/fc", 5) == at("/srv/bob/deeper/fc", 5));
+ CHECK(at("/home/alice/work/fc", 5) != at("/home/alice/work/fc", 8));
+}
+
TEST_CASE("A source prefix map's root is relativized, and the build tree's place under it is keyed")
{
// Catch2's own CMake passes `-ffile-prefix-map=/=` on every compile, so its
diff --git a/src/apps/pace-cc/CmdLine.cpp b/src/apps/pace-cc/CmdLine.cpp
index fa2f78ffc..d879fb8ed 100644
--- a/src/apps/pace-cc/CmdLine.cpp
+++ b/src/apps/pace-cc/CmdLine.cpp
@@ -48,23 +48,23 @@ namespace
// the launcher cares about. A new driver is a new row here plus a name
// pattern below; the parsing logic itself never grows a branch.
- // Both spellings must suppress line markers. `#line` / `# 1 "file"` markers
- // embed the ABSOLUTE source path, which would make the preprocessed text —
- // and therefore the cache key — differ between two checkouts of the same
- // content at different paths, defeating cross-machine sharing entirely.
- // MSVC: /EP writes to stdout without #line. GNU: -P suppresses markers.
+ // Both spellings KEEP line markers, and the key strips only the paths out of them
+ // (`KeyedPreprocessedText`). A `#line` / `# 1 "file"` marker embeds the ABSOLUTE source
+ // path, which would make the key differ between two checkouts of the same content; but
+ // suppressing the markers outright (`-E -P`, `/EP`) also threw away the LINE STRUCTURE.
+ // `-P` collapses blank and comment lines, so a comment inserted above a function left the
+ // hashed text byte-identical while `std::source_location`, `__builtin_LINE` and every
+ // `-g` line table moved -- measured on g++ and clang++: one key, two different objects,
+ // and the edited file was served the old object. The marker's line number is what keeps
+ // those lines in the key.
//
- // `/EP` ALONE, and the absence of `/P` here is the whole point. The two are
- // not additive: `/EP` preprocesses to stdout, `/P` preprocesses to a FILE, and
- // MSVC documents the pair as "write the file without #line directives". So
- // passing both sent the preprocessed text to `.i` and left the launcher
- // hashing an essentially empty stdout — a key with no content in it at all,
- // under which an edited source re-fetches the object built from the OLD text.
- // Direct mode hides it (its manifest hashes the source's bytes), so it showed
- // up only with PACE_NO_DIRECT=1, and it dropped a stray `.i` in the
- // working directory on every probe besides.
- constexpr std::array MsvcPreprocess { "/EP" };
- constexpr std::array GnuPreprocess { "-E", "-P" };
+ // `/E` and never `/P` beside it. `/P` preprocesses to a FILE rather than stdout, and the
+ // pair `/EP /P` sent the text to `.i` and left the launcher hashing an essentially
+ // empty stdout -- a key with no content in it at all, under which an edited source
+ // re-fetched the object built from the OLD text. Direct mode hid it (its manifest hashes
+ // the source's bytes), so it showed up only with PACE_NO_DIRECT=1.
+ constexpr std::array MsvcPreprocess { "/E" };
+ constexpr std::array GnuPreprocess { "-E" };
/// Preprocess flags for text that is going to be COMPILED elsewhere, which
/// keep the `#line` markers the key's own probe suppresses.
diff --git a/src/apps/pace-cc/CmdLine_test.cpp b/src/apps/pace-cc/CmdLine_test.cpp
index 6e5919c38..4cd59674f 100644
--- a/src/apps/pace-cc/CmdLine_test.cpp
+++ b/src/apps/pace-cc/CmdLine_test.cpp
@@ -391,18 +391,22 @@ TEST_CASE("PreprocessCommand asks a GNU driver for preprocessed text on stdout")
CHECK_FALSE(std::ranges::contains(pp, "build/a.o"));
}
-TEST_CASE("PreprocessCommand suppresses line markers on every driver")
+TEST_CASE("PreprocessCommand keeps line markers on every driver, for the key to reduce")
{
- // Regression guard. `# 1 "/abs/path/t.cpp"` line markers embed the absolute
- // source path, so preprocessed text from two checkouts of identical content
- // at different paths would differ — and the cache keys with it, silently
- // destroying cross-machine sharing, which is this launcher's whole point.
- // MSVC's /EP suppresses them; GNU needs an explicit -P.
+ // Regression guard, and the direction moved. Suppressing the markers (`-P`, `/EP`) kept
+ // the checkout path out of the key and threw the LINE STRUCTURE away with it: `-P`
+ // collapses blank and comment lines, so a comment inserted above a function kept the key
+ // while `source_location` and every `-g` line table moved. The markers stay, and
+ // `KeyedPreprocessedText` removes only their paths.
std::vector const gnu { "g++", "-c", "a.cpp", "-o", "a.o" };
- CHECK(std::ranges::contains(PreprocessCommand(Parse(gnu), gnu), "-P"));
+ auto const gnuLine = PreprocessCommand(Parse(gnu), gnu);
+ CHECK(std::ranges::contains(gnuLine, "-E"));
+ CHECK_FALSE(std::ranges::contains(gnuLine, "-P"));
std::vector const msvc { "cl.exe", "/c", "a.cpp" };
- CHECK(std::ranges::contains(PreprocessCommand(Parse(msvc), msvc), "/EP"));
+ auto const msvcLine = PreprocessCommand(Parse(msvc), msvc);
+ CHECK(std::ranges::contains(msvcLine, "/E"));
+ CHECK_FALSE(std::ranges::contains(msvcLine, "/EP"));
}
TEST_CASE("PreprocessCommand drops dependency flags together with their values")
@@ -423,7 +427,7 @@ TEST_CASE("PreprocessCommand uses the MSVC spelling for MSVC drivers")
std::vector const argv { "cl.exe", "/c", "/showIncludes", "/Foout.obj", "a.cpp" };
auto const pp = PreprocessCommand(Parse(argv), argv);
- CHECK(std::ranges::contains(pp, "/EP"));
+ CHECK(std::ranges::contains(pp, "/E"));
CHECK_FALSE(std::ranges::contains(pp, "/c"));
CHECK_FALSE(std::ranges::contains(pp, "/showIncludes"));
CHECK_FALSE(std::ranges::contains(pp, "/Foout.obj"));
@@ -443,7 +447,7 @@ TEST_CASE("PreprocessCommand drops the GNU spelling of compile-only on clang-cl"
std::vector const argv { R"(C:\llvm\bin\clang-cl.exe)", "-c", "/showIncludes", "/Foout.obj", "a.cpp" };
auto const pp = PreprocessCommand(Parse(argv), argv);
- CHECK(std::ranges::contains(pp, "/EP"));
+ CHECK(std::ranges::contains(pp, "/E"));
CHECK_FALSE(std::ranges::contains(pp, "-c"));
CHECK_FALSE(std::ranges::contains(pp, "/showIncludes"));
CHECK_FALSE(std::ranges::contains(pp, "/Foout.obj"));
@@ -470,7 +474,7 @@ TEST_CASE("PreprocessCommand drops warnings-as-errors from the probe line")
std::vector const argv { R"(C:\VC\bin\cl.exe)", "/WX", "/c", "/Foout.obj", "a.cpp" };
auto const pp = PreprocessCommand(Parse(argv), argv);
- CHECK(std::ranges::contains(pp, "/EP"));
+ CHECK(std::ranges::contains(pp, "/E"));
CHECK_FALSE(std::ranges::contains(pp, "/WX"));
CHECK(std::ranges::contains(pp, "a.cpp"));
}
@@ -721,7 +725,8 @@ TEST_CASE("PreprocessCommand sends MSVC preprocessed text to stdout, never to a
std::vector const argv { compiler, "/c", "/Foout.obj", "a.cpp" };
auto const pp = PreprocessCommand(Parse(argv), argv);
- CHECK(std::ranges::contains(pp, "/EP"));
+ CHECK(std::ranges::contains(pp, "/E"));
+ CHECK_FALSE(std::ranges::contains(pp, "/EP"));
CHECK_FALSE(std::ranges::contains(pp, "/P"));
}
}
@@ -1420,11 +1425,11 @@ TEST_CASE("RemoteCompileArgs drops the MSVC spellings too")
// --- preprocessing for a remote compile --------------------------------------
-TEST_CASE("The dispatch preprocess keeps line markers that the key's suppresses")
+TEST_CASE("The dispatch preprocess keeps line markers, as the key's now does")
{
- // The two runs answer different questions. The key's text must carry no path,
- // so it suppresses markers; a worker's must carry them, because they are what
- // tells the compiler which lines came from a system header.
+ // Both runs keep them now: a worker's because they tell the compiler which lines came
+ // from a system header, the key's because they carry the line structure -- which the
+ // key keeps while `KeyedPreprocessedText` drops the paths.
std::vector const argv { "g++", "-O2", "-c", "a.cpp", "-o", "a.o" };
auto const cmd = ParseCommand(argv);
REQUIRE(cmd.parsedOk);
@@ -1432,7 +1437,7 @@ TEST_CASE("The dispatch preprocess keeps line markers that the key's suppresses"
auto const forKey = PreprocessCommand(cmd, argv);
auto const forWorker = DispatchPreprocessCommand(cmd, argv);
- CHECK(std::ranges::find(forKey, "-P") != forKey.end());
+ CHECK(std::ranges::find(forKey, "-P") == forKey.end());
CHECK(std::ranges::find(forWorker, "-P") == forWorker.end());
CHECK(std::ranges::find(forWorker, "-E") != forWorker.end());
// The source still has to be there, or the run preprocesses nothing.
diff --git a/src/apps/pace-cc/DirectManifest.cpp b/src/apps/pace-cc/DirectManifest.cpp
index 01df2d0cc..81f50dfed 100644
--- a/src/apps/pace-cc/DirectManifest.cpp
+++ b/src/apps/pace-cc/DirectManifest.cpp
@@ -1169,7 +1169,10 @@ std::string ComputeManifestKey(std::string_view canonicalSource,
// Re-keying is the only thing that retires a v10 manifest: each one keeps its key under the
// fixed rules and keeps validating, and a direct hit never re-records. `objkey` does not
// move: the objects are correct under their own keys.
- KeyDigest digest { "manifest-v11" };
+ //
+ // v12 is the lock-step half of `objkey-v10` (the line structure): a v11 manifest stores
+ // an object key of the generation before it.
+ KeyDigest digest { "manifest-v12" };
digest.Field(toolchainStamp);
digest.Field(canonicalSource);
for (auto const& arg: relativizedArgs)
diff --git a/src/apps/pace-cc/DirectManifest_test.cpp b/src/apps/pace-cc/DirectManifest_test.cpp
index 693d74abe..79633f448 100644
--- a/src/apps/pace-cc/DirectManifest_test.cpp
+++ b/src/apps/pace-cc/DirectManifest_test.cpp
@@ -1746,7 +1746,7 @@ TEST_CASE("The manifest digests are pinned, so changing them is deliberate")
// to disagree about what was hashed.
std::vector const args { "/O2", "/src/a.cpp" };
auto const manifestKey = ComputeManifestKey("/src/a.cpp", args, "cl-19.51", {});
- CHECK(manifestKey == "88fad3f9230114ec78ee0aa163916054");
+ CHECK(manifestKey == "b7e580c5f28a2f7582ff637acf989b50");
// And the generations it has retired stay retired. This is the half the vector
// above cannot cover: a v5 manifest is only safe because no launcher carrying
@@ -1774,6 +1774,9 @@ TEST_CASE("The manifest digests are pinned, so changing them is deliberate")
// carried no shadow census, so each validated across a change to what it compiled.
// Only the tag moved for these inputs.
{ .key = "manifest-v10", .digest = "7063f9c97376cce355decb8f99859612" },
+ // Retired with `objkey-v10` (the line structure): a v11 manifest points at an object of
+ // the generation before it. Only the tag moved.
+ { .key = "manifest-v11", .digest = "88fad3f9230114ec78ee0aa163916054" },
});
RequireNoRetiredDigest(manifestKey, Retired);
diff --git a/src/apps/pace-cc/main.cpp b/src/apps/pace-cc/main.cpp
index c3c179599..86733ab91 100644
--- a/src/apps/pace-cc/main.cpp
+++ b/src/apps/pace-cc/main.cpp
@@ -1602,7 +1602,7 @@ class ScopedFile
/// compile depends on.
struct SourceProbe
{
- std::string preprocessed; ///< Preprocessor output, no line markers.
+ std::string preprocessed; ///< Preprocessor output, markers reduced to their lines.
std::vector dependencyPaths; ///< Dependencies as the compiler spelled them.
/// Whether the probe's dependency record was READ, as opposed to reporting
@@ -1715,7 +1715,7 @@ struct ProbedDependencies
if (driver.usesDepfile)
{
- SourceProbe probe { .preprocessed = std::move(run.out), .dependencyPaths = {} };
+ SourceProbe probe { .preprocessed = Cc::KeyedPreprocessedText(run.out), .dependencyPaths = {} };
if (probeRequest.empty())
return probe;
// Non-empty, not merely present: the writability check above created the
@@ -1762,7 +1762,7 @@ struct ProbedDependencies
auto const unreadable = split.notePaths.empty() && Cc::CarriesUnreadableIncludeNotes(run.err);
reconciler.DependencyList(split.notePaths);
- return SourceProbe { .preprocessed = std::move(split.preprocessed),
+ return SourceProbe { .preprocessed = Cc::KeyedPreprocessedText(split.preprocessed),
.dependencyPaths = std::move(split.notePaths),
.dependenciesUnreadable = unreadable };
}
diff --git a/src/tests/MidCompileEditStub.cpp b/src/tests/MidCompileEditStub.cpp
index 58f0b6525..a77371988 100644
--- a/src/tests/MidCompileEditStub.cpp
+++ b/src/tests/MidCompileEditStub.cpp
@@ -35,7 +35,9 @@
//
// A REAL COMPILE names `-c` or `/c` and no preprocess-only or probe switch. A DISPATCH
// PREPROCESS names `-E` or `/E` and none of the switches that make it the key's preprocess
-// (`-E -P`, `/EP`), the include probe (`-E -v`) or the target probe (`-###`). Everything else --
+// (its dependency record, `-MD -MF` or `/showIncludes`: both preprocess runs keep their line
+// markers since #1687, so `-P` no longer tells them apart), the include probe (`-E -v`) or the
+// target probe (`-###`). Everything else --
// the key's preprocess, the banner probe, `-###` -- is forwarded untouched.
//
// Exit status: the real compiler's; 125 when the stub cannot do what it was asked (a missing
@@ -118,7 +120,8 @@ struct ClassifyRow
constexpr std::array CompileSwitches { "-c", "/c" };
constexpr std::array NotACompile { "-E", "/E", "-EP", "/EP", "-P", "/P", "-###" };
constexpr std::array PreprocessSwitches { "-E", "/E" };
-constexpr std::array NotADispatchPreprocess { "-P", "/P", "-EP", "/EP", "-v", "-###" };
+constexpr std::array NotADispatchPreprocess { "-P", "/P", "-EP", "/EP", "-v",
+ "-MD", "-MF", "/showIncludes", "-###" };
/// The classification, first match wins; no row matching is `Invocation::Other`.
constexpr std::array ClassifyTable {