11use super :: command:: Command ;
22use super :: symbol_export;
3- use crate :: errors:: LibDefWriteFailure ;
3+ use crate :: errors;
44use rustc_span:: symbol:: sym;
55
66use std:: ffi:: { OsStr , OsString } ;
@@ -91,13 +91,13 @@ pub fn get_linker<'a>(
9191 arg. push ( format ! ( "{}\\ lib\\ {}\\ store" , root_lib_path. display( ) , a) ) ;
9292 cmd. arg ( & arg) ;
9393 } else {
94- warn ! ( "arch is not supported" ) ;
94+ sess . emit_warning ( errors :: UnsupportedArch ) ;
9595 }
9696 } else {
97- warn ! ( "MSVC root path lib location not found" ) ;
97+ sess . emit_warning ( errors :: MsvcPathNotFound ) ;
9898 }
9999 } else {
100- warn ! ( "link.exe not found" ) ;
100+ sess . emit_warning ( errors :: LinkExeNotFound ) ;
101101 }
102102 }
103103
@@ -435,11 +435,11 @@ impl<'a> Linker for GccLinker<'a> {
435435 // FIXME(81490): ld64 doesn't support these flags but macOS 11
436436 // has -needed-l{} / -needed_library {}
437437 // but we have no way to detect that here.
438- self . sess . warn ( "`as-needed` modifier not implemented yet for ld64" ) ;
438+ self . sess . emit_warning ( errors :: Ld64UnimplementedModifier ) ;
439439 } else if self . is_gnu && !self . sess . target . is_like_windows {
440440 self . linker_arg ( "--no-as-needed" ) ;
441441 } else {
442- self . sess . warn ( "`as-needed` modifier not supported for current linker" ) ;
442+ self . sess . emit_warning ( errors :: LinkerUnsupportedModifier ) ;
443443 }
444444 }
445445 self . hint_dynamic ( ) ;
@@ -493,7 +493,7 @@ impl<'a> Linker for GccLinker<'a> {
493493 // FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
494494 // flag but we have no way to detect that here.
495495 // self.cmd.arg("-needed_framework").arg(framework);
496- self . sess . warn ( "`as-needed` modifier not implemented yet for ld64" ) ;
496+ self . sess . emit_warning ( errors :: Ld64UnimplementedModifier ) ;
497497 }
498498 self . cmd . arg ( "-framework" ) . arg ( framework) ;
499499 }
@@ -667,7 +667,7 @@ impl<'a> Linker for GccLinker<'a> {
667667 }
668668 } ;
669669 if let Err ( error) = res {
670- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
670+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
671671 }
672672 } else if is_windows {
673673 let res: io:: Result < ( ) > = try {
@@ -682,7 +682,7 @@ impl<'a> Linker for GccLinker<'a> {
682682 }
683683 } ;
684684 if let Err ( error) = res {
685- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
685+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
686686 }
687687 } else {
688688 // Write an LD version script
@@ -698,8 +698,8 @@ impl<'a> Linker for GccLinker<'a> {
698698 }
699699 writeln ! ( f, "\n local:\n *;\n }};" ) ?;
700700 } ;
701- if let Err ( e ) = res {
702- self . sess . fatal ( & format ! ( "failed to write version script: {}" , e ) ) ;
701+ if let Err ( error ) = res {
702+ self . sess . emit_fatal ( errors :: VersionScriptWriteFailure { error } ) ;
703703 }
704704 }
705705
@@ -916,9 +916,8 @@ impl<'a> Linker for MsvcLinker<'a> {
916916 self . cmd . arg ( arg) ;
917917 }
918918 }
919- Err ( err) => {
920- self . sess
921- . warn ( & format ! ( "error enumerating natvis directory: {}" , err) ) ;
919+ Err ( error) => {
920+ self . sess . emit_warning ( errors:: NoNatvisDirectory { error } ) ;
922921 }
923922 }
924923 }
@@ -973,7 +972,7 @@ impl<'a> Linker for MsvcLinker<'a> {
973972 }
974973 } ;
975974 if let Err ( error) = res {
976- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
975+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
977976 }
978977 let mut arg = OsString :: from ( "/DEF:" ) ;
979978 arg. push ( path) ;
@@ -1436,7 +1435,7 @@ impl<'a> Linker for L4Bender<'a> {
14361435
14371436 fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ String ] ) {
14381437 // ToDo, not implemented, copy from GCC
1439- self . sess . warn ( "exporting symbols not implemented yet for L4Bender" ) ;
1438+ self . sess . emit_warning ( errors :: L4BenderExportingSymbolsUnimplemented ) ;
14401439 return ;
14411440 }
14421441
@@ -1728,8 +1727,8 @@ impl<'a> Linker for BpfLinker<'a> {
17281727 writeln ! ( f, "{}" , sym) ?;
17291728 }
17301729 } ;
1731- if let Err ( e ) = res {
1732- self . sess . fatal ( & format ! ( "failed to write symbols file: {}" , e ) ) ;
1730+ if let Err ( error ) = res {
1731+ self . sess . emit_fatal ( errors :: SymbolFileWriteFailure { error } ) ;
17331732 } else {
17341733 self . cmd . arg ( "--export-symbols" ) . arg ( & path) ;
17351734 }
0 commit comments