diff --git a/lldb/test/Shell/helper/toolchain.py b/lldb/test/Shell/helper/toolchain.py --- a/lldb/test/Shell/helper/toolchain.py +++ b/lldb/test/Shell/helper/toolchain.py @@ -147,14 +147,14 @@ llvm_config.use_clang(additional_flags=['--target=specify-a-target-or-use-a-_host-substitution'], additional_tool_dirs=additional_tool_dirs, - required=True) + required=True, use_installed=True) if sys.platform == 'win32': _use_msvc_substitutions(config) have_lld = llvm_config.use_lld(additional_tool_dirs=additional_tool_dirs, - required=False) + required=False, use_installed=True) if have_lld: config.available_features.add('lld') diff --git a/llvm/utils/lit/lit/llvm/config.py b/llvm/utils/lit/lit/llvm/config.py --- a/llvm/utils/lit/lit/llvm/config.py +++ b/llvm/utils/lit/lit/llvm/config.py @@ -401,10 +401,11 @@ self.add_err_msg_substitutions() - def use_llvm_tool(self, name, search_env=None, required=False, quiet=False): + def use_llvm_tool(self, name, search_env=None, required=False, quiet=False, + use_installed=False): """Find the executable program 'name', optionally using the specified - environment variable as an override before searching the - configuration's PATH.""" + environment variable as an override before searching the build directory + and then optionally the configuration's PATH.""" # If the override is specified in the environment, use it without # validation. tool = None @@ -412,7 +413,11 @@ tool = self.config.environment.get(search_env) if not tool: - # Otherwise look in the path. + # Use the build directory version. + tool = lit.util.which(name, self.config.llvm_tools_dir) + + if not tool and use_installed: + # Otherwise look in the path, if enabled. tool = lit.util.which(name, self.config.environment['PATH']) if required and not tool: @@ -429,11 +434,11 @@ return tool def use_clang(self, additional_tool_dirs=[], additional_flags=[], - required=True): + required=True, use_installed=False): """Configure the test suite to be able to invoke clang. Sets up some environment variables important to clang, locates a - just-built or installed clang, and add a set of standard + just-built or optionally an installed clang, and add a set of standard substitutions useful to any test suite that makes use of clang. """ @@ -497,7 +502,8 @@ # Discover the 'clang' and 'clangcc' to use. self.config.clang = self.use_llvm_tool( - 'clang', search_env='CLANG', required=required) + 'clang', search_env='CLANG', required=required, + use_installed=use_installed) if self.config.clang: self.config.available_features.add('clang') builtin_include_dir = self.get_clang_builtin_include_dir( @@ -569,11 +575,12 @@ (' %clang-cl ', '''\"*** invalid substitution, use '%clang_cl'. ***\"''')) - def use_lld(self, additional_tool_dirs=[], required=True): + def use_lld(self, additional_tool_dirs=[], required=True, + use_installed=False): """Configure the test suite to be able to invoke lld. Sets up some environment variables important to lld, locates a - just-built or installed lld, and add a set of standard + just-built or optionally an installed lld, and add a set of standard substitutions useful to any test suite that makes use of lld. """ @@ -593,12 +600,16 @@ self.with_environment('LD_LIBRARY_PATH', paths, append_path=True) - # Discover the 'clang' and 'clangcc' to use. + # Discover the LLD executables to use. - ld_lld = self.use_llvm_tool('ld.lld', required=required) - lld_link = self.use_llvm_tool('lld-link', required=required) - ld64_lld = self.use_llvm_tool('ld64.lld', required=required) - wasm_ld = self.use_llvm_tool('wasm-ld', required=required) + ld_lld = self.use_llvm_tool('ld.lld', required=required, + use_installed=use_installed) + lld_link = self.use_llvm_tool('lld-link', required=required, + use_installed=use_installed) + ld64_lld = self.use_llvm_tool('ld64.lld', required=required, + use_installed=use_installed) + wasm_ld = self.use_llvm_tool('wasm-ld', required=required, + use_installed=use_installed) was_found = ld_lld and lld_link and ld64_lld and wasm_ld tool_substitutions = []