Skip to content

Commit 7be8c8e

Browse files
committed
Force linking with spectre-mitigated libraries if /Qspectre is passed.
1 parent f2e1b1c commit 7be8c8e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/lib.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,6 +1012,29 @@ impl Build {
10121012
atlmfc_lib.display()
10131013
));
10141014
}
1015+
1016+
let compiler = self.try_get_compiler()?;
1017+
for arg in compiler.args.iter() {
1018+
if arg.to_str().unwrap().contains("Qspectre") {
1019+
for (var, val) in compiler.env.iter() {
1020+
if var == "LIB" {
1021+
for path in env::split_paths(&val) {
1022+
if let Some(last) = path.iter().last() {
1023+
// check upon .../lib/{platform}/../spectre/{platform}
1024+
let spectre = path.parent().unwrap().join("spectre").join(last);
1025+
if spectre.exists() {
1026+
self.print(&format!(
1027+
"cargo:rustc-link-search=native={}",
1028+
spectre.display()
1029+
));
1030+
}
1031+
}
1032+
}
1033+
break;
1034+
}
1035+
}
1036+
}
1037+
}
10151038
}
10161039

10171040
self.print(&format!("cargo:rustc-link-lib=static={}", lib_name));

0 commit comments

Comments
 (0)