File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
compiler/rustc_codegen_ssa/src/back Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -912,14 +912,23 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
912912 if !prog. status . success ( ) {
913913 let mut output = prog. stderr . clone ( ) ;
914914 output. extend_from_slice ( & prog. stdout ) ;
915- sess. struct_err ( & format ! (
915+ let escaped_output = escape_stdout_stderr_string ( & output) ;
916+ let mut err = sess. struct_err ( & format ! (
916917 "linking with `{}` failed: {}" ,
917918 linker_path. display( ) ,
918919 prog. status
919- ) )
920- . note ( & format ! ( "{:?}" , & cmd) )
921- . note ( & escape_stdout_stderr_string ( & output) )
922- . emit ( ) ;
920+ ) ) ;
921+ err. note ( & format ! ( "{:?}" , & cmd) ) . note ( & escaped_output) ;
922+ if escaped_output. contains ( "undefined reference to" ) {
923+ err. help (
924+ "some `extern` functions couldn't be found; some native libraries may \
925+ need to be installed or have their path specified",
926+ ) ;
927+ err. note ( "use the `-l` flag to specify native libraries to link" ) ;
928+ err. note ( "use the `cargo:rustc-link-lib` directive to specify the native \
929+ libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)") ;
930+ }
931+ err. emit ( ) ;
923932
924933 // If MSVC's `link.exe` was expected but the return code
925934 // is not a Microsoft LNK error then suggest a way to fix or
You can’t perform that action at this time.
0 commit comments