mirror of
https://github.com/rust-lang/rust
synced 2024-09-05 00:24:52 +00:00
Rollup merge of #32729 - pierzchalski:build_helper_suffix, r=alexcrichton
Change build helper to modify suffix The current implementation of [gcc](https://crates.io/crates/gcc) defaults to using the ```CC``` environment variable to determine the compiler. The current global-find-replace in ```build_helper``` causes issues for projects using tools like ```ccache``` if they try to integrate libstd into their build system. Almost all cross-compiler toolchains have the tool name as a suffix of the filename, so changing this to suffix-replacement instead of global-replacement should be fine.
This commit is contained in:
commit
ef8635ec82
|
@ -43,10 +43,16 @@ pub fn cc2ar(cc: &Path, target: &str) -> PathBuf {
|
||||||
if target.contains("musl") || target.contains("msvc") {
|
if target.contains("musl") || target.contains("msvc") {
|
||||||
PathBuf::from("ar")
|
PathBuf::from("ar")
|
||||||
} else {
|
} else {
|
||||||
|
let parent = cc.parent().unwrap();
|
||||||
let file = cc.file_name().unwrap().to_str().unwrap();
|
let file = cc.file_name().unwrap().to_str().unwrap();
|
||||||
cc.parent().unwrap().join(file.replace("gcc", "ar")
|
for suffix in &["gcc", "cc", "clang"] {
|
||||||
.replace("cc", "ar")
|
if let Some(idx) = file.rfind(suffix) {
|
||||||
.replace("clang", "ar"))
|
let mut file = file[..idx].to_owned();
|
||||||
|
file.push_str("ar");
|
||||||
|
return parent.join(&file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parent.join(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue