[Lldb-commits] [lldb] c38eeec - [lldb] Use just-built libcxx for tests when available

Felipe de Azevedo Piovezan via lldb-commits lldb-commits at lists.llvm.org
Thu Sep 8 10:43:07 PDT 2022


Author: Felipe de Azevedo Piovezan
Date: 2022-09-08T13:42:56-04:00
New Revision: c38eeecbc7d929c9601f2189214a7a90d3982a47

URL: https://github.com/llvm/llvm-project/commit/c38eeecbc7d929c9601f2189214a7a90d3982a47
DIFF: https://github.com/llvm/llvm-project/commit/c38eeecbc7d929c9601f2189214a7a90d3982a47.diff

LOG: [lldb] Use just-built libcxx for tests when available

This commit improves upon cc0b5ebf7fc8, which added support for
specifying which libcxx to use when testing LLDB. That patch honored
requests by tests that had `USE_LIBCPP=1` defined in their makefiles.
Now, we also use a non-default libcxx if all conditions below are true:

1. The test is not explicitly requesting the use of libstdcpp
(USE_LIBSTDCPP=1).
2. The test is not explicitly requesting the use of the system's
library (USE_SYSTEM_STDLIB=1).
3. A path to libcxx was either provided by the user through CMake flags
or libcxx was built together with LLDB.

Condition (2) is new and introduced in this patch in order to support
tests that are either:

* Cross-platform (such as API/macosx/macCatalyst and
API/tools/lldb-server). The just-built libcxx is usually not built for
platforms other than the host's.
* Cross-language (such as API/lang/objc/exceptions). In this case, the
Objective C runtime throws an exceptions that always goes through the
system's libcxx, instead of the just built libcxx. Fixing this would
require either changing the install-name of the just built libcxx in Mac
systems, or tuning the DYLD_LIBRARY_PATH variable at runtime.

Some other tests exposes limitations of LLDB when running with a debug
standard library. TestDbgInfoContentForwardLists had an assertion
removed, as it was checking for buggy LLDB behavior (which now
crashes). TestFixIts had a variable renamed, as the old name clashes
with a standard library name when debug info is present. This is a known
issue: https://github.com/llvm/llvm-project/issues/34391.

For `TestSBModule`, the way the "main" module is found was changed to
look for the "a.out" module, instead of relying on the index being 0. In
some systems, the index 0 is dyld when a custom standard library is
used.

Differential Revision: https://reviews.llvm.org/D132940

Added: 
    

Modified: 
    lldb/packages/Python/lldbsuite/test/make/Makefile.rules
    lldb/test/API/commands/expression/fixits/TestFixIts.py
    lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
    lldb/test/API/lang/objc/exceptions/Makefile
    lldb/test/API/macosx/macCatalyst/Makefile
    lldb/test/API/python_api/sbmodule/TestSBModule.py
    lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py

Removed: 
    


################################################################################
diff  --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index 937a2ae06fc44..c0fd5ecd0dc84 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -387,6 +387,16 @@ endif
 #----------------------------------------------------------------------
 # C++ standard library options
 #----------------------------------------------------------------------
+ifneq ($(and $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+	$(error Libcxx and Libstdc++ cannot be used together)
+endif
+
+ifeq (1, $(USE_SYSTEM_STDLIB))
+	ifneq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP)),)
+		$(error Cannot use system's standard library and a custom standard library together)
+	endif
+endif
+
 ifeq (1,$(USE_LIBSTDCPP))
 	# Clang requires an extra flag: -stdlib=libstdc++
 	ifneq (,$(findstring clang,$(CC)))
@@ -415,6 +425,15 @@ ifeq (1,$(USE_LIBCPP))
 	endif
 endif
 
+# If no explicit request was made, but we have paths to a custom libcxx, use
+# them.
+ifeq ($(or $(USE_LIBSTDCPP), $(USE_LIBCPP), $(USE_SYSTEM_STDLIB)),)
+	ifneq ($(and $(LIBCPP_INCLUDE_DIR), $(LIBCPP_LIBRARY_DIR)),)
+		CXXFLAGS += -nostdlib++ -nostdinc++ -cxx-isystem $(LIBCPP_INCLUDE_DIR)
+		LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LIBCPP_LIBRARY_DIR) -lc++
+	endif
+endif
+
 #----------------------------------------------------------------------
 # Additional system libraries
 #----------------------------------------------------------------------

