[Lldb-commits] [lldb] [lldb][test] Skip libc++ tests if it is linked statically (PR #113935)

Vladislav Dzhidzhoev via lldb-commits lldb-commits at lists.llvm.org
Mon Oct 28 10:00:23 PDT 2024


https://github.com/dzhidzhoev updated https://github.com/llvm/llvm-project/pull/113935

>From 9186c689391a96b09f947e6799d205054cf199ab Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev <vdzhidzhoev at accesssoftek.com>
Date: Mon, 28 Oct 2024 16:46:39 +0100
Subject: [PATCH 1/3] Revert "[lldb][test] Skip Test*FromStdModule tests on
 Linux for now (#112530)"

This reverts commit 87f126243beb69b8b02e5cd4df762bc8a6f1f8cc.
---
 .../expression/import-std-module/array/TestArrayFromStdModule.py | 1 -
 .../TestDbgInfoContentVectorFromStdModule.py                     | 1 -
 .../vector-of-vectors/TestVectorOfVectorsFromStdModule.py        | 1 -
 3 files changed, 3 deletions(-)

diff --git a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
index bafc7628296217..13ab6b0c9ac1fb 100644
--- a/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py
@@ -10,7 +10,6 @@
 class TestCase(TestBase):
     @add_test_categories(["libc++"])
     @skipIf(compiler=no_match("clang"))
-    @skipIfLinux  # https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
     def test(self):
         self.build()
 
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
index 71eaeef20e792d..1c32222e64f14c 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/TestDbgInfoContentVectorFromStdModule.py
@@ -14,7 +14,6 @@ class TestDbgInfoContentVector(TestBase):
     @skipIf(compiler="clang", compiler_version=["<", "12.0"])
     @skipIf(macos_version=["<", "14.0"])
     @skipIfDarwin  # https://github.com/llvm/llvm-project/issues/106475
-    @skipIfLinux  # https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
     def test(self):
         self.build()
 
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
index e9415fd53651f7..a1f33271f39d2f 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/TestVectorOfVectorsFromStdModule.py
@@ -10,7 +10,6 @@
 class TestVectorOfVectors(TestBase):
     @add_test_categories(["libc++"])
     @skipIf(compiler=no_match("clang"))
-    @skipIfLinux  # https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
     def test(self):
         self.build()
 

>From 77b2ad3e3975ed5b4e0f23efd64999abc92175e7 Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev <vdzhidzhoev at accesssoftek.com>
Date: Wed, 16 Oct 2024 17:29:07 +0200
Subject: [PATCH 2/3] [lldb][test] Skip libc++ tests if it is linked
 statically.

Some tests from 'import-std-module' used to fail on the builder
https://lab.llvm.org/staging/#/builders/195/builds/4470, since libcxx is
set up to be linked statically with the binary on it.

Thus, they were temporarily disabled in #112530. Here, this commit is
reverted.

When libcxx is linked with a program as an archive of static libraries,
functions that aren't used in the program are omitted. Then, jitted
expressions from the tests try calling several functions
that aren't present in the process image, which causes the failure.

LLD (and GNU ld AFAIK) links a binary with libcxx shared library
if libc++.so is present in corresponding library search paths.
Otherwise, it tries static linking. Here, a linker flag is added
to a clang call in libcxx configuration, that ensures that
libc++.so is present and found by linker.

Forcing linker to keep all functions from libcxx archive in this way #98701,
without checking whether libcxx is linked statically looks like a less
clean solution, but I'm not sure about that.
---
 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 681ea1638f2d6f..46673a9886c57e 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -776,7 +776,7 @@ def canRunLibcxxTests():
 
     if platform == "linux":
         with tempfile.NamedTemporaryFile() as f:
-            cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-o", f.name, "-"]
+            cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-l:libc++.so", "-o", f.name, "-"]
             p = subprocess.Popen(
                 cmd,
                 stdin=subprocess.PIPE,

>From 83bcf7213769441886a41cd527ef40ef6c92b24e Mon Sep 17 00:00:00 2001
From: Vladislav Dzhidzhoev <vdzhidzhoev at accesssoftek.com>
Date: Mon, 28 Oct 2024 18:00:06 +0100
Subject: [PATCH 3/3] Formatting fix

---
 lldb/packages/Python/lldbsuite/test/dotest.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index 46673a9886c57e..61de0fa089ed1a 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -776,7 +776,15 @@ def canRunLibcxxTests():
 
     if platform == "linux":
         with tempfile.NamedTemporaryFile() as f:
-            cmd = [configuration.compiler, "-xc++", "-stdlib=libc++", "-l:libc++.so", "-o", f.name, "-"]
+            cmd = [
+                configuration.compiler,
+                "-xc++",
+                "-stdlib=libc++",
+                "-l:libc++.so",
+                "-o",
+                f.name,
+                "-",
+            ]
             p = subprocess.Popen(
                 cmd,
                 stdin=subprocess.PIPE,



More information about the lldb-commits mailing list