[llvm] [BOLT] Fix test for systems where dl/pthread are not part of libc (PR #206944)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 1 03:53:17 PDT 2026


https://github.com/DmitriiMartynov created https://github.com/llvm/llvm-project/pull/206944

The bolt/test/runtime/setup-race.cpp test (including the original one) crashes with a segfault on Ubuntu 20.04 (glibc 2.31) because the dlsym symbol is not found.
According to the glibc 2.34 release notes, libpthread, libdl, libutil, and libanl have been integrated into libc. For older glibc versions, it is still necessary to link against libdl (for dlsym) and libpthread (for pthread_* symbols).

>From 5e5b0869f0560653192cc566b166b9849a14c9d3 Mon Sep 17 00:00:00 2001
From: Dmitrii Martynov <martynovdmitryvladimirovich at yandex.ru>
Date: Wed, 1 Jul 2026 13:00:48 +0300
Subject: [PATCH] [BOLT] Fix test for systems where dl/pthread are not part of
 libc

The bolt/test/runtime/setup-race.cpp test (including the original one) crashes
with a segfault on Ubuntu 20.04 (glibc 2.31) because the dlsym symbol is not
found.
According to the glibc 2.34 release notes, libpthread, libdl, libutil, and
libanl have been integrated into libc. For older glibc versions, it is still
necessary to link against libdl (for dlsym) and libpthread (for pthread_*
symbols).
---
 bolt/test/runtime/setup-race.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bolt/test/runtime/setup-race.cpp b/bolt/test/runtime/setup-race.cpp
index a601731967aac..728903e50626d 100644
--- a/bolt/test/runtime/setup-race.cpp
+++ b/bolt/test/runtime/setup-race.cpp
@@ -3,7 +3,7 @@
 // when libstdcxx.so invokes global constructors that call malloc.
 
 // REQUIRES: system-linux
-// RUN: %clangxx %cxxflags -Wl,-q %s -o %t.exe -D_GNU_SOURCE -g
+// RUN: %clangxx %cxxflags -Wl,-q %s -o %t.exe -D_GNU_SOURCE -g -ldl -lpthread
 // RUN: llvm-bolt -instrument %t.exe -o %t.bolt.exe
 // RUN: %t.bolt.exe
 



More information about the llvm-commits mailing list