@@ -559,6 +559,11 @@ fn link_staticlib<'a>(
559559 archive_builder_builder
560560 . extract_bundled_libs ( path, tempdir. as_ref ( ) , & relevant_libs)
561561 . unwrap_or_else ( |e| sess. dcx ( ) . emit_fatal ( e) ) ;
562+
563+ // We sort the libraries below
564+ #[ allow( rustc:: potential_query_instability) ]
565+ let mut relevant_libs: Vec < Symbol > = relevant_libs. into_iter ( ) . collect ( ) ;
566+ relevant_libs. sort_unstable ( ) ;
562567 for filename in relevant_libs {
563568 let joined = tempdir. as_ref ( ) . join ( filename. as_str ( ) ) ;
564569 let path = joined. as_path ( ) ;
@@ -2172,14 +2177,19 @@ fn linker_with_args<'a>(
21722177 . iter ( )
21732178 . find ( |( ty, _) | * ty == crate_type)
21742179 . expect ( "failed to find crate type in dependency format list" ) ;
2175- let native_libraries_from_nonstatics = codegen_results
2180+
2181+ // We sort the libraries below
2182+ #[ allow( rustc:: potential_query_instability) ]
2183+ let mut native_libraries_from_nonstatics = codegen_results
21762184 . crate_info
21772185 . native_libraries
21782186 . iter ( )
21792187 . filter_map ( |( cnum, libraries) | {
21802188 ( dependency_linkage[ cnum. as_usize ( ) - 1 ] != Linkage :: Static ) . then_some ( libraries)
21812189 } )
2182- . flatten ( ) ;
2190+ . flatten ( )
2191+ . collect :: < Vec < _ > > ( ) ;
2192+ native_libraries_from_nonstatics. sort_unstable_by ( |a, b| a. name . as_str ( ) . cmp ( b. name . as_str ( ) ) ) ;
21832193 for ( raw_dylib_name, raw_dylib_imports) in
21842194 collate_raw_dylibs ( sess, native_libraries_from_nonstatics) ?
21852195 {
0 commit comments