diff --git a/src/driver.rs b/src/driver.rs index a9cf054e039a..391154f80c1c 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -98,7 +98,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option) -> fn run_aot<'a, 'tcx: 'a>( tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata: EncodedMetadata, - _need_metadata_module: bool, + need_metadata_module: bool, log: &mut Option, ) -> Box { let new_module = |name: String| { @@ -166,7 +166,7 @@ fn run_aot<'a, 'tcx: 'a>( rustc_incremental::save_dep_graph(tcx); rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE)); - let metadata_module = { + let metadata_module = if need_metadata_module { use rustc::mir::mono::CodegenUnitNameBuilder; let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx); @@ -186,13 +186,15 @@ fn run_aot<'a, 'tcx: 'a>( let obj = metadata_artifact.emit().unwrap(); std::fs::write(&tmp_file, obj).unwrap(); - CompiledModule { + Some(CompiledModule { name: metadata_cgu_name, kind: ModuleKind::Metadata, object: Some(tmp_file), bytecode: None, bytecode_compressed: None, - } + }) + } else { + None }; Box::new(CodegenResults { @@ -213,7 +215,7 @@ fn run_aot<'a, 'tcx: 'a>( } else { None }, - metadata_module: Some(metadata_module), + metadata_module, crate_hash: tcx.crate_hash(LOCAL_CRATE), metadata, windows_subsystem: None, // Windows is not yet supported