[Lldb-commits] [PATCH] D132257: [lldb] Create flag to use a custom libcxx in tests

Felipe de Azevedo Piovezan via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Aug 19 11:40:59 PDT 2022


fdeazeve created this revision.
fdeazeve added a reviewer: aprantl.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.

When running LLDB tests with a separately built copy of libcxx, it may
be necessary to also use the `nostdinc++` and `cxx-isystem` flags, so
that Clang doesn't keep multiple paths to the standard library in its
include search list. This is particularly important when also running
LLDB tests using older versions of clang, which may not deal with
multiple standard libraries properly.

These issues have all been seen in the LLDB matrix green dragon bot,
which ensures that tip-of-trunk LLDBs can debug code compiled with older
versions of Clang/libcxx.

Once this is merged, llvm-zorg can be updated to use the flags. Local
testing has been done by compiling the project with:

`-DLLDB_TEST_USER_ARGS="--custom-libcpp=<invalid_path>`

We verified that all LLDB tests failed to find standard library files.
Then we fixed the invalid path to point to a proper libcxx, and the
tests passed.

A similar effect could have been accomplished by repurposing either
CXXFLAGS or CXXFLAGS_EXTRAS, but these are already for many different
purposes, so we choose to isolate the new behavior into a new
environment variable.

We also choose to keep the logic of formatting the flags inside the
Makefile, as that's where we can check which compiler is being used, as
it is already done in other places there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D132257

Files:
  lldb/packages/Python/lldbsuite/test/dotest.py
  lldb/packages/Python/lldbsuite/test/dotest_args.py
  lldb/packages/Python/lldbsuite/test/make/Makefile.rules


Index: lldb/packages/Python/lldbsuite/test/make/Makefile.rules
===================================================================
--- lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -402,6 +402,14 @@
 	endif
 endif
 
+ifdef CUSTOM_LIBCPP
+        ifeq (,$(findstring clang,$(CC)))
+                $(error "CUSTOM_LIBCPP only supported for Clang compilers")
+        endif
+
+        CXXFLAGS += -nostdinc++ -cxx-isystem $(CUSTOM_LIBCPP)
+endif
+
 #----------------------------------------------------------------------
 # Additional system libraries
 #----------------------------------------------------------------------
Index: lldb/packages/Python/lldbsuite/test/dotest_args.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -172,6 +172,11 @@
         type=str,
         metavar='A plugin whose tests will be enabled',
         help='A plugin whose tests will be enabled. The only currently supported plugin is intel-pt.')
+    group.add_argument(
+        '--custom-libcpp',
+        metavar='custom-libcpp',
+        dest='custom_libcpp',
+        help='(Clang only) Specify path to a custom standard library to use. Disables search for other standard C++ libraries.')
 
     # Configuration options
     group = parser.add_argument_group('Remote platform options')
Index: lldb/packages/Python/lldbsuite/test/dotest.py
===================================================================
--- lldb/packages/Python/lldbsuite/test/dotest.py
+++ lldb/packages/Python/lldbsuite/test/dotest.py
@@ -335,6 +335,9 @@
         # that explicitly require no debug info.
         os.environ['CFLAGS'] = '-gdwarf-{}'.format(configuration.dwarf_version)
 
+    if args.custom_libcpp:
+        os.environ['CUSTOM_LIBCPP'] = args.custom_libcpp
+
     if args.settings:
         for setting in args.settings:
             if not len(setting) == 1 or not setting[0].count('='):


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132257.454072.patch
Type: text/x-patch
Size: 2070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220819/7bb9f958/attachment-0001.bin>


More information about the lldb-commits mailing list