Skip to content

Commit e028b71

Browse files
authored
Prefer clang if linker-plugin-lto specified
Follow up for #1564
1 parent 5e84b3f commit e028b71

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/lib.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,14 @@ impl Build {
28112811
cmd
28122812
}
28132813

2814+
fn prefer_clang(&self) -> bool {
2815+
if let Some(env) = self.getenv("CARGO_ENCODED_RUSTFLAGS") {
2816+
env.to_string_lossy().contains("linker-plugin-lto")
2817+
} else {
2818+
false
2819+
}
2820+
}
2821+
28142822
fn get_base_compiler(&self) -> Result<Tool, Error> {
28152823
let out_dir = self.get_out_dir().ok();
28162824
let out_dir = out_dir.as_deref();
@@ -2844,6 +2852,8 @@ impl Build {
28442852
// also making it available as "cc".
28452853
let default = if cfg!(target_os = "solaris") || cfg!(target_os = "illumos") {
28462854
gnu
2855+
} else if self.prefer_clang() {
2856+
clang
28472857
} else {
28482858
traditional
28492859
};

0 commit comments

Comments
 (0)