@@ -559,6 +559,11 @@ fn link_staticlib<'a>(
559
559
archive_builder_builder
560
560
. extract_bundled_libs ( path, tempdir. as_ref ( ) , & relevant_libs)
561
561
. 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 ( ) ;
562
567
for filename in relevant_libs {
563
568
let joined = tempdir. as_ref ( ) . join ( filename. as_str ( ) ) ;
564
569
let path = joined. as_path ( ) ;
@@ -2172,14 +2177,19 @@ fn linker_with_args<'a>(
2172
2177
. iter ( )
2173
2178
. find ( |( ty, _) | * ty == crate_type)
2174
2179
. 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
2176
2184
. crate_info
2177
2185
. native_libraries
2178
2186
. iter ( )
2179
2187
. filter_map ( |( cnum, libraries) | {
2180
2188
( dependency_linkage[ cnum. as_usize ( ) - 1 ] != Linkage :: Static ) . then_some ( libraries)
2181
2189
} )
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 ( ) ) ) ;
2183
2193
for ( raw_dylib_name, raw_dylib_imports) in
2184
2194
collate_raw_dylibs ( sess, native_libraries_from_nonstatics) ?
2185
2195
{
0 commit comments