1 //! Locating various executables part of a C toolchain.
3 use std::path::PathBuf;
5 use rustc_codegen_ssa::back::link::linker_and_flavor;
6 use rustc_session::Session;
8 /// Tries to infer the path of a binary for the target toolchain from the linker name.
9 pub(crate) fn get_toolchain_binary(sess: &Session, tool: &str) -> PathBuf {
10 let (mut linker, _linker_flavor) = linker_and_flavor(sess);
11 let linker_file_name =
12 linker.file_name().unwrap().to_str().expect("linker filename should be valid UTF-8");
14 if linker_file_name == "ld.lld" {
16 linker.set_file_name(tool)
19 let tool_file_name = linker_file_name
22 .replace("clang", tool)
25 linker.set_file_name(tool_file_name)