[llvm] b1b68b4 - [CMake] Add `--gdb-index` option to linker if split dwarf compiling

Anton Afanasyev via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 30 02:23:38 PDT 2021


Author: Anton Afanasyev
Date: 2021-08-30T12:23:21+03:00
New Revision: b1b68b4c0190b7fc7f0ebe823277966056b39494

URL: https://github.com/llvm/llvm-project/commit/b1b68b4c0190b7fc7f0ebe823277966056b39494
DIFF: https://github.com/llvm/llvm-project/commit/b1b68b4c0190b7fc7f0ebe823277966056b39494.diff

LOG: [CMake] Add `--gdb-index` option to linker if split dwarf compiling

The option `--gdb-index` should be passed to linker if compiler is invoked
with `-gsplit-dwarf` option. This allows debugger to locate the appropriate
units quickly. See "Invocation" section here: https://gcc.gnu.org/wiki/DebugFission

Suggested by @dblaikie here: https://reviews.llvm.org/D68556#1698442

Differential Revision: https://reviews.llvm.org/D108776

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 0c3419390c275..b139344ce2a7d 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -901,6 +901,10 @@ if (LLVM_USE_SPLIT_DWARF AND
   if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
       CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
     add_compile_options(-gsplit-dwarf)
+  include(LLVMCheckLinkerFlag)
+  llvm_check_linker_flag(CXX "-Wl,--gdb-index" LINKER_SUPPORTS_GDB_INDEX)
+  append_if(LINKER_SUPPORTS_GDB_INDEX "-Wl,--gdb-index"
+    CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)
   endif()
 endif()
 


        


More information about the llvm-commits mailing list