@@ -554,6 +554,11 @@ fn link_staticlib<'a>(
554554 archive_builder_builder
555555 . extract_bundled_libs ( path, tempdir. as_ref ( ) , & relevant_libs)
556556 . unwrap_or_else ( |e| sess. dcx ( ) . emit_fatal ( e) ) ;
557+
558+ // We sort the libraries below
559+ #[ allow( rustc:: potential_query_instability) ]
560+ let mut relevant_libs: Vec < Symbol > = relevant_libs. into_iter ( ) . collect ( ) ;
561+ relevant_libs. sort_unstable ( ) ;
557562 for filename in relevant_libs {
558563 let joined = tempdir. as_ref ( ) . join ( filename. as_str ( ) ) ;
559564 let path = joined. as_path ( ) ;
@@ -2201,14 +2206,19 @@ fn linker_with_args<'a>(
22012206 . iter ( )
22022207 . find ( |( ty, _) | * ty == crate_type)
22032208 . expect ( "failed to find crate type in dependency format list" ) ;
2204- let native_libraries_from_nonstatics = codegen_results
2209+
2210+ // We sort the libraries below
2211+ #[ allow( rustc:: potential_query_instability) ]
2212+ let mut native_libraries_from_nonstatics = codegen_results
22052213 . crate_info
22062214 . native_libraries
22072215 . iter ( )
22082216 . filter_map ( |( cnum, libraries) | {
22092217 ( dependency_linkage[ cnum. as_usize ( ) - 1 ] != Linkage :: Static ) . then_some ( libraries)
22102218 } )
2211- . flatten ( ) ;
2219+ . flatten ( )
2220+ . collect :: < Vec < _ > > ( ) ;
2221+ native_libraries_from_nonstatics. sort_unstable_by ( |a, b| a. name . as_str ( ) . cmp ( b. name . as_str ( ) ) ) ;
22122222 for ( raw_dylib_name, raw_dylib_imports) in
22132223 collate_raw_dylibs ( sess, native_libraries_from_nonstatics) ?
22142224 {
0 commit comments