-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[lldb][test] Enable static linking with libcxx for import-std-module tests #98701
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-lldb Author: Vladislav Dzhidzhoev (dzhidzhoev) Changes--whole-archive and --allow-multiple-definition options has been added to linker flags of these import-std-module tests in order to make them pass with libcxx static linking enabled. Darwin has been excluded since it doesn't seem to build in this configuration. Also, some tests were switched from system stdlib to libcxx since the problem described in https://reviews.llvm.org/D139361 seems to be fixed. Full diff: https://github.com/llvm/llvm-project/pull/98701.diff 5 Files Affected:
diff --git a/lldb/test/API/commands/expression/import-std-module/array/Makefile b/lldb/test/API/commands/expression/import-std-module/array/Makefile
index f938f7428468..b96106a55b85 100644
--- a/lldb/test/API/commands/expression/import-std-module/array/Makefile
+++ b/lldb/test/API/commands/expression/import-std-module/array/Makefile
@@ -1,3 +1,8 @@
USE_LIBCPP := 1
CXX_SOURCES := main.cpp
+
+ifneq ($(OS),Darwin)
+ LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition
+endif
+
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/Makefile b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/Makefile
index 98638c56f0b9..b96106a55b85 100644
--- a/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/Makefile
+++ b/lldb/test/API/commands/expression/import-std-module/deque-dbg-info-content/Makefile
@@ -1,5 +1,8 @@
-# FIXME: once the expression evaluator can handle std libraries with debug
-# info, change this to USE_LIBCPP=1
-USE_SYSTEM_STDLIB := 1
+USE_LIBCPP := 1
CXX_SOURCES := main.cpp
+
+ifneq ($(OS),Darwin)
+ LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition
+endif
+
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/Makefile b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/Makefile
index 98638c56f0b9..b96106a55b85 100644
--- a/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/Makefile
+++ b/lldb/test/API/commands/expression/import-std-module/list-dbg-info-content/Makefile
@@ -1,5 +1,8 @@
-# FIXME: once the expression evaluator can handle std libraries with debug
-# info, change this to USE_LIBCPP=1
-USE_SYSTEM_STDLIB := 1
+USE_LIBCPP := 1
CXX_SOURCES := main.cpp
+
+ifneq ($(OS),Darwin)
+ LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition
+endif
+
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/Makefile b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/Makefile
index 98638c56f0b9..b96106a55b85 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/Makefile
+++ b/lldb/test/API/commands/expression/import-std-module/vector-dbg-info-content/Makefile
@@ -1,5 +1,8 @@
-# FIXME: once the expression evaluator can handle std libraries with debug
-# info, change this to USE_LIBCPP=1
-USE_SYSTEM_STDLIB := 1
+USE_LIBCPP := 1
CXX_SOURCES := main.cpp
+
+ifneq ($(OS),Darwin)
+ LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition
+endif
+
include Makefile.rules
diff --git a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/Makefile b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/Makefile
index f938f7428468..b96106a55b85 100644
--- a/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/Makefile
+++ b/lldb/test/API/commands/expression/import-std-module/vector-of-vectors/Makefile
@@ -1,3 +1,8 @@
USE_LIBCPP := 1
CXX_SOURCES := main.cpp
+
+ifneq ($(OS),Darwin)
+ LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition
+endif
+
include Makefile.rules
|
@@ -1,5 +1,8 @@ | |||
# FIXME: once the expression evaluator can handle std libraries with debug | |||
# info, change this to USE_LIBCPP=1 | |||
USE_SYSTEM_STDLIB := 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this related to the linker flag changes in any way? We rely on this on the macOS bots, so it doesn't sound like the underlying issue the FIXME referred to was resolved. If it's an unrelated change, I'd prefer opening a separate PR for these
@@ -1,3 +1,8 @@ | |||
USE_LIBCPP := 1 | |||
CXX_SOURCES := main.cpp | |||
|
|||
ifneq ($(OS),Darwin) | |||
LD_EXTRAS := -Xlinker --whole-archive -Xlinker --allow-multiple-definition |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you elaborate on why this is necessary? Example test failures would be great
…tests --whole-archive and --allow-multiple-definition options has been added to linker flags of these import-std-module tests in order to make them pass with libcxx static linking enabled. Darwin has been excluded since it doesn't seem to build in such configuration. Also, some tests were switched from system stdlib to libcxx since the problem described in https://reviews.llvm.org/D139361 seems to be fixed.
47f541c
to
c5332e4
Compare
It seems #106885 fixed the issue for The following 3 tests prevent the buildbot from being green
|
Can you add in the PR description why the |
This patch should fix the following tests: See the buildbot https://lab.llvm.org/staging/#/builders/195/builds/4464 But probably it is possible to update this patch to keep |
This patch fixes the error https://lab.llvm.org/staging/#/builders/195/builds/4464 ``` File "llvm-project/lldb/test/API/commands/expression/import-std-module/array/TestArrayFromStdModule.py", line 55, in test self.expect_expr("a.at(0)", result_type=value_type, result_value="3") Hint: The expression tried to call a function that is not present in the target, perhaps because it was optimized out by the compiler. ``` Note adding the usage of `a.at(0)` to main.cpp did not help. It is the alternative to llvm#98701.
I doubt those linker flags are going to work on windows. It might be more "portable" to ensure the symbols are present by using them from inside the program. |
Those linker flags work on Windows. |
I guess it will with clang+lld (which is the only way we can run the test suite now), though I still find this suboptimal -- in particular, I think the multiple definition thingy plants us firmly into undefined behavior territory. Did you check that |
Agree with Pavel here, it would be good to figure out what exactly is going wrong in this test. FWIW, we don't actually want to emit Since this is quite tricky to debug, and has been a known issue for a while and (i think) only happens when we built libc++ with debug symbols, I'd be fine with skipping the test on Linux until we figure out what the root cause is. |
This is the alternative to llvm#98701. See for more details: https://reviews.llvm.org/D139361 https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
Agree. Please see #112530. |
This is the alternative to #98701. See for more details: https://reviews.llvm.org/D139361 https://discourse.llvm.org/t/lldb-test-failures-on-linux/80095
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 llvm#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 llvm#98701, without checking whether libcxx is linked statically looks like a less clean solution, but I'm not sure about that.
Closed in favor of #118986 |
--whole-archive and --allow-multiple-definition options has been added to linker flags of these import-std-module tests in order to make them pass with libcxx static linking enabled.
Darwin has been excluded since it doesn't seem to be built in this configuration.
Also, some tests were switched from system stdlib to libcxx since the problem described in https://reviews.llvm.org/D139361 seems to be fixed.