diff options
| author | bors <bors@rust-lang.org> | 2018-01-01 01:00:24 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-01 01:00:24 +0000 |
| commit | 037bc651e56ca0bb92c053b31b87db5fa0dda22c (patch) | |
| tree | 22be87a3544d53464c653404a417adc59f35d1da | |
| parent | ad30f5476df401abcab4c28f482091bb6d68e866 (diff) | |
| parent | 7c13fa37305cf1034328f1e90d1ecf967137ed7c (diff) | |
| download | rust-037bc651e56ca0bb92c053b31b87db5fa0dda22c.tar.gz rust-037bc651e56ca0bb92c053b31b87db5fa0dda22c.zip | |
Auto merge of #47052 - fschutt:master, r=estebank
Improved error messages for linking failure Partial fix for #46998 It's unnecessary to print the linker options if there is no linker installed in the first place. Currently, for libraries, the output is still printed, but that should be cleaned up in the future. If you don't have gcc or g++ installed, so that no linker is installed on the system, the output is now this: ``` $ ./rustc hello.rs error: linker `cc` not found | = note: No such file or directory (os error 2) error: aborting due to previous error ``` For libraries, the linker arguments are still printed, but they should be cleaned up in further commits.
| -rw-r--r-- | src/Cargo.lock | 14 | ||||
| -rw-r--r-- | src/librustc_trans/back/link.rs | 23 | ||||
| -rw-r--r-- | src/test/compile-fail/issue-10755.rs | 2 | ||||
| m--------- | src/tools/cargo | 0 |
4 files changed, 32 insertions, 7 deletions
diff --git a/src/Cargo.lock b/src/Cargo.lock index 7c69601c68d..14cc1d4ec49 100644 --- a/src/Cargo.lock +++ b/src/Cargo.lock @@ -185,7 +185,7 @@ dependencies = [ "env_logger 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "failure 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "fs2 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "git2-curl 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -246,7 +246,7 @@ version = "0.1.0" dependencies = [ "cargo 0.25.0", "filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)", - "flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)", + "flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "git2 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", "hamcrest 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "hex 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", @@ -687,6 +687,15 @@ dependencies = [ ] [[package]] +name = "flate2" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.34 (registry+https://github.com/rust-lang/crates.io-index)", + "miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "fmt_macros" version = "0.0.0" @@ -2829,6 +2838,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum failure_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c7cdda555bb90c9bb67a3b670a0f42de8e73f5981524123ad8578aafec8ddb8b" "checksum filetime 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "aa75ec8f7927063335a9583e7fa87b0110bb888cf766dc01b54c0ff70d760c8e" "checksum flate2 0.2.20 (registry+https://github.com/rust-lang/crates.io-index)" = "e6234dd4468ae5d1e2dbb06fe2b058696fdc50a339c68a393aefbf00bc81e423" +"checksum flate2 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9fac2277e84e5e858483756647a9d0aa8d9a2b7cba517fd84325a0aaa69a0909" "checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3" "checksum foreign-types 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" "checksum foreign-types-shared 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index ec1c7e16c71..42538c5a3ad 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -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 \ diff --git a/src/test/compile-fail/issue-10755.rs b/src/test/compile-fail/issue-10755.rs index 87faff27195..57915bce456 100644 --- a/src/test/compile-fail/issue-10755.rs +++ b/src/test/compile-fail/issue-10755.rs @@ -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() { } diff --git a/src/tools/cargo b/src/tools/cargo -Subproject e08f310188cc0d101550c21b3d88877cfba7e5e +Subproject a88fbace48ac42ab21e1d8609012480d0aeab98 |
