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( 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/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@