Skip to content

Commit 1e9595e

Browse files
committed
Change build_helper to modify suffix of cc
This should help avoid issues when using tools like ccache.
1 parent f92ce2e commit 1e9595e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/build_helper/lib.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf {
4343
if target.contains("musl") || target.contains("msvc") {
4444
PathBuf::from("ar")
4545
} else {
46+
let parent = cc.parent().unwrap();
4647
let file = cc.file_name().unwrap().to_str().unwrap();
47-
cc.parent().unwrap().join(file.replace("gcc", "ar")
48-
.replace("cc", "ar")
49-
.replace("clang", "ar"))
48+
for suffix in &["gcc", "cc", "clang"] {
49+
if let Some(idx) = file.rfind(suffix) {
50+
let mut file = file[..idx].to_owned();
51+
file.push_str(suffix);
52+
return parent.join(&file);
53+
}
54+
}
55+
parent.join(file)
5056
}
5157
}
5258

0 commit comments

Comments
 (0)