[PATCH] D77154: [cmake] Add LLVM_USE_GDB_INDEX option for gold linker

Dominic Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 31 11:26:22 PDT 2020


ddcc created this revision.
ddcc added reviewers: pcc, aprantl.
Herald added subscribers: arphaman, mgorny.
Herald added a project: LLVM.

Add option for -Wl,--gdb-index and update documentation


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D77154

Files:
  llvm/CMakeLists.txt
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/docs/CMake.rst


Index: llvm/docs/CMake.rst
===================================================================
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -639,6 +639,15 @@
   Rewrite absolute source paths in sources and debug info to relative ones. The
   source prefix can be adjusted via the LLVM_SOURCE_PREFIX variable.
 
+**LLVM_USE_SPLIT_DWARF**:BOOL
+  If enabled, store DWARF debug information separately from object files. Enabling
+  this option can speed up build times in Debug configurations.
+
+**LLVM_USE_GDB_INDEX**:BOOL
+  If enabled, generate GDB index tables for locating split DWARF debug
+  information at link time. Enabling this option can speed up GDB debugging
+  startup times in Debug configurations with LLVM_USE_SPLIT_DWARF enabled.
+
 CMake Caches
 ============
 
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===================================================================
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -773,6 +773,12 @@
   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
       CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     add_compile_options(-gsplit-dwarf)
+
+    # Turn on -Wl,--gdb-index if requested and supported
+    if (LLVM_USE_GDB_INDEX AND
+        (LLVM_USE_LINKER STREQUAL "gold" OR LLVM_USE_LINKER STREQUAL "lld"))
+      append("-Wl,--gdb-index" CMAKE_EXE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
+    endif()
   endif()
 endif()
 
Index: llvm/CMakeLists.txt
===================================================================
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -477,6 +477,9 @@
 option(LLVM_USE_SPLIT_DWARF
   "Use -gsplit-dwarf when compiling llvm." OFF)
 
+option(LLVM_USE_GDB_INDEX
+  "Use -Wl,--gdb-index when compiling llvm." OFF)
+
 # Define an option controlling whether we should build for 32-bit on 64-bit
 # platforms, where supported.
 if( CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT (WIN32 OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX"))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D77154.253930.patch
Type: text/x-patch
Size: 1957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200331/16fddf78/attachment.bin>


More information about the llvm-commits mailing list