@@ -30,7 +30,7 @@ struct CommandDialect {
3030 std::string_view compileOnly; // "-c" | "/c"
3131 std::string_view outputObjPrefix; // "-o " | "/Fo:"
3232 std::string_view optPrefix; // "-O" | "/O"
33- std::string_view debugFlags; // "-g" | "/Zi /FS "
33+ std::string_view debugFlags; // "-g" | "/Z7 "
3434 std::string_view alwaysFlags; // "" | "/nologo /EHsc /utf-8"
3535 // Same rationale as forceCxxLangArgv: the argv consumer gets tokens, not
3636 // a string it has to split. Both spans point at static arrays below.
@@ -205,6 +205,18 @@ std::optional<CrtWordVerdict> check_crt_word(std::string_view word,
205205 bool staticCrt,
206206 std::string_view key);
207207
208+ // A SHARED-PDB WORD IS REFUSED ON cl.exe (2026.11.7.1). `/Zi` and `/ZI`
209+ // write a compile's debug information into a PDB that every compile of a
210+ // directory shares, through mspdbsrv.exe, a server the first cl.exe starts and
211+ // that outlives it; `/FS` serialises those writes through it. Each compile
212+ // runs in a process unit that retires with the compile, and the server is a
213+ // member of the unit that started it: retiring that unit ends the server under
214+ // every other compile writing through it. `[profile.<name>] debug = true`
215+ // gives each object its own debug information (`/Z7`). Returns the refusal
216+ // for such a word, either dash, and nullopt for any other word.
217+ std::optional<std::string> check_shared_pdb_word (std::string_view word,
218+ std::string_view key);
219+
208220// The two dialect rows, reachable without a Toolchain. Exposed so the MSVC
209221// row — which no build reaches until the cl.exe backend lands — can still be
210222// unit-tested, and so callers that already know the shape they want (the
@@ -273,7 +285,15 @@ constexpr CommandDialect kMsvcDialect{
273285 .compileOnly = " /c" ,
274286 .outputObjPrefix = " /Fo:" ,
275287 .optPrefix = " /O" ,
276- .debugFlags = " /Zi /FS" ,
288+ // DEBUG INFORMATION IN EACH OBJECT (/Z7), not in a PDB that every compile
289+ // of a directory shares (/Zi /FS). The shared PDB is written through
290+ // mspdbsrv.exe, which the first cl.exe starts and which outlives it by
291+ // seconds; the compiler executor retires each compile's process unit, and
292+ // retiring the unit that holds the server ended the server under the
293+ // concurrent compiles writing through it (C1090, PDB API error 23). An
294+ // object that carries its own debug information is also complete on its
295+ // own, which the object cache and a taken-over build directory assume.
296+ .debugFlags = " /Z7" ,
277297 .alwaysFlags = " /nologo /EHsc /utf-8" ,
278298 .alwaysFlagsArgv = kMsvcAlwaysArgv ,
279299 .libFlag = " {}.lib" ,
@@ -333,6 +353,21 @@ std::string std_flag_for(const CommandDialect& d,
333353 return std::format (" {}{}" , d.stdPrefix , canonical);
334354}
335355
356+ std::optional<std::string> check_shared_pdb_word (std::string_view word,
357+ std::string_view key) {
358+ if (word.size () != 3 || (word[0 ] != ' /' && word[0 ] != ' -' ))
359+ return std::nullopt ;
360+ const auto spelling = word.substr (1 );
361+ if (spelling != " Zi" && spelling != " ZI" && spelling != " FS" )
362+ return std::nullopt ;
363+ return std::format (
364+ " `{}` in {} writes debug information through mspdbsrv.exe, a PDB server "
365+ " shared by every compile and ended with the compile that started it. "
366+ " Remove the flag: `[profile.<name>] debug = true` gives each object its "
367+ " own debug information (/Z7)" ,
368+ word, key);
369+ }
370+
336371std::optional<CrtWordVerdict> check_crt_word (std::string_view word,
337372 bool staticCrt,
338373 std::string_view key) {
0 commit comments