Skip to content

Commit acb414d

Browse files
committed
Only write metadata module when necessary
1 parent 1dde96a commit acb414d

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/lib.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
194194
&self,
195195
tcx: TyCtxt<'a, 'tcx, 'tcx>,
196196
metadata: EncodedMetadata,
197-
_need_metadata_module: bool,
197+
need_metadata_module: bool,
198198
_rx: mpsc::Receiver<Box<dyn Any + Send>>,
199199
) -> Box<dyn Any> {
200200
env_logger::init();
@@ -323,7 +323,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
323323
rustc_incremental::save_dep_graph(tcx);
324324
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));
325325

326-
let metadata_module = {
326+
let metadata_module = if need_metadata_module {
327327
use rustc::mir::mono::CodegenUnitNameBuilder;
328328

329329
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
@@ -342,13 +342,15 @@ impl CodegenBackend for CraneliftCodegenBackend {
342342
let obj = metadata_artifact.emit().unwrap();
343343
std::fs::write(&tmp_file, obj).unwrap();
344344

345-
CompiledModule {
345+
Some(CompiledModule {
346346
name: metadata_cgu_name,
347347
kind: ModuleKind::Metadata,
348348
object: Some(tmp_file),
349349
bytecode: None,
350350
bytecode_compressed: None,
351-
}
351+
})
352+
} else {
353+
None
352354
};
353355

354356
return Box::new(CodegenResults {
@@ -369,7 +371,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
369371
} else {
370372
None
371373
},
372-
metadata_module: Some(metadata_module),
374+
metadata_module,
373375
crate_hash: tcx.crate_hash(LOCAL_CRATE),
374376
metadata,
375377
windows_subsystem: None, // Windows is not yet supported

0 commit comments

Comments
 (0)