@@ -755,6 +755,15 @@ pub enum FatLTOInput<B: WriteBackendMethods> {
755755 InMemory ( ModuleCodegen < B :: Module > ) ,
756756}
757757
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+
758767fn execute_work_item < B : ExtraBackendMethods > (
759768 cgcx : & CodegenContext < B > ,
760769 work_item : WorkItem < B > ,
@@ -1345,10 +1354,15 @@ fn start_executing_work<B: ExtraBackendMethods>(
13451354 assert ! ( !started_lto) ;
13461355 started_lto = true ;
13471356
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) ;
13491358 let needs_thin_lto = mem:: take ( & mut needs_thin_lto) ;
13501359 let import_only_modules = mem:: take ( & mut lto_import_only_modules) ;
13511360
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+
13521366 for ( work, cost) in generate_lto_work ( & cgcx, needs_fat_lto,
13531367 needs_thin_lto, import_only_modules) {
13541368 let insertion_index = work_items
0 commit comments