What are the implications of using /Zi vs /Z7 for Visual Studio C++ projects?

前端 未结 5 1053
野性不改
野性不改 2020-12-23 20:21

Background

There are several different debug flags you can use with the Visual Studio C++ compiler. They are:

  • (none)
    • Creat
5条回答
  •  礼貌的吻别
    2020-12-23 20:46

    /Z7 keeps the debug info in the .obj files in CodeView format and lets the linker extract them into a .pdb while /Zi consolidates it into a common .pdb file during compilation already by sync'ing with mspdbsrv.exe.

    So /Z7 means more file IO, disc space being used and more work for the linker as there is lots of duplicate debug info in these obj files. But it also means every compilation is independent and thus can actually still be faster than /Zi with enough parallelization.

    By now they've improved the /Zi situation though by reducing the inter-process communication with mspdbsrv.exe: https://docs.microsoft.com/en-us/cpp/build/reference/zf

    Another use-case of /Z7 is for "standalone" (though larger) static libraries that don't require shipping a separate .pdb if you want that. That also prevents the annoying issues arising from the awful default vcxxx.pdb name cl uses as long as you don't fix it with a proper https://docs.microsoft.com/en-us/cpp/build/reference/fd-program-database-file-name, which most people forget.

    /ZI is like /Zi but adds additional data etc. to make the Edit and Continue feature work.

提交回复
热议问题