@@ -495,7 +495,6 @@ impl<'a> CrateLocator<'a> {
495
495
} ;
496
496
497
497
if !self . rejected_via_filename . is_empty ( ) {
498
- let dylibname = self . dylibname ( ) ;
499
498
let mismatches = self . rejected_via_filename . iter ( ) ;
500
499
for & CrateMismatch { ref path, .. } in mismatches {
501
500
err. note ( & format ! (
@@ -505,7 +504,7 @@ impl<'a> CrateLocator<'a> {
505
504
) )
506
505
. help ( & format ! (
507
506
"file name should be lib*.rlib or {}*.{}" ,
508
- dylibname . 0 , dylibname . 1
507
+ self . target . options . dll_prefix , self . target . options . dll_suffix
509
508
) ) ;
510
509
}
511
510
}
@@ -520,13 +519,12 @@ impl<'a> CrateLocator<'a> {
520
519
extra_prefix : & str ,
521
520
seen_paths : & mut FxHashSet < PathBuf > ,
522
521
) -> Option < Library > {
523
- let dypair = self . dylibname ( ) ;
524
- let staticpair = self . staticlibname ( ) ;
525
-
526
522
// want: crate_name.dir_part() + prefix + crate_name.file_part + "-"
527
- let dylib_prefix = format ! ( "{}{}{}" , dypair. 0 , self . crate_name, extra_prefix) ;
523
+ let dylib_prefix =
524
+ format ! ( "{}{}{}" , self . target. options. dll_prefix, self . crate_name, extra_prefix) ;
528
525
let rlib_prefix = format ! ( "lib{}{}" , self . crate_name, extra_prefix) ;
529
- let staticlib_prefix = format ! ( "{}{}{}" , staticpair. 0 , self . crate_name, extra_prefix) ;
526
+ let staticlib_prefix =
527
+ format ! ( "{}{}{}" , self . target. options. staticlib_prefix, self . crate_name, extra_prefix) ;
530
528
531
529
let mut candidates: FxHashMap < _ , ( FxHashMap < _ , _ > , FxHashMap < _ , _ > , FxHashMap < _ , _ > ) > =
532
530
Default :: default ( ) ;
@@ -554,10 +552,18 @@ impl<'a> CrateLocator<'a> {
554
552
( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rlib" . len ( ) ) ] , CrateFlavor :: Rlib )
555
553
} else if file. starts_with ( & rlib_prefix) && file. ends_with ( ".rmeta" ) {
556
554
( & file[ ( rlib_prefix. len ( ) ) ..( file. len ( ) - ".rmeta" . len ( ) ) ] , CrateFlavor :: Rmeta )
557
- } else if file. starts_with ( & dylib_prefix) && file. ends_with ( & dypair. 1 ) {
558
- ( & file[ ( dylib_prefix. len ( ) ) ..( file. len ( ) - dypair. 1 . len ( ) ) ] , CrateFlavor :: Dylib )
555
+ } else if file. starts_with ( & dylib_prefix)
556
+ && file. ends_with ( & self . target . options . dll_suffix )
557
+ {
558
+ (
559
+ & file
560
+ [ ( dylib_prefix. len ( ) ) ..( file. len ( ) - self . target . options . dll_suffix . len ( ) ) ] ,
561
+ CrateFlavor :: Dylib ,
562
+ )
559
563
} else {
560
- if file. starts_with ( & staticlib_prefix) && file. ends_with ( & staticpair. 1 ) {
564
+ if file. starts_with ( & staticlib_prefix)
565
+ && file. ends_with ( & self . target . options . staticlib_suffix )
566
+ {
561
567
staticlibs
562
568
. push ( CrateMismatch { path : spf. path . clone ( ) , got : "static" . to_string ( ) } ) ;
563
569
}
@@ -859,32 +865,19 @@ impl<'a> CrateLocator<'a> {
859
865
Some ( hash)
860
866
}
861
867
862
- // Returns the corresponding (prefix, suffix) that files need to have for
863
- // dynamic libraries
864
- fn dylibname ( & self ) -> ( String , String ) {
865
- let t = & self . target ;
866
- ( t. options . dll_prefix . clone ( ) , t. options . dll_suffix . clone ( ) )
867
- }
868
-
869
- // Returns the corresponding (prefix, suffix) that files need to have for
870
- // static libraries
871
- fn staticlibname ( & self ) -> ( String , String ) {
872
- let t = & self . target ;
873
- ( t. options . staticlib_prefix . clone ( ) , t. options . staticlib_suffix . clone ( ) )
874
- }
875
-
876
868
fn find_commandline_library ( & mut self ) -> Option < Library > {
877
869
// First, filter out all libraries that look suspicious. We only accept
878
870
// files which actually exist that have the correct naming scheme for
879
871
// rlibs/dylibs.
880
872
let sess = self . sess ;
881
- let dylibname = self . dylibname ( ) ;
882
873
let mut rlibs = FxHashMap :: default ( ) ;
883
874
let mut rmetas = FxHashMap :: default ( ) ;
884
875
let mut dylibs = FxHashMap :: default ( ) ;
885
876
{
886
877
let crate_name = self . crate_name ;
887
878
let rejected_via_filename = & mut self . rejected_via_filename ;
879
+ let dll_prefix = & self . target . options . dll_prefix ;
880
+ let dll_suffix = & self . target . options . dll_suffix ;
888
881
let locs = self . exact_paths . iter ( ) . filter ( |loc| {
889
882
if !loc. exists ( ) {
890
883
sess. err ( & format ! (
@@ -909,8 +902,7 @@ impl<'a> CrateLocator<'a> {
909
902
{
910
903
return true ;
911
904
} else {
912
- let ( ref prefix, ref suffix) = dylibname;
913
- if file. starts_with ( & prefix[ ..] ) && file. ends_with ( & suffix[ ..] ) {
905
+ if file. starts_with ( dll_prefix) && file. ends_with ( dll_suffix) {
914
906
return true ;
915
907
}
916
908
}
0 commit comments