Dear all,
I have problems trying to add a GDB index to my built Clang+LLVM binaries. This results in GDB startup being extremely slow (minutes) when trying to debug Clang.
I am building LLVM with Clang, using the upstream LLVM source code from around January this year. I am using the preinstalled GCC 11.2 on my Ubuntu 22.04 and GNU gold 1.16 to link, using -DLLVM_USE_LINKER=gold
at CMake configuration time.
I am building with -DLLVM_BUILD_LLVM_DYLIB=On
and -DLLVM_LINK_LLVM_DYLIB=On
for development purposes (but the problem does not change when not doing so). I am building in Debug
mode with LLVM_USE_SPLIT_DWARF
.
As far as I can see from the CMake scripts in LLVM’s build system, in my situation automatically --gdb-index
is added to the linker calls, and my GNU gold also seems to support this. I can see a .gdb_index
section in libLLVM.so
, which is however practically empty and does not seem to contain any actual index.
Maybe this existing but unusable section is the cause of the problem that GDB startup for debugging Clang is extremely slow, since it recreates the symbols each time at startup. A call to gdb-add-index
outputs “file in wrong format” and is not able to add an index.
Strangely, everything worked nicely until I installed Ubuntu 22.04 some weeks ago. Previously, it worked (using Ubuntu 18.04). I was either able to use gdb-add-index
in the beginning, or the index was already present in the created binaries. If I remember right, at some point when merging upstream LLVM changes to our project, adding the index was not necessary anymore, since it was already contained in the built binaries, maybe this was introduced by some change in LLVM’s build system.
Any hints would be greatly appreciated.