@@ -842,18 +842,31 @@ pub fn run_passes(sess: &Session,
842
842
//if sess.time_llvm_passes() { llvm::LLVMRustPrintPassTimings(); }
843
843
}
844
844
845
- type WorkItem = proc ( & CodegenContext ) : Send ;
845
+ struct WorkItem {
846
+ mtrans : ModuleTranslation ,
847
+ config : ModuleConfig ,
848
+ output_names : OutputFilenames ,
849
+ name_extra : String
850
+ }
846
851
847
852
fn build_work_item ( sess : & Session ,
848
853
mtrans : ModuleTranslation ,
849
854
config : ModuleConfig ,
850
855
output_names : OutputFilenames ,
851
- name_extra : String ) -> WorkItem {
856
+ name_extra : String )
857
+ -> WorkItem
858
+ {
852
859
let mut config = config;
853
860
config. tm = create_target_machine ( sess) ;
861
+ WorkItem { mtrans : mtrans, config : config, output_names : output_names,
862
+ name_extra : name_extra }
863
+ }
854
864
855
- proc ( cgcx) unsafe {
856
- optimize_and_codegen ( cgcx, mtrans, config, name_extra, output_names) ;
865
+ fn execute_work_item ( cgcx : & CodegenContext ,
866
+ work_item : WorkItem ) {
867
+ unsafe {
868
+ optimize_and_codegen ( cgcx, work_item. mtrans , work_item. config ,
869
+ work_item. name_extra , work_item. output_names ) ;
857
870
}
858
871
}
859
872
@@ -866,7 +879,7 @@ fn run_work_singlethreaded(sess: &Session,
866
879
// Since we're running single-threaded, we can pass the session to
867
880
// the proc, allowing `optimize_and_codegen` to perform LTO.
868
881
for work in Unfold :: new ( ( ) , |_| work_items. pop ( ) ) {
869
- work ( & cgcx) ;
882
+ execute_work_item ( & cgcx, work ) ;
870
883
}
871
884
}
872
885
@@ -883,7 +896,7 @@ fn run_work_multithreaded(sess: &Session,
883
896
let diag_emitter = diag_emitter. clone ( ) ;
884
897
let remark = sess. opts . cg . remark . clone ( ) ;
885
898
886
- let future = TaskBuilder :: new ( ) . named ( format ! ( "codegen-{}" , i) ) . try_future ( proc ( ) {
899
+ let future = TaskBuilder :: new ( ) . named ( format ! ( "codegen-{}" , i) ) . try_future ( move | : | {
887
900
let diag_handler = mk_handler ( box diag_emitter) ;
888
901
889
902
// Must construct cgcx inside the proc because it has non-Send
@@ -899,7 +912,7 @@ fn run_work_multithreaded(sess: &Session,
899
912
let maybe_work = work_items_arc. lock ( ) . pop ( ) ;
900
913
match maybe_work {
901
914
Some ( work) => {
902
- work ( & cgcx) ;
915
+ execute_work_item ( & cgcx, work ) ;
903
916
904
917
// Make sure to fail the worker so the main thread can
905
918
// tell that there were errors.
0 commit comments