windowsclangllvmpdb-files

clang++ 14 does not generate PDB file


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.


Solution

  • It seems in modern Clang it's enough to pass -g (both when compiling and linking). This works regardless of the linker (with Microsoft's linker and with -fuse-ld=lld).

    It can also be useful to add -gcolumn-info when compiling to include column information (to know what part of a line is being ran, not just the line number).


    When I originall wrote this answer, I had to pass -g -gcodeview when compiling, and -fuse-ld=lld -g -Wl,--pdb= when linking (you can add ??.pdb after = to customize the PDB name, it defaults to the executable name with extension changed to .pdb).