[Lldb-commits] [PATCH] D29985: [lldb] [test] Fix finding LLDB tools when building stand-alone
Michał Górny via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Feb 15 04:57:12 PST 2017
mgorny created this revision.
mgorny added a project: LLDB.
Herald added a subscriber: aemerson.
Use both LLDB- and LLVM-specific tool/library directories when LLDB is
being built stand-alone. This ensures that the freshly-built tools
(and libraries) are used correctly.
Without this patch, the test suite uses LLVM_TOOLS_DIR and LLVM_LIBS_DIR
to locate lldb, and set PATH and LD_LIBRARY_PATH. When doing
a stand-alone build, these variables represent the installed LLVM.
As a result, tests either fail due to missing lldb executable
or use an earlier installed LLDB version rather than the one being
built.
To solve this, additional LLDB_TOOLS_DIR and LLDB_LIBS_DIR variables
are added and populated using LLVM_*_OUTPUT_INTDIR. Those variables
contain directories used to output built executables and libraries.
In stand-alone builds, they represent the build-tree directories
used by LLDB. In integrated builds, they have the same values as
LLVM_*_DIR and therefore using them does not harm.
The new variables are prepended to PATH and LD_LIBRARY_PATH to ensure
that freshly built binaries are preferred over potentially earlier
installed ones. Furthermore, the resulting PATH is used to locate tools
for substitutions.
Repository:
rL LLVM
https://reviews.llvm.org/D29985
Files:
lit/lit.cfg
lit/lit.site.cfg.in
Index: lit/lit.site.cfg.in
===================================================================
--- lit/lit.site.cfg.in
+++ lit/lit.site.cfg.in
@@ -6,6 +6,8 @@
config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
config.lldb_obj_root = "@LLDB_BINARY_DIR@"
+config.lldb_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
+config.lldb_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
config.target_triple = "@TARGET_TRIPLE@"
config.python_executable = "@PYTHON_EXECUTABLE@"
config.cc = "@CMAKE_C_COMPILER@"
Index: lit/lit.cfg
===================================================================
--- lit/lit.cfg
+++ lit/lit.cfg
@@ -39,18 +39,24 @@
# Tweak the PATH to include the tools dir and the scripts dir.
if lldb_obj_root is not None:
+ lldb_tools_dir = getattr(config, 'lldb_tools_dir', None)
+ if not lldb_tools_dir:
+ lit_config.fatal('No LLDB tools dir set!')
llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
if not llvm_tools_dir:
lit_config.fatal('No LLVM tools dir set!')
- path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
+ path = os.path.pathsep.join((lldb_tools_dir, llvm_tools_dir, config.environment['PATH']))
path = os.path.pathsep.join((os.path.join(getattr(config, 'llvm_src_root', None),'test','Scripts'),path))
config.environment['PATH'] = path
+ lldb_libs_dir = getattr(config, 'lldb_libs_dir', None)
+ if not lldb_libs_dir:
+ lit_config.fatal('No LLDB libs dir set!')
llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
if not llvm_libs_dir:
lit_config.fatal('No LLVM libs dir set!')
- path = os.path.pathsep.join((llvm_libs_dir,
+ path = os.path.pathsep.join((lldb_libs_dir, llvm_libs_dir,
config.environment.get('LD_LIBRARY_PATH','')))
config.environment['LD_LIBRARY_PATH'] = path
@@ -115,14 +121,14 @@
# Register substitutions
config.substitutions.append(('%python', config.python_executable))
-debugserver = lit.util.which('debugserver', llvm_tools_dir)
-lldb = lit.util.which('lldb', llvm_tools_dir)
+debugserver = lit.util.which('debugserver', config.environment['PATH'])
+lldb = lit.util.which('lldb', config.environment['PATH'])
if not os.path.exists(config.cc):
- config.cc = lit.util.which(config.cc, llvm_tools_dir)
+ config.cc = lit.util.which(config.cc, config.environment['PATH'])
if not os.path.exists(config.cxx):
- config.cxx = lit.util.which(config.cxx, llvm_tools_dir)
+ config.cxx = lit.util.which(config.cxx, config.environment['PATH'])
if platform.system() in ['Darwin']:
try:
@@ -150,11 +156,11 @@
pattern)
tool_pipe = tool_match.group(2)
tool_name = tool_match.group(4)
- tool_path = lit.util.which(tool_name, config.llvm_tools_dir)
+ tool_path = lit.util.which(tool_name, config.environment['PATH'])
if not tool_path:
# Warn, but still provide a substitution.
lit_config.note(
- 'Did not find ' + tool_name + ' in ' + config.llvm_tools_dir)
+ 'Did not find ' + tool_name + ' in ' + config.environment['PATH'])
config.substitutions.append((pattern, tool_pipe + tool_path))
# Shell execution
@@ -192,13 +198,16 @@
# llvm-config knows whether it is compiled with asserts (and)
# whether we are operating in release/debug mode.
import subprocess
+llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
+if not llvm_config:
+ lit_config.fatal("Could not find llvm-config in " + config.environment['PATH'])
try:
llvm_config_cmd = \
- subprocess.Popen([os.path.join(llvm_tools_dir, 'llvm-config'),
+ subprocess.Popen([llvm_config,
'--build-mode', '--assertion-mode', '--targets-built'],
stdout = subprocess.PIPE)
except OSError as why:
- print("Could not find llvm-config in " + llvm_tools_dir)
+ print("llvm-config invocation failed")
exit(42)
llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8')
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29985.88512.patch
Type: text/x-patch
Size: 4069 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20170215/83dfc0d8/attachment.bin>
More information about the lldb-commits
mailing list