1 | clang.exe -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:test.pdb -o test.exe test.c |
mmozeiko
Clang supports pdb generation just fine. For example, to use it with lld.exe from mingw-w64-x86_64-lld package (in msys2) do this:
1 clang.exe -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:test.pdb -o test.exe test.c
This will create test.pdb next to test.exe which will work in Visual Studio just fine.
If you are using clang binary build from offical website then replace lld.exe with lld-link.exe.
SaraPanda
Hi there.
Just wondering if you could give a rough estimate as to when the windows version will support the DWARF format.
I try to avoid microsoft products as much as possible and so prefer to use clang/mingw64 which doesn't support PDB generation.
Thanks.
mmozeiko
Clang supports pdb generation just fine. For example, to use it with lld.exe from mingw-w64-x86_64-lld package (in msys2) do this:
1 clang.exe -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:test.pdb -o test.exe test.c
This will create test.pdb next to test.exe which will work in Visual Studio just fine.
If you are using clang binary build from offical website then replace lld.exe with lld-link.exe.
1 | clang.exe -gcodeview test.c -o test.exe |
1 | clang-cl.exe /Fetest.exe /Zi test.c |
spx
I did quickly try out clang in the past and never got it to emit line information.
1 | clang.exe -target x86_64-windows-gnu -fuse-ld=lld.exe -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe |
1 | file example.exe |
1 | lld: error: unable to find library -lmingw32 |
1 | -target x86_64-windows-gnu |
1 2 3 4 | int main(int argc, char **argv) { return(0); } |
1 | clang.exe -fuse-ld=lld-link.exe -g -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe |
1 | clang.exe -target x86_64-windows-gnu -fuse-ld=lld.exe -g -gcodeview -Wl,/debug,/pdb:example.pdb example.c -o example.exe |
1 | clang.exe -target x86_64-windows-gnu example.c -o example.exe |
1 | clang.exe -fuse-ld=lld.exe -target x86_64-windows-gnu example.c -o example.exe |
SaraPanda
I also had issues using lld linker from LLVM, rather than the default ld from binutils.
For example, this works:
1 clang.exe -target x86_64-windows-gnu example.c -o example.exe
However, this faults:
1 clang.exe -fuse-ld=lld.exe -target x86_64-windows-gnu example.c -o example.exe
It seems to be an issue using lld with mingw.
mmozeiko
ld.exe is from binutils. Binutils does not know anything about MSVC linker arguments or generating .pdb debug info. To use MSVC style linker arguments you need to use lld which understands both - MSVC linker style and binutils syle arguments. And is capable of generating .pdb file not only dwarf.
1 | clang.exe -fuse-ld=lld -target x86_64-windows-gnu -g -gcodeview -Wl,/debug,/pdb:test.pdb test.c -o test.exe |
1 2 3 4 5 6 7 8 9 | C:\msys2\mingw64\bin>clang --version clang version 7.0.1 (tags/RELEASE_701/final) Target: x86_64-w64-windows-gnu Thread model: posix InstalledDir: C:\msys2\mingw64\bin C:\msys2\mingw64\bin>lld --version lld is a generic driver. Invoke ld.lld (Unix), ld64.lld (macOS), lld-link (Windows), wasm-lld (WebAssembly) instead |