Skip to content

Commit

Permalink
Fix determination of llvm-objcopy included in toolchain
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Weiner <[email protected]>
  • Loading branch information
mraerino authored and orangecms committed Sep 9, 2023
1 parent 03f2b2b commit 6a4e20a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions xtask/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,12 @@ fn cargo() -> String {
fn objcopy() -> String {
let llvm_objcopy = {
let toolchain = env_or("RUSTUP_TOOLCHAIN", "nightly-x86_64-unknown-none");
let pos = toolchain.find('-').map(|p| p + 1).unwrap_or(0);
let host = toolchain[pos..].to_string();

// find host architecture by taking last 3 segments from toolchain
let mut arch_segments: Box<[_]> = toolchain.split('-').rev().take(3).collect();
arch_segments.reverse();
let host = arch_segments.join("-");

let home = env_or("RUSTUP_HOME", "");
let mut path = PathBuf::from(home);
path.push("toolchains");
Expand All @@ -233,11 +237,11 @@ fn objcopy() -> String {
path.push("rustlib");
path.push(host);
path.push("bin");
path.push("rust-objcopy");
path.push("llvm-objcopy");
if path.exists() {
path.into_os_string().into_string().unwrap()
} else {
"rust-objcopy".into()
"llvm-objcopy".into()
}
};
env_or("OBJCOPY", &llvm_objcopy)
Expand Down

0 comments on commit 6a4e20a

Please sign in to comment.