use std::io::Write;
use std::num::NonZeroU32;
use std::ops::{Div, Mul};
-use std::path::PathBuf;
+use std::path::{Path, PathBuf};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
pub target: Target,
pub host: Target,
pub opts: config::Options,
- pub host_tlib_path: SearchPath,
- /// `None` if the host and target are the same.
- pub target_tlib_path: Option<SearchPath>,
+ pub host_tlib_path: Lrc<SearchPath>,
+ pub target_tlib_path: Lrc<SearchPath>,
pub parse_sess: ParseSess,
pub sysroot: PathBuf,
/// The name of the root source file of the crate, in the local file system.
&self.sysroot,
self.opts.target_triple.triple(),
&self.opts.search_paths,
- // `target_tlib_path == None` means it's the same as `host_tlib_path`.
- self.target_tlib_path.as_ref().unwrap_or(&self.host_tlib_path),
+ &self.target_tlib_path,
kind,
)
}
)
}
+ /// Returns a list of directories where target-specific tool binaries are located.
+ pub fn get_tools_search_paths(&self, self_contained: bool) -> Vec<PathBuf> {
+ let rustlib_path = rustc_target::target_rustlib_path(&self.sysroot, &config::host_triple());
+ let p = std::array::IntoIter::new([
+ Path::new(&self.sysroot),
+ Path::new(&rustlib_path),
+ Path::new("bin"),
+ ])
+ .collect::<PathBuf>();
+ if self_contained { vec![p.clone(), p.join("self-contained")] } else { vec![p] }
+ }
+
pub fn init_incr_comp_session(
&self,
session_dir: PathBuf,
let host_triple = config::host_triple();
let target_triple = sopts.target_triple.triple();
- let host_tlib_path = SearchPath::from_sysroot_and_triple(&sysroot, host_triple);
+ let host_tlib_path = Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, host_triple));
let target_tlib_path = if host_triple == target_triple {
- None
+ // Use the same `SearchPath` if host and target triple are identical to avoid unnecessary
+ // rescanning of the target lib path and an unnecessary allocation.
+ host_tlib_path.clone()
} else {
- Some(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
+ Lrc::new(SearchPath::from_sysroot_and_triple(&sysroot, target_triple))
};
let file_path_mapping = sopts.file_path_mapping();