[PATCH] D29335: [lld] [test] Use LLD-specific binary&library dirs when building stand-alone

Michał Górny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 31 10:10:57 PST 2017

mgorny created this revision.
mgorny added a project: lld.
Herald added a subscriber: aemerson.

Use both LLD- and LLVM-specific binary&library directories when LLD is
being built stand-alone. This ensures that the freshly built tools and
libraries are found and used correctly.

Without this patch, the test suite uses LLVM_TOOLS_DIR and LLVM_LIBS_DIR
to locate lld, and set PATH and LD_LIBRARY_PATH. When doing
a stand-alone builds, these variables represent the installed LLVM.
As a result, tests either fail due to missing lld executables/libraries
or use an earlier installed LLD version rather than the one being built.

To solve this, an additional LLD_TOOLS_DIR and LLD_LIBS_DIR variables
are added that are populated using LLVM_*_OUTPUT_INTDIR. Those variables
are populated with directories used to output built executables
and libraries. In stand-alone builds, they represent the directories
used by LLD. 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 since the search includes both tools built as part of
LLD and of LLVM.




Index: test/lit.site.cfg.in
--- test/lit.site.cfg.in
+++ test/lit.site.cfg.in
@@ -6,6 +6,8 @@
 config.llvm_libs_dir = "@LLVM_LIBS_DIR@"
 config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
 config.lld_obj_root = "@LLD_BINARY_DIR@"
+config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@"
+config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@"
 config.target_triple = "@TARGET_TRIPLE@"
 config.python_executable = "@PYTHON_EXECUTABLE@"
 config.have_zlib = "@HAVE_LIBZ@"
Index: test/lit.cfg
--- test/lit.cfg
+++ test/lit.cfg
@@ -66,18 +66,24 @@
 # Tweak the PATH to include the tools dir and the scripts dir.
 if lld_obj_root is not None:
+    lld_tools_dir = getattr(config, 'lld_tools_dir', None)
+    if not lld_tools_dir:
+        lit_config.fatal('No LLD 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((lld_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
+    lld_libs_dir = getattr(config, 'lld_libs_dir', None)
+    if not lld_libs_dir:
+        lit_config.fatal('No LLD 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((lld_libs_dir, llvm_libs_dir,
     config.environment['LD_LIBRARY_PATH'] = path
@@ -174,10 +180,10 @@
     tool_pipe = tool_match.group(2)
     tool_name = tool_match.group(4)
-    tool_path = lit.util.which(tool_name, 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 ' + llvm_tools_dir)
+        lit_config.note('Did not find ' + tool_name + ' in ' + path)
         tool_path = llvm_tools_dir + '/' + tool_name
     config.substitutions.append((pattern, tool_pipe + tool_path))

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29335.86450.patch
Type: text/x-patch
Size: 2499 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170131/133eea5f/attachment.bin>

More information about the llvm-commits mailing list