[llvm] Default to LLDB debugger tuning for shared library builds (PR #83083)

Alexander Richardson via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 26 15:52:58 PST 2024


https://github.com/arichardson created https://github.com/llvm/llvm-project/pull/83083

Currently, it is not possible to sensibly debug LLVM using shared library builds with LLDB since types are not resolved across shared library boundaries. As a workaround we can enable -glldb to emit standalone debug info which ensures we get a working debugging experience at the expense of increased disk usage.

See https://github.com/llvm/llvm-project/issues/60994#issuecomment-1447337360
and the closed https://github.com/llvm/llvm-project/pull/82527.

>From d053d0c65868f55f4ad4e8a94d0a7b78c8330db4 Mon Sep 17 00:00:00 2001
From: Alex Richardson <alexrichardson at google.com>
Date: Wed, 21 Feb 2024 15:50:22 -0800
Subject: [PATCH] Default to LLDB debugger tuning for shared library builds

Currently, it is not possible to sensibly debug LLVM using shared library
builds with LLDB since types are not resolved across shared library
boundaries. As a workaround we can enable -glldb to emit standalone debug
info which ensures we get a working debugging experience at the expense of
increased disk usage.

See https://github.com/llvm/llvm-project/issues/60994#issuecomment-1447337360
---
 llvm/cmake/modules/HandleLLVMOptions.cmake | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 08ff49ded57a14..19dfb3083f571e 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -1061,6 +1061,17 @@ if (LLVM_USE_SPLIT_DWARF AND
   endif()
 endif()
 
+if (BUILD_SHARED_LIBS AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND
+    ((uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG") OR
+     (uppercase_CMAKE_BUILD_TYPE STREQUAL "RELWITHDEBINFO")))
+  # When using a shared libraries build, tune the debug info output for LLDB
+  # (which enables standalone debug info) since otherwise LLDB users will not be
+  # able to print types from other shared libraries (e.g. SmallVector printing
+  # will only work inside libLLVMSupport).
+  # See https://github.com/llvm/llvm-project/issues/60994#issuecomment-1447337360
+  add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-glldb>)
+endif()
+
 add_compile_definitions(__STDC_CONSTANT_MACROS)
 add_compile_definitions(__STDC_FORMAT_MACROS)
 add_compile_definitions(__STDC_LIMIT_MACROS)



More information about the llvm-commits mailing list