jhenderson created this revision. jhenderson added reviewers: JDevlieghere, aprantl, MaskRay, thopre, dblaikie, teemperor. Herald added subscribers: usaxena95, kadircet, delcypher. jhenderson requested review of this revision. Herald added subscribers: lldb-commits, ilya-biryukov, aheejin. Herald added projects: LLDB, LLVM.
This patch stops lit from looking on the PATH for clang, lld and other users of use_llvm_tool (currently only the debuginfo-tests) unless the call explicitly requests to opt into using the PATH. When not opting in, tests will only look in the build directory. See the mailing list thread starting from https://lists.llvm.org/pipermail/llvm-dev/2021-May/150421.html. `use_clang` is used from: - The main clang tests (we don't want to test the installed version here, only the built version). - The debuginfo tests (this one is possibly debatable, but the conversation in D95339 <https://reviews.llvm.org/D95339> suggests we should only use the build version in a monorepo setting; see also D96511 <https://reviews.llvm.org/D96511>). - The clangd testing (although rGc29513f7e023f125c6d221db179dc40b79e5c074 <https://reviews.llvm.org/rGc29513f7e023f125c6d221db179dc40b79e5c074> suggests clang is not actually used). - The lldb shell testing (this appears to deliberately allow using the installed version). `use_lld` is used from: - The main lld tests (we don't want to test the installed version here, only the built version). - The lldb shell testing (this appears to deliberately allow using the installed version). `use_llvm_tool` is used from: - `use_lld` and `use_clang` - The debuginfo_tests to lookup LLDB (see above reasoning for clang) - The tests for lit itself (not in a way where the behaviour change is relevant) Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D102630 Files: lldb/test/Shell/helper/toolchain.py llvm/utils/lit/lit/llvm/config.py
Index: llvm/utils/lit/lit/llvm/config.py =================================================================== --- llvm/utils/lit/lit/llvm/config.py +++ 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 = [] Index: lldb/test/Shell/helper/toolchain.py =================================================================== --- lldb/test/Shell/helper/toolchain.py +++ 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')
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits