11use gen_target_info:: { get_target_specs_from_json, write_target_tuple_mapping, RustcTargetSpecs } ;
2- use std:: { fs:: File , io:: Write as _} ;
2+ use std:: { collections :: BTreeMap , fs:: File , io:: Write as _} ;
33
44const PRELUDE : & str = r#"//! This file is generated code. Please edit the generator
55//! in dev-tools/gen-target-info if you need to make changes.
66
77"# ;
88
99fn generate_riscv_arch_mapping ( f : & mut File , target_specs : & RustcTargetSpecs ) {
10- let mut riscv_target_mapping = target_specs
10+ let riscv_target_mapping = target_specs
1111 . 0
1212 . iter ( )
1313 . filter_map ( |( target, target_spec) | {
1414 let arch = target. split_once ( '-' ) . unwrap ( ) . 0 ;
1515 ( arch. contains ( "riscv" ) && arch != target_spec. arch )
1616 . then_some ( ( arch, & * target_spec. arch ) )
1717 } )
18- . collect :: < Vec < _ > > ( ) ;
19- riscv_target_mapping. sort_unstable_by_key ( |( arch, _) | & * * arch) ;
20- riscv_target_mapping. dedup ( ) ;
18+ . collect :: < BTreeMap < _ , _ > > ( ) ;
2119 write_target_tuple_mapping ( f, "RISCV_ARCH_MAPPING" , & riscv_target_mapping) ;
2220}
2321
2422fn generate_windows_triple_mapping ( f : & mut File , target_specs : & RustcTargetSpecs ) {
25- let mut windows_target_mapping = target_specs
23+ let windows_target_mapping = target_specs
2624 . 0
2725 . iter ( )
2826 . filter_map ( |( target, target_spec) | {
@@ -31,9 +29,7 @@ fn generate_windows_triple_mapping(f: &mut File, target_specs: &RustcTargetSpecs
3129 ( os. contains ( "windows" ) && target != & * target_spec. llvm_target )
3230 . then_some ( ( & * * target, & * target_spec. llvm_target ) )
3331 } )
34- . collect :: < Vec < _ > > ( ) ;
35- windows_target_mapping. sort_unstable_by_key ( |( triple, _) | & * * triple) ;
36- windows_target_mapping. dedup ( ) ;
32+ . collect :: < BTreeMap < _ , _ > > ( ) ;
3733 write_target_tuple_mapping ( f, "WINDOWS_TRIPLE_MAPPING" , & windows_target_mapping) ;
3834}
3935
0 commit comments