fix(ci): use CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded for sccache (documented fix)#432
Merged
Merged
Conversation
Per sccache documentation: cmake sets /Zi by default for MSVC, which writes debug info to a shared .pdb file. With Ninja + sccache + /MP running parallel cl.exe processes, this causes C1041 (PDB contention). Official fix (cmake >= 3.25): set CMAKE_POLICY_DEFAULT_CMP0141=NEW and CMAKE_MSVC_DEBUG_INFORMATION_FORMAT=Embedded, which instructs cmake to use /Z7 (debug info embedded in .obj) instead of /Zi for all targets. Replaces the manual /Z7 flags in CMAKE_CXX_FLAGS_RELEASE which only affected top-level targets and missed vendored subprojects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause (properly researched this time)
Per the sccache README: cmake sets
/Ziby default for MSVC, which writes debug info to a shared.pdbfile. With Ninja + sccache +/MPall running parallelcl.exeprocesses, multiple processes race to write the same PDB →C1041.Official fix
For cmake ≥ 3.25 (we use ~3.31.0), the documented solution is:
This instructs cmake to pass
/Z7to all targets (including vendored subprojects like admesh), embedding debug info in each.objfile. No shared PDB → no contention.Previous attempt (
/Z7viaCMAKE_CXX_FLAGS_RELEASE) only affected top-level targets and missed subprojects that set their own flags (like admesh).