Author: Jonas Devlieghere Date: 2022-07-11T14:49:24-07:00 New Revision: ce233e714665a0499fbd0686226e43130d44ef87
URL: https://github.com/llvm/llvm-project/commit/ce233e714665a0499fbd0686226e43130d44ef87 DIFF: https://github.com/llvm/llvm-project/commit/ce233e714665a0499fbd0686226e43130d44ef87.diff LOG: [lldb] Use the just-built libc++ for testing the LLDB data formatters Make sure we use the libc++ from the build dir. Currently, by passing -stdlib=libc++, we might pick up the system libc++. This change ensures that if LLVM_LIBS_DIR is set, we try to use the libc++ from there. Differential revision: https://reviews.llvm.org/D129166 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/test/API/lit.cfg.py lldb/test/API/lit.site.cfg.py.in lldb/test/CMakeLists.txt Removed: ################################################################################ diff --git a/lldb/packages/Python/lldbsuite/test/builders/builder.py b/lldb/packages/Python/lldbsuite/test/builders/builder.py index 98057066f3f3c..cb82dd4c98817 100644 --- a/lldb/packages/Python/lldbsuite/test/builders/builder.py +++ b/lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -120,6 +120,11 @@ def getModuleCacheSpec(self): configuration.clang_module_cache_dir)] return [] + def getLibCxxArgs(self): + if configuration.hermetic_libcxx: + return ["USE_HERMETIC_LIBCPP=1"] + return [] + def _getDebugInfoArgs(self, debug_info): if debug_info is None: return [] @@ -142,7 +147,7 @@ def getBuildCommand(self, debug_info, architecture=None, compiler=None, self.getArchCFlags(architecture), self.getArchSpec(architecture), self.getCCSpec(compiler), self.getExtraMakeArgs(), self.getSDKRootSpec(), self.getModuleCacheSpec(), - self.getCmdLine(dictionary)] + self.getLibCxxArgs(), self.getCmdLine(dictionary)] command = list(itertools.chain(*command_parts)) return command diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 6b3da8f255230..c29a44e70638a 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -124,6 +124,9 @@ # LLDB library directory. lldb_libs_dir = None +# Force us to use the just-built libcxx +hermetic_libcxx = False + # 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 a9ca741cf3a72..ee59500a4fc7f 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -281,6 +281,11 @@ 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') + 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 aac2fecfe6994..768b052885074 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -43,6 +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.''')) # FIXME? This won't work for diff erent extra flags according to each arch. group.add_argument( '-E', diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index abd396d015dff..b553b8940467d 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -158,14 +158,22 @@ def delete_module_cache(path): if is_configured('dotest_args_str'): dotest_cmd.extend(config.dotest_args_str.split(';')) -# Library path may be needed to locate just-built clang. +# Library path may be needed to locate just-built clang and libcxx. if is_configured('llvm_libs_dir'): dotest_cmd += ['--env', 'LLVM_LIBS_DIR=' + config.llvm_libs_dir] +# Include path may be needed to locate just-built libcxx. +if is_configured('llvm_include_dir'): + dotest_cmd += ['--env', 'LLVM_INCLUDE_DIR=' + config.llvm_include_dir] + # This path may be needed to locate required llvm tools if is_configured('llvm_tools_dir'): dotest_cmd += ['--env', 'LLVM_TOOLS_DIR=' + config.llvm_tools_dir] +# 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'] + # 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'): diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index 75d588a30b375..f7ffb0ab77b46 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = lit_config.substitute("@LLVM_TOOLS_DIR@") config.llvm_libs_dir = lit_config.substitute("@LLVM_LIBS_DIR@") +config.llvm_include_dir = lit_config.substitute("@LLVM_INCLUDE_DIR@") config.llvm_shlib_dir = lit_config.substitute("@SHLIBDIR@") config.llvm_build_mode = lit_config.substitute("@LLVM_BUILD_MODE@") config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" @@ -29,6 +30,7 @@ config.lldb_executable = lit_config.substitute('@LLDB_TEST_EXECUTABLE@') config.test_arch = '@LLDB_TEST_ARCH@' config.test_compiler = lit_config.substitute('@LLDB_TEST_COMPILER@') config.dsymutil = lit_config.substitute('@LLDB_TEST_DSYMUTIL@') +config.has_libcxx = '@LLDB_HAS_LIBCXX@' # The API tests use their own module caches. config.lldb_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_LLDB@", "lldb-api") config.clang_module_cache = os.path.join("@LLDB_TEST_MODULE_CACHE_CLANG@", "lldb-api") diff --git a/lldb/test/CMakeLists.txt b/lldb/test/CMakeLists.txt index 61106e31d7813..49626ce13a7ce 100644 --- a/lldb/test/CMakeLists.txt +++ b/lldb/test/CMakeLists.txt @@ -127,6 +127,7 @@ if(TARGET clang) # dependency as it's also possible to run the libc++ tests against the libc++ # installed on the system. if (TARGET cxx) + set(LLDB_HAS_LIBCXX ON) add_lldb_test_dependency(cxx) endif() @@ -172,6 +173,7 @@ llvm_canonicalize_cmake_booleans( LLDB_ENABLE_LZMA LLVM_ENABLE_ZLIB LLVM_ENABLE_SHARED_LIBS + LLDB_HAS_LIBCXX LLDB_USE_SYSTEM_DEBUGSERVER LLDB_IS_64_BITS) _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits