fmtlib / fmt

A modern formatting library
https://fmt.dev
Other
19.9k stars 2.43k forks source link

Invalid PDB file generated due to MSVC 2017 compatibility code #3926

Closed jaw closed 2 months ago

jaw commented 3 months ago

When compiling with these 3 lines on using MSVC2022, a PDB file is generated in the cmake build directory which is invalid:

https://github.com/fmtlib/fmt/blob/5eb68c0ef25070fe21861c37e6f8458b08453588/CMakeLists.txt#L323 https://github.com/fmtlib/fmt/blob/5eb68c0ef25070fe21861c37e6f8458b08453588/CMakeLists.txt#L324 https://github.com/fmtlib/fmt/blob/5eb68c0ef25070fe21861c37e6f8458b08453588/CMakeLists.txt#L325

Would it be possible to split out these properties and make them default on, but optionally disabled?

jaw commented 3 months ago

Or alternatively: maybe only do this if the compiler actually is msvc2017...

vitaut commented 3 months ago

PDB file is generated in the cmake build directory which is invalid

Could you elaborate why is it invalid and which directory would you expect it to be?

milianw commented 3 months ago

could it be that the issue lies in the fact that the CMAKE_BINARY_DIR is used? That's not where the .lib is being put necessarily, instead CMAKE_LIBRARY_OUTPUT_DIRECTORY is used which might point to a different location.

jaw commented 3 months ago

PDB file is generated in the cmake build directory which is invalid

Could you elaborate why is it invalid and which directory would you expect it to be?

Yes, I wasn't totally clear in my wording; the PDB file is corrupt, at least according to breakpad's dump_syms. Looking at it, it's smaller than the "real" working one, ~700k instead of >2MB.

pklima commented 3 months ago

@jaw Could you please describe a bit more about your environment?

Because for me on current master (5eb68c0), the size of Debug\fmtd.pdb is 815,104 bytes even if I revert my change from 52a99a6. How did you get this "real" PDB that is bigger?

I'm using VS2022 17.9.5 with:

cmake . -G "Visual Studio 17 2022"
cmake --build .
vitaut commented 2 months ago

It seems strange to me that the PDB file would be corrupt if you change the output directory. This might indicate a bug in a specific version of MSVC so I recommend reporting to Microsoft although I'm not opposed to a workaround. Closing for now but feel free to reopen with more details/repro per @pklima's comment.