File tree Expand file tree Collapse file tree 3 files changed +18
-3
lines changed
compiler/rustc_codegen_ssa/src
tests/run-make/linker-warning Expand file tree Collapse file tree 3 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -935,12 +935,12 @@ fn link_natively<'a>(
935935 let mut output = prog. stderr . clone ( ) ;
936936 output. extend_from_slice ( & prog. stdout ) ;
937937 let escaped_output = escape_linker_output ( & output, flavor) ;
938- // FIXME: Add UI tests for this error.
939938 let err = errors:: LinkingFailed {
940939 linker_path : & linker_path,
941940 exit_status : prog. status ,
942941 command : & cmd,
943942 escaped_output,
943+ verbose : sess. opts . verbose ,
944944 } ;
945945 sess. dcx ( ) . emit_err ( err) ;
946946 // If MSVC's `link.exe` was expected but the return code
Original file line number Diff line number Diff line change @@ -408,6 +408,7 @@ pub struct LinkingFailed<'a> {
408408 pub exit_status : ExitStatus ,
409409 pub command : & ' a Command ,
410410 pub escaped_output : String ,
411+ pub verbose : bool ,
411412}
412413
413414impl IntoDiagnostic < ' _ > for LinkingFailed < ' _ > {
@@ -418,7 +419,13 @@ impl IntoDiagnostic<'_> for LinkingFailed<'_> {
418419
419420 let contains_undefined_ref = self . escaped_output . contains ( "undefined reference to" ) ;
420421
421- diag. note ( format ! ( "{:?}" , self . command) ) . note ( self . escaped_output ) ;
422+ if self . verbose {
423+ diag. note ( format ! ( "{:?}" , self . command) ) ;
424+ } else {
425+ diag. note ( "use `--verbose` to show all linker arguments" ) ;
426+ }
427+
428+ diag. note ( self . escaped_output ) ;
422429
423430 // Trying to match an error from OS linkers
424431 // which by now we have no way to translate.
Original file line number Diff line number Diff line change @@ -2,16 +2,24 @@ include ../tools.mk
22
33RUN_RUSTC := $(RUSTC_ORIGINAL ) main.rs -o $(TMPDIR ) /main -C linker=./fake-linker.sh
44
5- all :
5+ all : succeeds_with_warnings errors linker_args
6+
7+ succeeds_with_warnings :
68 # Run rustc with our fake linker, and make sure it shows warnings
79 $(RUN_RUSTC ) -C link-arg=run_make_warn 2>&1 | $(CGREP ) " warning: linker stderr: bar"
810
911 # Make sure it shows stdout, but only when --verbose is passed
1012 $(RUN_RUSTC) -C link-arg=run_make_info --verbose 2>&1 | $(CGREP) "warning: linker stdout: foo"
1113 $(RUN_RUSTC) -C link-arg=run_make_info 2>&1 | $(CGREP) -v "warning: linker stdout: foo"
1214
15+ errors :
1316 # Make sure we short-circuit this new path if the linker exits with an error (so the diagnostic is less verbose)
1417 rm -f $(TMPDIR ) /main
1518 $(RUN_RUSTC ) -C link-arg=run_make_error 2>&1 | $(CGREP ) " note: error: baz"
1619 ! [ -e $( TMPDIR) /main ]
1720
21+ linker_args :
22+ # Make sure we don't show the linker args unless `--verbose` is passed
23+ $(RUN_RUSTC ) --verbose -C link-arg=run_make_error 2>&1 | $(CGREP ) -e " PATH=.*fake-linker.sh.*run_make_error"
24+ $(RUN_RUSTC ) -C link-arg=run_make_error 2>&1 | $(CGREP ) -v -e " PATH=.*fake-linker.sh.*run_make_error"
25+
You can’t perform that action at this time.
0 commit comments