diff  --git a/lldb/test/API/commands/expression/fixits/TestFixIts.py b/lldb/test/API/commands/expression/fixits/TestFixIts.py
index bf4118d1b9d86..bcc7e61d5261c 100644
--- a/lldb/test/API/commands/expression/fixits/TestFixIts.py
+++ b/lldb/test/API/commands/expression/fixits/TestFixIts.py
@@ -45,7 +45,7 @@ def test_with_target(self):
 
         # Try with one error in a top-level expression.
         # The Fix-It changes "ptr.m" to "ptr->m".
-        expr = "struct X { int m; }; X x; X *ptr = &x; int m = ptr.m;"
+        expr = "struct MyTy { int m; }; MyTy x; MyTy *ptr = &x; int m = ptr.m;"
         value = frame.EvaluateExpression(expr, top_level_options)
         # A successfully parsed top-level expression will yield an error
         # that there is 'no value'. If a parsing error would have happened we

diff  --git a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
index f9b7219c72a3d..d794f3b127b3a 100644
--- a/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
+++ b/lldb/test/API/commands/expression/import-std-module/forward_list-dbg-info-content/TestDbgInfoContentForwardListFromStdModule.py
@@ -29,8 +29,3 @@ def test(self):
         self.expect_expr("std::distance(a.begin(), a.end())", result_value="3")
         self.expect_expr("a.front().a", result_type="int", result_value="3")
         self.expect_expr("a.begin()->a", result_type="int", result_value="3")
-
-        # FIXME: The value here isn't actually empty.
-        self.expect_expr("a.front()",
-                         result_type=value_type,
-                         result_children=[ValueCheck()])

diff  --git a/lldb/test/API/lang/objc/exceptions/Makefile b/lldb/test/API/lang/objc/exceptions/Makefile
index 876340159d9c8..355010a867e3a 100644
--- a/lldb/test/API/lang/objc/exceptions/Makefile
+++ b/lldb/test/API/lang/objc/exceptions/Makefile
@@ -2,7 +2,7 @@ OBJCXX_SOURCES := main.mm
 
 CFLAGS_EXTRAS := -w
 
-
+USE_SYSTEM_STDLIB := 1
 
 LD_EXTRAS := -framework Foundation
 include Makefile.rules

diff  --git a/lldb/test/API/macosx/macCatalyst/Makefile b/lldb/test/API/macosx/macCatalyst/Makefile
index d162c33d774f9..3f084968a2d57 100644
--- a/lldb/test/API/macosx/macCatalyst/Makefile
+++ b/lldb/test/API/macosx/macCatalyst/Makefile
@@ -3,6 +3,8 @@ C_SOURCES := main.c
 override TRIPLE := $(ARCH)-apple-ios13.1-macabi
 CFLAGS_EXTRAS := -target $(TRIPLE)
 
+USE_SYSTEM_STDLIB := 1
+
 # FIXME: rdar://problem/54986190
 # There is a Clang driver change missing on llvm.org.
 override CC=xcrun clang

diff  --git a/lldb/test/API/python_api/sbmodule/TestSBModule.py b/lldb/test/API/python_api/sbmodule/TestSBModule.py
index 046c9abddd18c..5a6a8e99ebfe3 100644
--- a/lldb/test/API/python_api/sbmodule/TestSBModule.py
+++ b/lldb/test/API/python_api/sbmodule/TestSBModule.py
@@ -47,8 +47,8 @@ def test_module_is_file_backed(self):
         process = target.AttachToProcessWithID(self.dbg.GetListener(),
                                                self.background_pid, error)
         self.assertTrue(error.Success() and process,  PROCESS_IS_VALID)
-        main_module = target.GetModuleAtIndex(0)
-        self.assertEqual(main_module.GetFileSpec().GetFilename(), "a.out")
+        main_module = target.FindModule(lldb.SBFileSpec("a.out"))
+        self.assertTrue(main_module is not None)
         self.assertFalse(main_module.IsFileBacked(),
                          "The module should not be backed by a file on disk.")
 

diff  --git a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
index 1f3afb1d404ce..e666f34bf6068 100644
--- a/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
+++ b/lldb/test/API/tools/lldb-server/TestAppleSimulatorOSType.py
@@ -70,6 +70,7 @@ def check_simulator_ostype(self, sdk, platform_name, arch=platform.machine()):
                 'SDKROOT': sdkroot.strip(),
                 'ARCH': arch,
                 'ARCH_CFLAGS': '-target {} {}'.format(triple, version_min),
+                'USE_SYSTEM_STDLIB': 1,
             })
         exe_path = os.path.realpath(self.getBuildArtifact(exe_name))
         cmd = [


        


More information about the lldb-commits mailing list