Skip to content

Commit 995f0bd

Browse files
committed
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.
1 parent 11f64d8 commit 995f0bd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/librustc_trans/back/linker.rs

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

0 commit comments

Comments
 (0)