Add suggestions for "undefined reference" link errors
This commit is contained in:
parent
6a5b97adb4
commit
ce63d55bc7
@ -912,14 +912,23 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
|||||||
if !prog.status.success() {
|
if !prog.status.success() {
|
||||||
let mut output = prog.stderr.clone();
|
let mut output = prog.stderr.clone();
|
||||||
output.extend_from_slice(&prog.stdout);
|
output.extend_from_slice(&prog.stdout);
|
||||||
sess.struct_err(&format!(
|
let escaped_output = escape_stdout_stderr_string(&output);
|
||||||
|
let mut err = sess.struct_err(&format!(
|
||||||
"linking with `{}` failed: {}",
|
"linking with `{}` failed: {}",
|
||||||
linker_path.display(),
|
linker_path.display(),
|
||||||
prog.status
|
prog.status
|
||||||
))
|
));
|
||||||
.note(&format!("{:?}", &cmd))
|
err.note(&format!("{:?}", &cmd)).note(&escaped_output);
|
||||||
.note(&escape_stdout_stderr_string(&output))
|
if escaped_output.contains("undefined reference to") {
|
||||||
.emit();
|
err.help(
|
||||||
|
"some `extern` functions couldn't be found; some native libraries may \
|
||||||
|
need to be installed or have their path specified",
|
||||||
|
);
|
||||||
|
err.note("use the `-l` flag to specify native libraries to link");
|
||||||
|
err.note("use the `cargo:rustc-link-lib` directive to specify the native \
|
||||||
|
libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)");
|
||||||
|
}
|
||||||
|
err.emit();
|
||||||
|
|
||||||
// If MSVC's `link.exe` was expected but the return code
|
// If MSVC's `link.exe` was expected but the return code
|
||||||
// is not a Microsoft LNK error then suggest a way to fix or
|
// is not a Microsoft LNK error then suggest a way to fix or
|
||||||
|
Loading…
x
Reference in New Issue
Block a user