1
1
use super :: command:: Command ;
2
2
use super :: symbol_export;
3
- use crate :: errors:: LibDefWriteFailure ;
3
+ use crate :: errors;
4
4
use rustc_span:: symbol:: sym;
5
5
6
6
use std:: ffi:: { OsStr , OsString } ;
@@ -91,13 +91,13 @@ pub fn get_linker<'a>(
91
91
arg. push ( format ! ( "{}\\ lib\\ {}\\ store" , root_lib_path. display( ) , a) ) ;
92
92
cmd. arg ( & arg) ;
93
93
} else {
94
- warn ! ( "arch is not supported" ) ;
94
+ sess . emit_warning ( errors :: UnsupportedArch ) ;
95
95
}
96
96
} else {
97
- warn ! ( "MSVC root path lib location not found" ) ;
97
+ sess . emit_warning ( errors :: MsvcPathNotFound ) ;
98
98
}
99
99
} else {
100
- warn ! ( "link.exe not found" ) ;
100
+ sess . emit_warning ( errors :: LinkExeNotFound ) ;
101
101
}
102
102
}
103
103
@@ -435,11 +435,11 @@ impl<'a> Linker for GccLinker<'a> {
435
435
// FIXME(81490): ld64 doesn't support these flags but macOS 11
436
436
// has -needed-l{} / -needed_library {}
437
437
// 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 ) ;
439
439
} else if self . is_gnu && !self . sess . target . is_like_windows {
440
440
self . linker_arg ( "--no-as-needed" ) ;
441
441
} else {
442
- self . sess . warn ( "`as-needed` modifier not supported for current linker" ) ;
442
+ self . sess . emit_warning ( errors :: LinkerUnsupportedModifier ) ;
443
443
}
444
444
}
445
445
self . hint_dynamic ( ) ;
@@ -493,7 +493,7 @@ impl<'a> Linker for GccLinker<'a> {
493
493
// FIXME(81490): ld64 as of macOS 11 supports the -needed_framework
494
494
// flag but we have no way to detect that here.
495
495
// 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 ) ;
497
497
}
498
498
self . cmd . arg ( "-framework" ) . arg ( framework) ;
499
499
}
@@ -667,7 +667,7 @@ impl<'a> Linker for GccLinker<'a> {
667
667
}
668
668
} ;
669
669
if let Err ( error) = res {
670
- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
670
+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
671
671
}
672
672
} else if is_windows {
673
673
let res: io:: Result < ( ) > = try {
@@ -682,7 +682,7 @@ impl<'a> Linker for GccLinker<'a> {
682
682
}
683
683
} ;
684
684
if let Err ( error) = res {
685
- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
685
+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
686
686
}
687
687
} else {
688
688
// Write an LD version script
@@ -698,8 +698,8 @@ impl<'a> Linker for GccLinker<'a> {
698
698
}
699
699
writeln ! ( f, "\n local:\n *;\n }};" ) ?;
700
700
} ;
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 } ) ;
703
703
}
704
704
}
705
705
@@ -916,9 +916,8 @@ impl<'a> Linker for MsvcLinker<'a> {
916
916
self . cmd . arg ( arg) ;
917
917
}
918
918
}
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 } ) ;
922
921
}
923
922
}
924
923
}
@@ -973,7 +972,7 @@ impl<'a> Linker for MsvcLinker<'a> {
973
972
}
974
973
} ;
975
974
if let Err ( error) = res {
976
- self . sess . emit_fatal ( LibDefWriteFailure { error } ) ;
975
+ self . sess . emit_fatal ( errors :: LibDefWriteFailure { error } ) ;
977
976
}
978
977
let mut arg = OsString :: from ( "/DEF:" ) ;
979
978
arg. push ( path) ;
@@ -1436,7 +1435,7 @@ impl<'a> Linker for L4Bender<'a> {
1436
1435
1437
1436
fn export_symbols ( & mut self , _: & Path , _: CrateType , _: & [ String ] ) {
1438
1437
// ToDo, not implemented, copy from GCC
1439
- self . sess . warn ( "exporting symbols not implemented yet for L4Bender" ) ;
1438
+ self . sess . emit_warning ( errors :: L4BenderExportingSymbolsUnimplemented ) ;
1440
1439
return ;
1441
1440
}
1442
1441
@@ -1728,8 +1727,8 @@ impl<'a> Linker for BpfLinker<'a> {
1728
1727
writeln ! ( f, "{}" , sym) ?;
1729
1728
}
1730
1729
} ;
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 } ) ;
1733
1732
} else {
1734
1733
self . cmd . arg ( "--export-symbols" ) . arg ( & path) ;
1735
1734
}
0 commit comments