about summary refs log tree commit diff
path: root/compiler/rustc_session/src/filesearch.rs
diff options
context:
space:
mode:
authorRémy Rakic <remy.rakic+github@gmail.com>2024-05-21 17:59:13 +0000
committerRémy Rakic <remy.rakic+github@gmail.com>2024-05-21 18:40:34 +0000
commit6867d6492b1b96173d175b4a4b5887691798daf6 (patch)
treedf25e277d58da54453ec1cb008250a96f7b132d0 /compiler/rustc_session/src/filesearch.rs
parenteb1a5c9bb3df2ce5f003d45f835da0d61d8742cd (diff)
downloadrust-6867d6492b1b96173d175b4a4b5887691798daf6.tar.gz
rust-6867d6492b1b96173d175b4a4b5887691798daf6.zip
add helper to target bin path
Diffstat (limited to 'compiler/rustc_session/src/filesearch.rs')
-rw-r--r--compiler/rustc_session/src/filesearch.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/filesearch.rs b/compiler/rustc_session/src/filesearch.rs
index f4e2436efb9..9cb8cd836e6 100644
--- a/compiler/rustc_session/src/filesearch.rs
+++ b/compiler/rustc_session/src/filesearch.rs
@@ -51,6 +51,14 @@ pub fn make_target_lib_path(sysroot: &Path, target_triple: &str) -> PathBuf {
     PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("lib")])
 }
 
+/// Returns a path to the target's `bin` folder within its `rustlib` path in the sysroot. This is
+/// where binaries are usually installed, e.g. the self-contained linkers, lld-wrappers, LLVM tools,
+/// etc.
+pub fn make_target_bin_path(sysroot: &Path, target_triple: &str) -> PathBuf {
+    let rustlib_path = rustc_target::target_rustlib_path(sysroot, target_triple);
+    PathBuf::from_iter([sysroot, Path::new(&rustlib_path), Path::new("bin")])
+}
+
 #[cfg(unix)]
 fn current_dll_path() -> Result<PathBuf, String> {
     use std::ffi::{CStr, OsStr};