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.
This commit is contained in:
commit
037bc651e5
14
src/Cargo.lock
generated
14
src/Cargo.lock
generated
@ -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)",
|
||||
@ -686,6 +686,15 @@ dependencies = [
|
||||
"miniz-sys 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
@ -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 \
|
||||
|
@ -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() {
|
||||
}
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e08f310188cc0d101550c21b3d88877cfba7e5e1
|
||||
Subproject commit a88fbace48ac42ab21e1d8609012480d0aeab982
|
Loading…
x
Reference in New Issue
Block a user