[libcxx-commits] [libcxx] [lldb] [lldb][test] Don't run libc++ API tests without a locally built libc++ (PR #162657)

Michael Buch via libcxx-commits libcxx-commits at lists.llvm.org
Thu Oct 9 07:08:51 PDT 2025


https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/162657

>From 0b23bd05541354a493acea8fbb2c89b771a3e774 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 9 Oct 2025 13:06:40 +0100
Subject: [PATCH 1/3] [lldb][test] Don't run libc++ API tests without a locally
 built libc++

API tests in the `libc++` category will try their best to build against a locally built libc++. If none exists, the `Makefile.rules` currently fall back to using the system libc++.

The issue with falling back to the system libc++ is that we are now potentially not testing what we intended to. But we also can't rely on certain libc++ features being available that the tests are trying to use. On Apple platforms this is a configuration error (because libc++ is the only stdlib supported), but we can't make it an error on Linux because a user might want to run the API tests with libstdc++.

The Ubunutu 22.04 bots on the Apple fork are failing to run following tests are failing:
* `TestLibcxxInternalsRecognizer.py`
* `TestDataFormatterStdRangesRefView.py`
because the system stdlib doesn't have `std::ranges` support yet. And the tests just fail to build. Building libc++ on those bots is also not possible because the system compiler is too old (and the Apple fork builds all the subprojects standalone, so it requires the system compiler).

This patch marks tests in the `libc++` category as `UNSUPPORTED` if no local libc++ is available.

The downside is that we will inevitably lose coverage on bots that were running these tests without a local libc++. Arguably those weren't really testing the right thing. But for vendors with LLDB forks it might have been useful to at least know that the tests on the fork don't fail against the system libc++.
---
 lldb/packages/Python/lldbsuite/test/dotest.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 2966ac04227cb..0c854c23e31a4 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -788,7 +788,11 @@ def canRunLibcxxTests():
     if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin():
         return True, "libc++ always present"
 
+    # Make sure -stdlib=libc++ works since that's how the tests will be built.
     if platform == "linux":
+        if not configuration.libcxx_include_dir or not configuration.libcxx_library_dir:
+            return False, "API tests require a locally built libc++."
+
         with temp_file.OnDiskTempFile() as f:
             cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.path, "-"]
             p = subprocess.Popen(

>From cc9b3e83f4e23723ea94314c18432c244e298e31 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 9 Oct 2025 15:08:21 +0100
Subject: [PATCH 2/3] fixup! move comment

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 0c854c23e31a4..1d474a2180d22 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -788,11 +788,11 @@ def canRunLibcxxTests():
     if lldbplatformutil.target_is_android() or lldbplatformutil.platformIsDarwin():
         return True, "libc++ always present"
 
-    # Make sure -stdlib=libc++ works since that's how the tests will be built.
     if platform == "linux":
         if not configuration.libcxx_include_dir or not configuration.libcxx_library_dir:
             return False, "API tests require a locally built libc++."
 
+        # Make sure -stdlib=libc++ works since that's how the tests will be built.
         with temp_file.OnDiskTempFile() as f:
             cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.path, "-"]
             p = subprocess.Popen(

>From 2ed5ef0e79b4dc861f83e1ca4aaec50613609209 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Thu, 9 Oct 2025 15:08:38 +0100
Subject: [PATCH 3/3] TEMPORARY: touch libcxx and lldb tests

---
 libcxx/src/memory.cpp                                           | 2 ++
 .../generic/string/TestDataFormatterStdString.py                | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/libcxx/src/memory.cpp b/libcxx/src/memory.cpp
index 9be40cb9c1285..a3db8d3df37fd 100644
--- a/libcxx/src/memory.cpp
+++ b/libcxx/src/memory.cpp
@@ -29,6 +29,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
 
 bad_weak_ptr::~bad_weak_ptr() noexcept {}
 
+struct __Blah {} __blah;
+
 const char* bad_weak_ptr::what() const noexcept { return "bad_weak_ptr"; }
 
 __shared_count::~__shared_count() {}
diff --git a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
index 6a27b5d2f0780..dee5975557458 100644
--- a/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
+++ b/lldb/test/API/functionalities/data-formatter/data-formatter-stl/generic/string/TestDataFormatterStdString.py
@@ -81,7 +81,7 @@ def cleanup():
                 % ns,
                 "(%s::string *) null_str = nullptr" % ns,
                 '(CustomString) custom_str = "hello!"',
-                '(CustomWString) custom_wstr = L"hello!"',
+                '(CustomWString) custom_ = L"hello!"',
             ],
         )
 



More information about the libcxx-commits mailing list