@@ -554,6 +554,11 @@ fn link_staticlib<'a>(
554
554
archive_builder_builder
555
555
. extract_bundled_libs ( path, tempdir. as_ref ( ) , & relevant_libs)
556
556
. 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 ( ) ;
557
562
for filename in relevant_libs {
558
563
let joined = tempdir. as_ref ( ) . join ( filename. as_str ( ) ) ;
559
564
let path = joined. as_path ( ) ;
@@ -2201,14 +2206,19 @@ fn linker_with_args<'a>(
2201
2206
. iter ( )
2202
2207
. find ( |( ty, _) | * ty == crate_type)
2203
2208
. 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
2205
2213
. crate_info
2206
2214
. native_libraries
2207
2215
. iter ( )
2208
2216
. filter_map ( |( cnum, libraries) | {
2209
2217
( dependency_linkage[ cnum. as_usize ( ) - 1 ] != Linkage :: Static ) . then_some ( libraries)
2210
2218
} )
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 ( ) ) ) ;
2212
2222
for ( raw_dylib_name, raw_dylib_imports) in
2213
2223
collate_raw_dylibs ( sess, native_libraries_from_nonstatics) ?
2214
2224
{
0 commit comments