Home > OS >  clang 14 does not generate PDB file
clang 14 does not generate PDB file

Time:11-13

My objective

I want to generate the PDB file of my app using clang 14.0.6 and mingw ucrt (the GCC-like) and NOT clang-cl / clang-cpp.

My problem

The PDB file is not generated.

What I tried

clang   -march=native -O3 -g -gcodeview main.cpp -o filecomp.exe

I looked for info in --help, clang github issues and existing SO questions but didn't find any answer so far.
Most people talk about old versions of Clang which solutions didn't work for me or Clang-cl or even visual studio bundled clang-cl which are irrelevant to my case.

CodePudding user response:

Use -g -gcodeview when compiling, then -fuse-ld=lld -g -Wl,--pdb= when linking. This produces ??.pdb alongside ??.exe.

You can also pass a custom PDB file path to -Wl,--pdb=??.

I'm unsure if -g does anything when linking, but the Clang doesn't warn about it, so I prefer to keep it. It does warn about -gcodeview being unused if specified when linking.

  • Related