From 6d6afb72b3a2c8b85c3c6e3acd39d96baa6e443e Mon Sep 17 00:00:00 2001 From: Michal Gorny Date: Tue, 26 Feb 2019 19:46:29 +0000 Subject: [PATCH] [lldb] [lit] Set LD_LIBRARY_PATH or alike for Suite tests Set LD_LIBRARY_PATH or local platform's equivalent of it when running the 'Suite' tests. This is necessary when running tests inside build tree with BUILD_SHARED_LIBS enabled, in order to make the LLDB modules load freshly built LLVM libraries. The code is copied from clang (test/Unit/lit.cfg). SHLIBDIR substitution is added to site-config (already present in top-level LLDB site-config) to future-proof this into supporting stand-alone builds with shared LLDB libraries. Differential Revision: https://reviews.llvm.org/D58610 llvm-svn: 354920 --- lldb/lit/Suite/lit.cfg | 23 +++++++++++++++++++++++ lldb/lit/Suite/lit.site.cfg.in | 1 + 2 files changed, 24 insertions(+) diff --git a/lldb/lit/Suite/lit.cfg b/lldb/lit/Suite/lit.cfg index 7bc16e9..790d6d1 100644 --- a/lldb/lit/Suite/lit.cfg +++ b/lldb/lit/Suite/lit.cfg @@ -3,6 +3,7 @@ # Configuration file for the 'lit' test runner. import os +import platform import shlex import lit.formats @@ -32,6 +33,28 @@ if 'Address' in config.llvm_use_sanitizer and \ 'detect_stack_use_after_return=1' config.environment['DYLD_INSERT_LIBRARIES'] = runtime +# Shared library build of LLVM may require LD_LIBRARY_PATH or equivalent. +def find_shlibpath_var(): + if platform.system() in ['Linux', 'FreeBSD', 'NetBSD', 'SunOS']: + yield 'LD_LIBRARY_PATH' + elif platform.system() == 'Darwin': + yield 'DYLD_LIBRARY_PATH' + elif platform.system() == 'Windows': + yield 'PATH' + +for shlibpath_var in find_shlibpath_var(): + # In stand-alone build llvm_shlib_dir specifies LLDB's lib directory + # while llvm_libs_dir specifies LLVM's lib directory. + shlibpath = os.path.pathsep.join( + (config.llvm_shlib_dir, + config.llvm_libs_dir, + config.environment.get(shlibpath_var, ''))) + config.environment[shlibpath_var] = shlibpath + break +else: + lit_config.warning("unable to inject shared library path on '{}'" + .format(platform.system())) + # Build dotest command. dotest_cmd = [config.dotest_path, '-q'] dotest_cmd.extend(config.dotest_args_str.split(';')) diff --git a/lldb/lit/Suite/lit.site.cfg.in b/lldb/lit/Suite/lit.site.cfg.in index 1a24f8c..8fd3d25 100644 --- a/lldb/lit/Suite/lit.site.cfg.in +++ b/lldb/lit/Suite/lit.site.cfg.in @@ -5,6 +5,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.llvm_shlib_dir = "@SHLIBDIR@" config.llvm_build_mode = "@LLVM_BUILD_MODE@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lldb_obj_root = "@LLDB_BINARY_DIR@" -- 2.7.4