summaryrefslogtreecommitdiff
blob: 1b183d860a2d54ed29a702343ddf141eba21ab46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
From 6a9aab954c32a2d3d13a0fe5fc984e9787e9f794 Mon Sep 17 00:00:00 2001
From: Michal Gorny <mgorny@gentoo.org>
Date: Sun, 19 Feb 2017 22:11:38 +0000
Subject: [PATCH] [test] Fix finding LLDB tools when building stand-alone

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, paths used to locate various tools are
updated to match appropriate locations.

Differential Revision: https://reviews.llvm.org/D29985

git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@295621 91177308-0d34-0410-b5e6-96231b3b80d8
---
 lit/lit.cfg         | 18 ++++++++++++------
 lit/lit.site.cfg.in |  2 ++
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/lit/lit.cfg b/lit/lit.cfg
index dd89b45fa..a3d5f9ca7 100644
--- a/lit/lit.cfg
+++ b/lit/lit.cfg
@@ -39,18 +39,24 @@ config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
 
 # 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 @@ if config.test_exec_root is None:
 # 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', lldb_tools_dir)
+lldb = lit.util.which('lldb', lldb_tools_dir)
 
 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:
diff --git a/lit/lit.site.cfg.in b/lit/lit.site.cfg.in
index 904521c9d..03aa3df9a 100644
--- a/lit/lit.site.cfg.in
+++ b/lit/lit.site.cfg.in
@@ -6,6 +6,8 @@ config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
 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@"
-- 
2.12.0