- It's well-known that building gdb index could speed up the loading in gdb. However, simply adding '-DCMAKE_{EXE/SHARED/MODULE}_LINKER_FLAGS="-Wl,--gdb-index"' would cause linking error under certain enviroments. E.g., it's quite common that gold is not the default system linker but it's selected in LLVM build by specifying '-DLLVM_USE_LINKER=gold'. Under such case, -Wl,--gdb-index would cause linking issue when cmake needs to build executable for environment detection, says it needs to build a problem to check whether there a working C compiler as, following the default system linker, it still uses the linker without understanding of -Wl,--gdb-index. It's quite annoying if the default system linker cannot be easily switched to gold.
- LLVM_USE_GDBINDEX option is introduced to make life easier by only adding that option in LLVM build. So far, it only enables adding of that option when the linker to be used is gold.