From: Michał Górny Date: Fri, 31 Jan 2020 08:35:34 +0000 (+0100) Subject: [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb X-Git-Tag: llvmorg-12-init~15672 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcab9736f01bc19a4d8011e04b6be46df5942791;p=platform%2Fupstream%2Fllvm.git [lldb] [test] Pass LLVM_LIBS_DIR from CMake for linking liblldb Pass the correct library directory from CMake to dotest.py when linking liblldb, instead of trying to reconstruct the path from executable path. This fixes link failures on platforms having non-null LLVM_LIBDIR_SUFFIX. Differential Revision: https://reviews.llvm.org/D73767 --- diff --git a/lldb/packages/Python/lldbsuite/test/configuration.py b/lldb/packages/Python/lldbsuite/test/configuration.py index 09fc646..91a2234 100644 --- a/lldb/packages/Python/lldbsuite/test/configuration.py +++ b/lldb/packages/Python/lldbsuite/test/configuration.py @@ -136,6 +136,10 @@ rerun_all_issues = False # same base name. all_tests = set() +# LLDB library directory. +lldb_libs_dir = None + + def shouldSkipBecauseOfCategories(test_categories): if use_categories: if len(test_categories) == 0 or len( diff --git a/lldb/packages/Python/lldbsuite/test/dotest.py b/lldb/packages/Python/lldbsuite/test/dotest.py index 560e47d..d45a572 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest.py +++ b/lldb/packages/Python/lldbsuite/test/dotest.py @@ -452,6 +452,9 @@ def parseOptionsAndInitTestdirs(): os.environ['CLANG_MODULE_CACHE_DIR'] = configuration.clang_module_cache_dir + if args.lldb_libs_dir: + configuration.lldb_libs_dir = args.lldb_libs_dir + # Gather all the dirs passed on the command line. if len(args.args) > 0: configuration.testdirs = [os.path.realpath(os.path.abspath(x)) for x in args.args] @@ -559,10 +562,7 @@ def setupSysPath(): # confusingly, this is the "bin" directory lldbLibDir = os.path.dirname(lldbtest_config.lldbExec) os.environ["LLDB_LIB_DIR"] = lldbLibDir - lldbImpLibDir = os.path.join( - lldbLibDir, - '..', - 'lib') if sys.platform.startswith('win32') else lldbLibDir + lldbImpLibDir = configuration.lldb_libs_dir os.environ["LLDB_IMPLIB_DIR"] = lldbImpLibDir print("LLDB library dir:", os.environ["LLDB_LIB_DIR"]) print("LLDB import library dir:", os.environ["LLDB_IMPLIB_DIR"]) diff --git a/lldb/packages/Python/lldbsuite/test/dotest_args.py b/lldb/packages/Python/lldbsuite/test/dotest_args.py index 7ec5fa2..385f65f 100644 --- a/lldb/packages/Python/lldbsuite/test/dotest_args.py +++ b/lldb/packages/Python/lldbsuite/test/dotest_args.py @@ -172,6 +172,11 @@ def create_parser(): dest='clang_module_cache_dir', metavar='The clang module cache directory used by Clang', help='The clang module cache directory used in the Make files by Clang while building tests. Defaults to /module-cache-clang.') + group.add_argument( + '--lldb-libs-dir', + dest='lldb_libs_dir', + metavar='path', + help='The path to LLDB library directory (containing liblldb)') # Configuration options group = parser.add_argument_group('Remote platform options') diff --git a/lldb/packages/Python/lldbsuite/test/lldbtest.py b/lldb/packages/Python/lldbsuite/test/lldbtest.py index fe4b198..8db081b 100644 --- a/lldb/packages/Python/lldbsuite/test/lldbtest.py +++ b/lldb/packages/Python/lldbsuite/test/lldbtest.py @@ -1399,7 +1399,7 @@ class Base(unittest2.TestCase): stdflag = self.getstdFlag() stdlibflag = self.getstdlibFlag() - lib_dir = os.environ["LLDB_LIB_DIR"] + lib_dir = configuration.lldb_libs_dir if self.hasDarwinFramework(): d = {'CXX_SOURCES': sources, 'EXE': exe_name, @@ -1426,7 +1426,7 @@ class Base(unittest2.TestCase): os.path.join( os.environ["LLDB_SRC"], "include")), - 'LD_EXTRAS': "-L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} + 'LD_EXTRAS': "-L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)} if self.TraceOn(): print( "Building LLDB Driver (%s) from sources %s" % @@ -1439,7 +1439,7 @@ class Base(unittest2.TestCase): stdflag = self.getstdFlag() - lib_dir = os.environ["LLDB_LIB_DIR"] + lib_dir = configuration.lldb_libs_dir if self.hasDarwinFramework(): d = {'DYLIB_CXX_SOURCES': sources, 'DYLIB_NAME': lib_name, @@ -1464,7 +1464,7 @@ class Base(unittest2.TestCase): os.path.join( os.environ["LLDB_SRC"], "include")), - 'LD_EXTRAS': "-shared -L%s/../lib -llldb -Wl,-rpath,%s/../lib" % (lib_dir, lib_dir)} + 'LD_EXTRAS': "-shared -L%s -llldb -Wl,-rpath,%s" % (lib_dir, lib_dir)} if self.TraceOn(): print( "Building LLDB Library (%s) from sources %s" % diff --git a/lldb/test/API/lit.cfg.py b/lldb/test/API/lit.cfg.py index 631a8a4..79401ae 100644 --- a/lldb/test/API/lit.cfg.py +++ b/lldb/test/API/lit.cfg.py @@ -114,6 +114,9 @@ if config.dsymutil: if config.filecheck: dotest_cmd += ['--filecheck', config.filecheck] +if config.lldb_libs_dir: + dotest_cmd += ['--lldb-libs-dir', config.lldb_libs_dir] + # We don't want to force users passing arguments to lit to use `;` as a # separator. We use Python's simple lexical analyzer to turn the args into a # list. Pass there arguments last so they can override anything that was diff --git a/lldb/test/API/lit.site.cfg.py.in b/lldb/test/API/lit.site.cfg.py.in index a675c97..e68d481 100644 --- a/lldb/test/API/lit.site.cfg.py.in +++ b/lldb/test/API/lit.site.cfg.py.in @@ -10,6 +10,7 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lldb_obj_root = "@LLDB_BINARY_DIR@" config.lldb_src_root = "@LLDB_SOURCE_DIR@" +config.lldb_libs_dir = "@LLDB_LIBS_DIR@" config.cmake_cxx_compiler = "@CMAKE_CXX_COMPILER@" config.host_os = "@HOST_OS@" config.host_triple = "@LLVM_HOST_TRIPLE@"