From 1e9595e1169a31b518d72c9c64e990a20faec869 Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Mon, 4 Apr 2016 19:44:38 +1000 Subject: [PATCH 1/2] 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) } } From 0fe1359885288537833d4b8cd6db724b46ea07b7 Mon Sep 17 00:00:00 2001 From: pierzchalski Date: Mon, 4 Apr 2016 21:14:15 +1000 Subject: [PATCH 2/2] whoops --- src/build_helper/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/build_helper/lib.rs b/src/build_helper/lib.rs index 87e93afcf09..8e1da69cf02 100644 --- a/src/build_helper/lib.rs +++ b/src/build_helper/lib.rs @@ -48,7 +48,7 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf { for suffix in &["gcc", "cc", "clang"] { if let Some(idx) = file.rfind(suffix) { let mut file = file[..idx].to_owned(); - file.push_str(suffix); + file.push_str("ar"); return parent.join(&file); } }