[Lldb-commits] [lldb] cc0b5eb - [lldb] Support specifying a custom libcxx for the API tests
Jonas Devlieghere via lldb-commits
lldb-commits at lists.llvm.org
Fri Aug 19 15:20:50 PDT 2022
Author: Jonas Devlieghere
Date: 2022-08-19T15:20:41-07:00
New Revision: cc0b5ebf7fc8beb8fa907730e2d8f52d4c31bdc7
URL: https://github.com/llvm/llvm-project/commit/cc0b5ebf7fc8beb8fa907730e2d8f52d4c31bdc7
DIFF: https://github.com/llvm/llvm-project/commit/cc0b5ebf7fc8beb8fa907730e2d8f52d4c31bdc7.diff
LOG: [lldb] Support specifying a custom libcxx for the API tests
This patch combines D129166 (to always pick the just-built libc++) and
D132257 (to allow customizing the libc++ for testing). The common goal
is to avoid picking up an unexpected libc++ for testing.
Differential revision: https://reviews.llvm.org/D132263
Added:
Modified:
lldb/packages/Python/lldbsuite/test/builders/builder.py
lldb/packages/Python/lldbsuite/test/configuration.py
lldb/packages/Python/lldbsuite/test/dotest.py
lldb/packages/Python/lldbsuite/test/dotest_args.py
lldb/packages/Python/lldbsuite/test/make/Makefile.rules
lldb/test/API/lit.cfg.py
Removed:
################################################################################
diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py
index cb82dd4c98817..e260431cad812 100644
--- a/lldb/packages/Python/lldbsuite/test/builders/builder.py
+++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py
@@ -121,8 +121,9 @@ def getModuleCacheSpec(self):
return []
def getLibCxxArgs(self):
- if configuration.hermetic_libcxx:
- return ["USE_HERMETIC_LIBCPP=1"]
+ if configuration.libcxx_include_dir and configuration.libcxx_library_dir:
+ return ["LIBCPP_INCLUDE_DIR={}".format(configuration.libcxx_include_dir),
+ "LIBCPP_LIBRARY_DIR={}".format(configuration.libcxx_library_dir)]
return []
def _getDebugInfoArgs(self, debug_info):
diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py
index c29a44e70638a..5133dedbe8524 100644
--- a/lldb/packages/Python/lldbsuite/test/configuration.py
+++ b/lldb/packages/Python/lldbsuite/test/configuration.py
@@ -124,8 +124,8 @@
# LLDB library directory.
lldb_libs_dir = None
-# Force us to use the just-built libcxx
-hermetic_libcxx = False
+libcxx_include_dir = None
+libcxx_library_dir = None
# A plugin whose tests will be enabled, like intel-pt.
enabled_plugins = []
diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py
index fd212631d3e27..37842c96ba388 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest.py
@@ -280,10 +280,17 @@ def parseOptionsAndInitTestdirs():
logging.warning('No valid FileCheck executable; some tests may fail...')
logging.warning('(Double-check the --llvm-tools-dir argument to dotest.py)')
- configuration.hermetic_libcxx = args.hermetic_libcxx
- if configuration.hermetic_libcxx and args.lldb_platform_name:
- configuration.hermetic_libcxx = False
- logging.warning('Hermetic libc++ is not supported for remote runs: ignoring --hermetic-libcxx')
+ configuration.libcxx_include_dir = args.libcxx_include_dir
+ configuration.libcxx_library_dir = args.libcxx_library_dir
+ if args.libcxx_include_dir or args.libcxx_library_dir:
+ if args.lldb_platform_name:
+ logging.warning('Custom libc++ is not supported for remote runs: ignoring --libcxx arguments')
+ elif args.libcxx_include_dir and args.libcxx_library_dir:
+ configuration.libcxx_include_dir = args.libcxx_include_dir
+ configuration.libcxx_library_dir = args.libcxx_library_dir
+ else:
+ logging.error('Custom libc++ requires both --libcxx-include-dir and --libcxx-library-dir')
+ sys.exit(-1)
if args.channels:
lldbtest_config.channels = args.channels
diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py
index 768b052885074..3bd523ac579bc 100644
--- a/lldb/packages/Python/lldbsuite/test/dotest_args.py
+++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py
@@ -43,8 +43,8 @@ def create_parser():
if sys.platform == 'darwin':
group.add_argument('--apple-sdk', metavar='apple_sdk', dest='apple_sdk', default="", help=textwrap.dedent(
'''Specify the name of the Apple SDK (macosx, macosx.internal, iphoneos, iphoneos.internal, or path to SDK) and use the appropriate tools from that SDK's toolchain.'''))
- group.add_argument('--hermetic-libcxx', action='store_true', help=textwrap.dedent(
- '''Force the just-built libcxx to be used for the libc++ formatter tests.'''))
+ group.add_argument('--libcxx-include-dir', help=textwrap.dedent('Specify the path to a custom libc++ include directory. Must be used in conjunction with --libcxx-library-dir.'))
+ group.add_argument('--libcxx-library-dir', help=textwrap.dedent('Specify the path to a custom libc++ library directory. Must be used in conjunction with --libcxx-include-dir.'))
# FIXME? This won't work for
diff erent extra flags according to each arch.
group.add_argument(
'-E',
diff --git a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
index b065a43cb1934..6336ef2a523c0 100644
--- a/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
+++ b/lldb/packages/Python/lldbsuite/test/make/Makefile.rules
@@ -388,16 +388,21 @@ endif
ifeq (1,$(USE_LIBCPP))
CXXFLAGS += -DLLDB_USING_LIBCPP
- ifeq "$(OS)" "Android"
- # Nothing to do, this is already handled in
- # Android.rules.
+ 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++
else
- CXXFLAGS += -stdlib=libc++
- LDFLAGS += -stdlib=libc++
- endif
- ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))
- ifneq (,$(LLVM_LIBS_DIR))
- LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)
+ ifeq "$(OS)" "Android"
+ # Nothing to do, this is already handled in
+ # Android.rules.
+ else
+ CXXFLAGS += -stdlib=libc++
+ LDFLAGS += -stdlib=libc++
+ endif
+ ifneq (,$(filter $(OS), FreeBSD Linux NetBSD))
+ ifneq (,$(LLVM_LIBS_DIR))
+ LDFLAGS += -Wl,-rpath,$(LLVM_LIBS_DIR)
+ endif
endif
endif
endif
diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py
index b553b8940467d..9ebf7e88cdaea 100644
--- a/lldb/test/API/lit.cfg.py
+++ b/lldb/test/API/lit.cfg.py
@@ -172,7 +172,9 @@ def delete_module_cache(path):
# If we have a just-built libcxx, prefer it over the system one.
if is_configured('has_libcxx') and platform.system() != 'Windows':
- dotest_cmd += ['--hermetic-libcxx']
+ if is_configured('llvm_include_dir') and is_configured('llvm_libs_dir'):
+ dotest_cmd += ['--libcxx-include-dir', os.path.join(config.llvm_include_dir, 'c++', 'v1')]
+ dotest_cmd += ['--libcxx-library-dir', config.llvm_libs_dir]
# Forward ASan-specific environment variables to tests, as a test may load an
# ASan-ified dylib.
More information about the lldb-commits
mailing list