Skip to content

Commit 3e3536c

Browse files
committed
Removed unnecessary output of linker options when linker is not installed
It's unnecessary to print the linker options if there is no linker installed. Currently, for libraries, the output is still printed, see #46998 for discussion
1 parent 8c59418 commit 3e3536c

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

src/librustc_trans/back/link.rs

+19-4
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,25 @@ fn link_natively(sess: &Session,
708708
info!("linker stdout:\n{}", escape_string(&prog.stdout));
709709
},
710710
Err(e) => {
711-
sess.struct_err(&format!("could not exec the linker `{}`: {}", pname.display(), e))
712-
.note(&format!("{:?}", &cmd))
713-
.emit();
714-
if sess.target.target.options.is_like_msvc && e.kind() == io::ErrorKind::NotFound {
711+
let linker_not_found = e.kind() == io::ErrorKind::NotFound;
712+
713+
let mut linker_error = {
714+
if linker_not_found {
715+
sess.struct_err(&format!("linker `{}` not found", pname.display()))
716+
} else {
717+
sess.struct_err(&format!("could not exec the linker `{}`", pname.display()))
718+
}
719+
};
720+
721+
linker_error.note(&format!("{}", e));
722+
723+
if !linker_not_found {
724+
linker_error.note(&format!("{:?}", &cmd));
725+
}
726+
727+
linker_error.emit();
728+
729+
if sess.target.target.options.is_like_msvc && linker_not_found {
715730
sess.note_without_error("the msvc targets depend on the msvc linker \
716731
but `link.exe` was not found");
717732
sess.note_without_error("please ensure that VS 2013 or VS 2015 was installed \

src/test/compile-fail/issue-10755.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
// compile-flags: -C linker=llllll -Z linker-flavor=ld
12-
// error-pattern: the linker `llllll`
12+
// error-pattern: linker `llllll` not found
1313

1414
fn main() {
1515
}

0 commit comments

Comments
 (0)