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 = linker
13 .and_then(|name| name.to_str())
14 .unwrap_or_else(|| sess.fatal("couldn't extract file name from specified linker"));
16 if linker_file_name == "ld.lld" {
18 linker.set_file_name(tool)
21 let tool_file_name = linker_file_name
24 .replace("clang", tool)
27 linker.set_file_name(tool_file_name)