Index: llvm/utils/gn/build/BUILD.gn =================================================================== --- llvm/utils/gn/build/BUILD.gn +++ llvm/utils/gn/build/BUILD.gn @@ -75,6 +75,18 @@ if (host_os != "win") { if (is_debug) { cflags += [ "-g" ] + + # --gdb-index makes links ~15% slower, and gdb symbol reading time + # 15x faster (lld links in 4.4 instead of 3.9s, and gdb loads and runs + # it in 2s instead of in 30s). Since the GN build defaults to release + # builds, it's likely that people doing debug builds want to run a + # debugger. So this seems like the right tradeoff. + if (host_os != "mac") { + if (use_lld) { + cflags += [ "-ggnu-pubnames" ] # PR34820 + } + ldflags += [ "-Wl,--gdb-index" ] + } } if (is_optimized) { cflags += [ "-O3" ]