diff --git a/src/lib.rs b/src/lib.rs index bb7ff63b0a6..c7b328b5d88 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -237,13 +237,6 @@ impl CodegenBackend for CraneliftCodegenBackend { module }; - let mut faerie_module = new_module("some_file".to_string()); - - codegen_cgus(tcx, &mut faerie_module, &mut log); - crate::allocator::codegen(tcx.sess, &mut faerie_module); - - tcx.sess.abort_if_errors(); - let emit_module = |name: &str, kind: ModuleKind, mut module: Module| { module.finalize_definitions(); let artifact = module.finish().artifact; @@ -262,6 +255,13 @@ impl CodegenBackend for CraneliftCodegenBackend { } }; + let mut faerie_module = new_module("some_file".to_string()); + + codegen_cgus(tcx, &mut faerie_module, &mut log); + crate::allocator::codegen(tcx.sess, &mut faerie_module); + + tcx.sess.abort_if_errors(); + return Box::new(CodegenResults { crate_name: tcx.crate_name(LOCAL_CRATE), modules: vec![emit_module("dummy_name", ModuleKind::Regular, faerie_module)],