Enable automatic debuginfod support with llvm tools
Description:
Tools like llvm-objdump and llvm-symbolizer can automatically fetch debug symbols from debuginfod servers when llvm is compiled with libcurl support (using LLVM_ENABLE_CURL=ON
).
I think it would be worthwhile to enable this support by default to make it easier to debug with sanitizers like MemorySanitizer. GDB and Valgrind have out-of-the-box support for debuginfod on Arch, so there is already precedent for similar integrations.
Additional info:
- package version(s):
clang 16.0.6-2
llvm 16.0.6-1
llvm-libs 16.0.6-1
A basic patch that works locally (the curl dependency bits might not be totally correct):
diff --git a/PKGBUILD b/PKGBUILD
index 248030e..6898035 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -9,7 +9,7 @@ url="https://llvm.org/"
license=('custom:Apache 2.0 with LLVM Exception')
makedepends=('cmake' 'ninja' 'zlib' 'zstd' 'libffi' 'libedit' 'ncurses'
'libxml2' 'python-setuptools' 'python-psutil' 'python-sphinx'
- 'python-recommonmark')
+ 'python-recommonmark' 'curl')
options=('staticlibs' '!lto') # https://github.com/llvm/llvm-project/issues/57740
_source_base=https://github.com/llvm/llvm-project/releases/download/llvmorg-$pkgver
source=($_source_base/llvm-$pkgver.src.tar.xz{,.sig}
@@ -76,6 +76,7 @@ build() {
-DLLVM_BUILD_LLVM_DYLIB=ON
-DLLVM_BUILD_TESTS=ON
-DLLVM_ENABLE_BINDINGS=OFF
+ -DLLVM_ENABLE_CURL=ON
-DLLVM_ENABLE_FFI=ON
-DLLVM_ENABLE_RTTI=ON
-DLLVM_ENABLE_SPHINX=ON
@@ -126,7 +127,7 @@ package_llvm() {
package_llvm-libs() {
pkgdesc="LLVM runtime libraries"
- depends=('gcc-libs' 'zlib' 'zstd' 'libffi' 'libedit' 'ncurses' 'libxml2')
+ depends=('gcc-libs' 'zlib' 'zstd' 'libffi' 'libedit' 'ncurses' 'libxml2' 'curl')
install -d "$pkgdir/usr/lib"
cp -P \
Steps to reproduce:
sudo pacman -S clang llvm
- Save the following code as
test.c
:
#include <stdio.h>
#include <string.h>
int main() {
const char *foo;
printf("%lu", strlen(foo));
return 0;
}
clang -fsanitize=memory test.c
./a.out
With the official Arch package, you will get output like this:
==294452==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x5e1279c6c43a in main (/home/s/code/test/a.out+0xb143a) (BuildId: 8e7a5180ae9876949eb6d6e3d3530a6096a21072)
#1 0x7a82c6d68ccf (/usr/lib/libc.so.6+0x27ccf) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
#2 0x7a82c6d68d89 in __libc_start_main (/usr/lib/libc.so.6+0x27d89) (BuildId: 8bfe03f6bf9b6a6e2591babd0bbc266837d8f658)
#3 0x5e1279bd9114 in _start (/home/s/code/test/a.out+0x1e114) (BuildId: 8e7a5180ae9876949eb6d6e3d3530a6096a21072)
With a modified package that includes -DLLVM_ENABLE_CURL=ON
, you will get additional symbol and line information:
==294488==WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x57277602643a in main (/home/s/code/test/a.out+0xb143a) (BuildId: 8e7a5180ae9876949eb6d6e3d3530a6096a21072)
#1 0x7d4907521ccf in __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#2 0x7d4907521d89 in __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:360:3
#3 0x572775f93114 in _start (/home/s/code/test/a.out+0x1e114) (BuildId: 8e7a5180ae9876949eb6d6e3d3530a6096a21072)