[libcxx-commits] [libcxx] [libc++][test][shared] Add @CMAKE_DL_LIBS@ when needed (PR #222797)

Amilendra Kodithuwakku via libcxx-commits libcxx-commits at lists.llvm.org
Sat Sep 12 08:47:10 PDT 2026


https://github.com/amilendra updated https://github.com/llvm/llvm-project/pull/222797

>From c6e5facba89a91dc7571358ef8f0381b67d17a93 Mon Sep 17 00:00:00 2001
From: Amilendra Kodithuwakku <Amilendra.Kodithuwakku at arm.com>
Date: Thu, 10 Sep 2026 21:38:06 +0000
Subject: [PATCH] [libc++][test][shared] Add @CMAKE_DL_LIBS@ when needed

libcxx shared tests on systems with glibc older than 2.34 fail
due to missing dynamic loading library provided symbols.
e.g. RHEL-8, Ubuntu-20.

Fix by leveraging @CMAKE_DL_LIBS@ to provide the list of required
libraries.
---
 libcxx/test/configs/llvm-libc++-shared.cfg.in | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libcxx/test/configs/llvm-libc++-shared.cfg.in b/libcxx/test/configs/llvm-libc++-shared.cfg.in
index 71e56e732e796..fa97536ee41fd 100644
--- a/libcxx/test/configs/llvm-libc++-shared.cfg.in
+++ b/libcxx/test/configs/llvm-libc++-shared.cfg.in
@@ -7,8 +7,13 @@ config.substitutions.append(('%{flags}',
 config.substitutions.append(('%{compile_flags}',
     '-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I %{libcxx-dir}/test/support'
 ))
+
+link_flags = []
+if '@CMAKE_DL_LIBS@':
+    link_flags.append('-l at CMAKE_DL_LIBS@')
 config.substitutions.append(('%{link_flags}',
-    '-nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++'
+    '-nostdlib++ -L %{{lib-dir}} -Wl,-rpath,%{{lib-dir}} '
+    '-lc++ {}'.format(' '.join(link_flags))
 ))
 config.substitutions.append(('%{exec}',
     '%{executor} --execdir %{temp} -- '



More information about the libcxx-commits mailing list