@@ -755,6 +755,15 @@ pub enum FatLTOInput<B: WriteBackendMethods> {
755
755
InMemory ( ModuleCodegen < B :: Module > ) ,
756
756
}
757
757
758
+ impl < B : WriteBackendMethods > FatLTOInput < B > {
759
+ fn name ( & ' a self ) -> & ' a String {
760
+ match self {
761
+ FatLTOInput :: Serialized { name, buffer : _ } => & name,
762
+ FatLTOInput :: InMemory ( module) => & module. name ,
763
+ }
764
+ }
765
+ }
766
+
758
767
fn execute_work_item < B : ExtraBackendMethods > (
759
768
cgcx : & CodegenContext < B > ,
760
769
work_item : WorkItem < B > ,
@@ -1345,10 +1354,15 @@ fn start_executing_work<B: ExtraBackendMethods>(
1345
1354
assert ! ( !started_lto) ;
1346
1355
started_lto = true ;
1347
1356
1348
- let needs_fat_lto = mem:: take ( & mut needs_fat_lto) ;
1357
+ let mut needs_fat_lto: Vec < FatLTOInput < B > > = mem:: take ( & mut needs_fat_lto) ;
1349
1358
let needs_thin_lto = mem:: take ( & mut needs_thin_lto) ;
1350
1359
let import_only_modules = mem:: take ( & mut lto_import_only_modules) ;
1351
1360
1361
+ // Regardless of what order these modules completed in, report them to
1362
+ // the backend in the same order every time to ensure that we're handing
1363
+ // out deterministic results.
1364
+ needs_fat_lto. sort_by ( |m1, m2| m1. name ( ) . cmp ( m2. name ( ) ) ) ;
1365
+
1352
1366
for ( work, cost) in generate_lto_work ( & cgcx, needs_fat_lto,
1353
1367
needs_thin_lto, import_only_modules) {
1354
1368
let insertion_index = work_items
0 commit comments