From 1e9595e1169a31b518d72c9c64e990a20faec869 Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Mon, 4 Apr 2016 19:44:38 +1000 Subject: [PATCH] Change build_helper to modify suffix of cc This should help avoid issues when using tools like ccache. --- src/build_helper/lib.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 092a1cabc74..87e93afcf09 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -43,10 +43,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf { if target.contains("musl") || target.contains("msvc") { PathBuf::from("ar") } else { + let parent = cc.parent().unwrap(); let file = cc.file_name().unwrap().to_str().unwrap(); - cc.parent().unwrap().join(file.replace("gcc", "ar") - .replace("cc", "ar") - .replace("clang", "ar")) + for suffix in &["gcc", "cc", "clang"] { + if let Some(idx) = file.rfind(suffix) { + let mut file = file[..idx].to_owned(); + file.push_str(suffix); + return parent.join(&file); + } + } + parent.join(file) } }