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
4 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -1004,6 +1004,7 @@ fn link_natively(
1004
1004
exit_status : prog. status ,
1005
1005
command : & cmd,
1006
1006
escaped_output,
1007
+ verbose : sess. opts . verbose ,
1007
1008
} ;
1008
1009
sess. dcx ( ) . emit_err ( err) ;
1009
1010
// 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> {
349
349
pub exit_status : ExitStatus ,
350
350
pub command : & ' a Command ,
351
351
pub escaped_output : String ,
352
+ pub verbose : bool ,
352
353
}
353
354
354
355
impl < G : EmissionGuarantee > Diagnostic < ' _ , G > for LinkingFailed < ' _ > {
@@ -359,7 +360,17 @@ impl<G: EmissionGuarantee> Diagnostic<'_, G> for LinkingFailed<'_> {
359
360
360
361
let contains_undefined_ref = self . escaped_output . contains ( "undefined reference to" ) ;
361
362
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) ) ;
363
374
364
375
// Trying to match an error from OS linkers
365
376
// 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 {
221
221
self
222
222
}
223
223
224
+ pub fn verbose ( & mut self ) -> & mut Self {
225
+ self . cmd . arg ( "--verbose" ) ;
226
+ self
227
+ }
228
+
224
229
/// Specify json messages printed by the compiler
225
230
pub fn json ( & mut self , items : & str ) -> & mut Self {
226
231
self . cmd . arg ( format ! ( "--json={items}" ) ) ;
Original file line number Diff line number Diff line change 2
2
3
3
//@ only-apple
4
4
5
- use run_make_support:: { Rustc , run, rustc} ;
5
+ use run_make_support:: { Rustc , diff , run, rustc} ;
6
6
7
7
fn compile ( cfg : & str ) -> Rustc {
8
8
let mut rustc = rustc ( ) ;
@@ -16,11 +16,15 @@ fn main() {
16
16
run ( "main" ) ;
17
17
}
18
18
19
- let errs = compile ( "omit" ) . run_fail ( ) ;
19
+ let errs = compile ( "omit" ) . verbose ( ) . run_fail ( ) ;
20
20
// The linker's exact error output changes between Xcode versions, depends on
21
21
// linker invocation details, and the linker sometimes outputs more warnings.
22
22
errs. assert_stderr_contains_regex ( r"error: linking with `.*` failed" ) ;
23
23
errs. assert_stderr_contains_regex ( r"(Undefined symbols|ld: symbol[^\s]* not found)" ) ;
24
24
errs. assert_stderr_contains_regex ( r".?_CFRunLoopGetTypeID.?, referenced from:" ) ;
25
25
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
+ ) ;
26
30
}
You can’t perform that action at this time.
0 commit comments