[PATCH] D92844: [gn build] Link with -Wl,--gdb-index

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 17 11:42:51 PST 2020


thakis updated this revision to Diff 312576.
thakis edited the summary of this revision.
thakis added a comment.

rebase, and only for full debug info


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92844/new/

https://reviews.llvm.org/D92844

Files:
  llvm/utils/gn/build/BUILD.gn


Index: llvm/utils/gn/build/BUILD.gn
===================================================================
--- llvm/utils/gn/build/BUILD.gn
+++ llvm/utils/gn/build/BUILD.gn
@@ -77,8 +77,24 @@
   if (host_os != "win") {
     if (symbol_level == 2) {
       cflags += [ "-g" ]
+
+      # For full debug-info -g builds, --gdb-index makes links ~15% slower, and
+      # gdb symbol reading time 1500% faster (lld links in 4.4 instead of 3.9s,
+      # and gdb loads and runs it in 2s instead of in 30s).  It's likely that
+      # people doing symbol_level=2 want to run a debugger (since
+      # symbol_level=2 isn't the default). So this seems like the right
+      # tradeoff.
+      if (host_os != "mac" && use_lld) {
+        cflags += [ "-ggnu-pubnames" ]  # PR34820
+        ldflags += [ "-Wl,--gdb-index" ]
+      }
     } else if (symbol_level == 1) {
       cflags += [ "-g1" ]
+
+      # For linetable-only -g1 builds, --gdb-index makes links ~8% slower, but
+      # links are 4x faster than -g builds so it's a fairly small absolute cost.
+      # On the other hand, gdb startup is well below 1s with and without the
+      # index. So don't use the flag here.
     }
     if (is_optimized) {
       cflags += [ "-O3" ]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92844.312576.patch
Type: text/x-patch
Size: 1227 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201217/b52ee63c/attachment.bin>


More information about the llvm-commits mailing list