Skip passing /natvis to lld-link until supported.

LLVM 5.0.0's lld-link frontend errors out if passed /natvis.
LLVM 6 (maybe earlier?) should at least ignore the flag.
Hopefully LLVM will eventually support the flag, at which point
this workaround can perhaps be simply removed, if 6? is old enough.
This commit is contained in:
MaulingMonkey 2017-09-10 19:37:59 -07:00
parent 11f64d8f88
commit 995f0bdb9b

View File

@ -498,6 +498,18 @@ impl<'a> Linker for MsvcLinker<'a> {
let sysroot = self.sess.sysroot();
let natvis_dir_path = sysroot.join("lib\\rustlib\\etc");
if let Ok(natvis_dir) = fs::read_dir(&natvis_dir_path) {
// LLVM 5.0.0's lld-link frontend doesn't yet recognize, and chokes
// on, the /NATVIS:... flags. LLVM 6 (or earlier) should at worst ignore
// them, eventually mooting this workaround, per this landed patch:
// https://github.com/llvm-mirror/lld/commit/27b9c4285364d8d76bb43839daa100
if let Some(ref linker_path) = self.sess.opts.cg.linker {
if let Some(linker_name) = Path::new(&linker_path).file_stem() {
if linker_name.to_str().unwrap().to_lowercase() == "lld-link" {
self.sess.warn("not embedding natvis: lld-link may not support the flag");
return;
}
}
}
for entry in natvis_dir {
match entry {
Ok(entry) => {