[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 12:39:15 PST 2020


This revision was automatically updated to reflect the committed changes.
Closed by commit rG7e33fd9ce2d8: [gn build] Link with -Wl,--gdb-index when linking with LLD (authored by thakis).

Changed prior to commit:
  https://reviews.llvm.org/D92844?vs=312576&id=312588#toc

Repository:
  rG LLVM Github Monorepo

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,25 @@
   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, and people using -g1 likely don't use a debugger. So don't use
+      # the flag here.
     }
     if (is_optimized) {
       cflags += [ "-O3" ]


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


More information about the llvm-commits mailing list