JDevlieghere updated this revision to Diff 442635. JDevlieghere added a comment. Herald added a subscriber: mgorny.
I still have to test different configurations, but putting it up here for feedback about the general direction. This doesn't account yet for remote runs. Should be easy to detect based on whether `--platform-name` is set in dotest.py. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D129166/new/ https://reviews.llvm.org/D129166 Files: 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 lldb/test/API/lit.site.cfg.py.in lldb/test/CMakeLists.txt
Index: lldb/test/CMakeLists.txt =================================================================== --- lldb/test/CMakeLists.txt +++ lldb/test/CMakeLists.txt @@ -127,6 +127,7 @@ # 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 @@ LLDB_ENABLE_LZMA LLVM_ENABLE_ZLIB LLVM_ENABLE_SHARED_LIBS + LLDB_HAS_LIBCXX LLDB_USE_SYSTEM_DEBUGSERVER LLDB_IS_64_BITS) 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 @@ -4,6 +4,7 @@ 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.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") Index: lldb/test/API/lit.cfg.py =================================================================== --- lldb/test/API/lit.cfg.py +++ lldb/test/API/lit.cfg.py @@ -158,14 +158,22 @@ 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'): + 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'): 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 @@ -387,17 +387,22 @@ endif ifeq (1,$(USE_LIBCPP)) - CXXFLAGS += -DLLDB_USING_LIBCPP - ifeq "$(OS)" "Android" - # Nothing to do, this is already handled in - # Android.rules. + ifeq (1,$(USE_HERMETIC_LIBCPP)) + CXXFLAGS += -nostdlib++ -nostdinc++ -I$(LLVM_INCLUDE_DIR)/c++/v1 + LDFLAGS += -L$(LLVM_LIBS_DIR) -Wl,-rpath,$(LLVM_LIBS_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) + CXXFLAGS += -DLLDB_USING_LIBCPP + 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 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 @@ -43,6 +43,8 @@ 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 different extra flags according to each arch. group.add_argument( '-E', Index: lldb/packages/Python/lldbsuite/test/dotest.py =================================================================== --- lldb/packages/Python/lldbsuite/test/dotest.py +++ lldb/packages/Python/lldbsuite/test/dotest.py @@ -281,6 +281,8 @@ logging.warning('No valid FileCheck executable; some tests may fail...') logging.warning('(Double-check the --llvm-tools-dir argument to dotest.py)') + configuration.hermetic_libxxx = args.hermetic_libcxx + if args.channels: lldbtest_config.channels = args.channels Index: lldb/packages/Python/lldbsuite/test/configuration.py =================================================================== --- lldb/packages/Python/lldbsuite/test/configuration.py +++ 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 = [] Index: lldb/packages/Python/lldbsuite/test/builders/builder.py =================================================================== --- lldb/packages/Python/lldbsuite/test/builders/builder.py +++ lldb/packages/Python/lldbsuite/test/builders/builder.py @@ -120,6 +120,11 @@ 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 @@ 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
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits