MSVC PDB generation strategies
In !6721 (closed), I tried to improve CI by using flags that work with sccache
. However, CMake uses an incompatible strategy for PDB files in that it uses a per-library .pdb
file rather than per-TU files which just doesn't work with any (simple) caching mechanism. I propose a per-target property which can be used to select the PDB strategy for the target (names subject to bikeshedding):
set(CMAKE_PDB_STRATEGY PER_TU) # defaults to PER_TARGET for compat
set(CMAKE_PDB_LEVEL NONE) # or DEFAULT or EDIT_AND_CONTINUE
# also CMAKE_PDB_LEVEL_<CONFIG> with sensible defaults per config
AFAICT, EDIT_AND_CONTINUE
is not compatible with PER_TU
since it requires /ZI
which is incompatible with sccache
(fine for CI which doesn't need EDIT_AND_CONTINUE
anyways).
Things to consider:
- See CMP0091 for how to move the existing flags out of the global settings into these target properties
- Behaviors with MSVC-emulating compilers (
clang-cl
)? - Gathering per-TU
.pdb
files into a final target-wide.pdb
file (related: how doOBJECT
libraries do this?). - Could/should
PDB_LEVEL
be shared at some level with other compilers (-g
,-ggdb
,-Og
, etc.)? - Can
PDB_STRATEGY
also encompass-gsplit-dwarf
? - What to do if the strategy doesn't support the level? Downgrade the strategy, level, or error?
See also:
-
#10189 (closed) (
/Zi
vs/ZI
for Debug builds) -
#19549 (closed) (using
/Z
at all for Release builds) - #20256 (separate debug info, generally)
- #16874 (NatVis support)
- #20812 (default flag selection for MSVC)