[Lldb-commits] [PATCH] D86416: [lldb] -stdlib=libc++ for linking with lldb lib also if LLVM_ENABLE_LIBCXX

Luboš Luňák via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Sun Aug 23 04:21:21 PDT 2020


llunak created this revision.
llunak added reviewers: labath, zturner.
llunak added a project: LLDB.
Herald added a subscriber: JDevlieghere.
llunak requested review of this revision.

Otherwise on Linux e.g. the api/command-return-object test uses libstdc++ for the test app and libc++ is used for the lldb library, and some objects such as std::shared_ptr are not binary compatible between the two libs, leading to "mysterious" crashes.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D86416

Files:
  lldb/packages/Python/lldbsuite/test/lldbtest.py
  lldb/test/API/lit.cfg.py
  lldb/test/API/lit.site.cfg.py.in


Index: lldb/test/API/lit.site.cfg.py.in
===================================================================
--- lldb/test/API/lit.site.cfg.py.in
+++ lldb/test/API/lit.site.cfg.py.in
@@ -20,6 +20,7 @@
 config.lldb_build_directory = "@LLDB_TEST_BUILD_DIRECTORY@"
 config.lldb_reproducer_directory = os.path.join("@LLDB_TEST_BUILD_DIRECTORY@", "reproducers")
 config.python_executable = "@Python3_EXECUTABLE@"
+config.libcxx_used = @LLVM_LIBCXX_USED@
 config.dotest_path = "@LLDB_SOURCE_DIR@/test/API/dotest.py"
 config.dotest_args_str = "@LLDB_DOTEST_ARGS@"
 config.lldb_enable_python = @LLDB_ENABLE_PYTHON@
Index: lldb/test/API/lit.cfg.py
===================================================================
--- lldb/test/API/lit.cfg.py
+++ lldb/test/API/lit.cfg.py
@@ -155,6 +155,9 @@
 if config.llvm_libs_dir:
   dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir]
 
+if config.libcxx_used:
+  dotest_cmd += ['--env', 'LLVM_LIBCXX_USED=1']
+
 # Forward ASan-specific environment variables to tests, as a test may load an
 # ASan-ified dylib.
 for env_var in ('ASAN_OPTIONS', 'DYLD_INSERT_LIBRARIES'):
Index: lldb/packages/Python/lldbsuite/test/lldbtest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/lldbtest.py
+++ lldb/packages/Python/lldbsuite/test/lldbtest.py
@@ -1485,6 +1485,8 @@
             stdlibflag = "-stdlib=libc++"
         else:  # this includes NetBSD
             stdlibflag = ""
+        if "LLVM_LIBCXX_USED" in os.environ and os.environ["LLVM_LIBCXX_USED"] == "1":
+            stdlibflag = "-stdlib=libc++"
         return stdlibflag
 
     def getstdFlag(self):
@@ -1541,12 +1543,13 @@
         """Platform specific way to build a default library. """
 
         stdflag = self.getstdFlag()
+        stdlibflag = self.getstdlibFlag()
 
         lib_dir = configuration.lldb_libs_dir
         if self.hasDarwinFramework():
             d = {'DYLIB_CXX_SOURCES': sources,
                  'DYLIB_NAME': lib_name,
-                 'CFLAGS_EXTRAS': "%s -stdlib=libc++" % stdflag,
+                 'CFLAGS_EXTRAS': "%s %s" % (stdflag, stdlibflag),
                  'FRAMEWORK_INCLUDES': "-F%s" % self.framework_dir,
                  'LD_EXTRAS': "%s -Wl,-rpath,%s -dynamiclib" % (self.dsym, self.framework_dir),
                  }
@@ -1554,19 +1557,21 @@
             d = {
                 'DYLIB_CXX_SOURCES': sources,
                 'DYLIB_NAME': lib_name,
-                'CFLAGS_EXTRAS': "%s -I%s " % (stdflag,
-                                               os.path.join(
-                                                   os.environ["LLDB_SRC"],
-                                                   "include")),
+                'CFLAGS_EXTRAS': "%s %s -I%s " % (stdflag,
+                                                  stdlibflag,
+                                                  os.path.join(
+                                                      os.environ["LLDB_SRC"],
+                                                      "include")),
                 'LD_EXTRAS': "-shared -l%s\liblldb.lib" % self.os.environ["LLDB_IMPLIB_DIR"]}
         else:
             d = {
                 'DYLIB_CXX_SOURCES': sources,
                 'DYLIB_NAME': lib_name,
-                'CFLAGS_EXTRAS': "%s -I%s -fPIC" % (stdflag,
-                                                    os.path.join(
-                                                        os.environ["LLDB_SRC"],
-                                                        "include")),
+                'CFLAGS_EXTRAS': "%s %s -I%s -fPIC" % (stdflag,
+                                                       stdlibflag,
+                                                       os.path.join(
+                                                           os.environ["LLDB_SRC"],
+                                                           "include")),
                 'LD_EXTRAS': "-shared -L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)}
         if self.TraceOn():
             print(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D86416.287248.patch
Type: text/x-patch
Size: 4050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20200823/c328803a/attachment-0001.bin>


More information about the lldb-commits mailing list