Skip to content

Commit

Permalink
Removed unnecessary output of linker options when linker is not insta…
Browse files Browse the repository at this point in the history
…lled

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
  • Loading branch information
fschutt committed Dec 31, 2017
1 parent 8c59418 commit 3e3536c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
23 changes: 19 additions & 4 deletions src/librustc_trans/back/link.rs
Expand Up @@ -708,10 +708,25 @@ fn link_natively(sess: &Session,
info!("linker stdout:\n{}", escape_string(&prog.stdout));
},
Err(e) => {
sess.struct_err(&format!("could not exec the linker `{}`: {}", pname.display(), e))
.note(&format!("{:?}", &cmd))
.emit();
if sess.target.target.options.is_like_msvc && e.kind() == io::ErrorKind::NotFound {
let linker_not_found = e.kind() == io::ErrorKind::NotFound;

let mut linker_error = {
if linker_not_found {
sess.struct_err(&format!("linker `{}` not found", pname.display()))
} else {
sess.struct_err(&format!("could not exec the linker `{}`", pname.display()))
}
};

linker_error.note(&format!("{}", e));

if !linker_not_found {
linker_error.note(&format!("{:?}", &cmd));
}

linker_error.emit();

if sess.target.target.options.is_like_msvc && linker_not_found {
sess.note_without_error("the msvc targets depend on the msvc linker \
but `link.exe` was not found");
sess.note_without_error("please ensure that VS 2013 or VS 2015 was installed \
Expand Down
2 changes: 1 addition & 1 deletion src/test/compile-fail/issue-10755.rs
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

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

fn main() {
}

0 comments on commit 3e3536c

Please sign in to comment.