]> git.lizzy.rs Git - rust.git/commitdiff
Only write metadata module when necessary
authorbjorn3 <bjorn3@users.noreply.github.com>
Sat, 4 May 2019 13:26:26 +0000 (15:26 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Tue, 11 Jun 2019 14:45:14 +0000 (16:45 +0200)
src/driver.rs

index a9cf054e039ae15a6ede9ed62a24babd186baf76..391154f80c1cdb03918d7d74e90a93d5ed424a67 100644 (file)
@@ -98,7 +98,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option<File>) ->
 fn run_aot<'a, 'tcx: 'a>(
     tcx: TyCtxt<'a, 'tcx, 'tcx>,
     metadata: EncodedMetadata,
-    _need_metadata_module: bool,
+    need_metadata_module: bool,
     log: &mut Option<File>,
 ) -> Box<CodegenResults> {
     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