File tree Expand file tree Collapse file tree 4 files changed +24
-3
lines changed
compiler/rustc_codegen_ssa/src
src/tools/run-make-support/src/external_deps
tests/run-make/linkage-attr-framework Expand file tree Collapse file tree 4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -1004,6 +1004,7 @@ fn link_natively(
10041004 exit_status : prog. status ,
10051005 command : & cmd,
10061006 escaped_output,
1007+ verbose : sess. opts . verbose ,
10071008 } ;
10081009 sess. dcx ( ) . emit_err ( err) ;
10091010 // If MSVC's `link.exe` was expected but the return code
Original file line number Diff line number Diff line change @@ -349,6 +349,7 @@ pub(crate) struct LinkingFailed<'a> {
349349 pub exit_status : ExitStatus ,
350350 pub command : & ' a Command ,
351351 pub escaped_output : String ,
352+ pub verbose : bool ,
352353}
353354
354355impl < G : EmissionGuarantee > Diagnostic < ' _ , G > for LinkingFailed < ' _ > {
@@ -359,7 +360,17 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
359360
360361 let contains_undefined_ref = self . escaped_output . contains ( "undefined reference to" ) ;
361362
362- diag. note ( format ! ( "{:?}" , self . command) ) . note ( self . escaped_output ) ;
363+ let command = format ! ( "{:?}" , self . command) ;
364+ let width = 100 ;
365+ match ( self . verbose , command. len ( ) > width) {
366+ ( false , true ) => {
367+ diag. note ( "to see the full command that was run, rerun with `--verbose` flag" ) ;
368+ }
369+ ( true , _) | ( _, false ) => {
370+ diag. note ( command) ;
371+ }
372+ }
373+ diag. note ( format ! ( "output:\n {}" , self . escaped_output) ) ;
363374
364375 // Trying to match an error from OS linkers
365376 // which by now we have no way to translate.
Original file line number Diff line number Diff line change @@ -221,6 +221,11 @@ impl Rustc {
221221 self
222222 }
223223
224+ pub fn verbose ( & mut self ) -> & mut Self {
225+ self . cmd . arg ( "--verbose" ) ;
226+ self
227+ }
228+
224229 /// Specify json messages printed by the compiler
225230 pub fn json ( & mut self , items : & str ) -> & mut Self {
226231 self . cmd . arg ( format ! ( "--json={items}" ) ) ;
Original file line number Diff line number Diff line change 22
33//@ only-apple
44
5- use run_make_support:: { Rustc , run, rustc} ;
5+ use run_make_support:: { Rustc , diff , run, rustc} ;
66
77fn compile ( cfg : & str ) -> Rustc {
88 let mut rustc = rustc ( ) ;
@@ -16,11 +16,15 @@ fn main() {
1616 run ( "main" ) ;
1717 }
1818
19- let errs = compile ( "omit" ) . run_fail ( ) ;
19+ let errs = compile ( "omit" ) . verbose ( ) . run_fail ( ) ;
2020 // The linker's exact error output changes between Xcode versions, depends on
2121 // linker invocation details, and the linker sometimes outputs more warnings.
2222 errs. assert_stderr_contains_regex ( r"error: linking with `.*` failed" ) ;
2323 errs. assert_stderr_contains_regex ( r"(Undefined symbols|ld: symbol[^\s]* not found)" ) ;
2424 errs. assert_stderr_contains_regex ( r".?_CFRunLoopGetTypeID.?, referenced from:" ) ;
2525 errs. assert_stderr_contains ( "clang: error: linker command failed with exit code 1" ) ;
26+ // Ensure we don't show the full linker command by default.
27+ let errs = compile ( "omit" ) . run_fail ( ) . assert_stderr_contains (
28+ "to see the full command that was run, rerun with `--verbose` flag" ,
29+ ) ;
2630}
You can’t perform that action at this time.
0 commit comments