Skip to content

Commit d59234b

Browse files
committed
Only write metadata module when necessary
1 parent 0893602 commit d59234b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/driver.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::prelude::*;
1717
pub fn codegen_crate<'a, 'tcx>(
1818
tcx: TyCtxt<'a, 'tcx, 'tcx>,
1919
metadata: EncodedMetadata,
20-
_need_metadata_module: bool,
20+
need_metadata_module: bool,
2121
) -> Box<dyn Any> {
2222
env_logger::init();
2323
if !tcx.sess.crate_types.get().contains(&CrateType::Executable)
@@ -146,7 +146,7 @@ pub fn codegen_crate<'a, 'tcx>(
146146
rustc_incremental::save_dep_graph(tcx);
147147
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));
148148

149-
let metadata_module = {
149+
let metadata_module = if need_metadata_module {
150150
use rustc::mir::mono::CodegenUnitNameBuilder;
151151

152152
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
@@ -166,13 +166,15 @@ pub fn codegen_crate<'a, 'tcx>(
166166
let obj = metadata_artifact.emit().unwrap();
167167
std::fs::write(&tmp_file, obj).unwrap();
168168

169-
CompiledModule {
169+
Some(CompiledModule {
170170
name: metadata_cgu_name,
171171
kind: ModuleKind::Metadata,
172172
object: Some(tmp_file),
173173
bytecode: None,
174174
bytecode_compressed: None,
175-
}
175+
})
176+
} else {
177+
None
176178
};
177179

178180
Box::new(CodegenResults {
@@ -193,7 +195,7 @@ pub fn codegen_crate<'a, 'tcx>(
193195
} else {
194196
None
195197
},
196-
metadata_module: Some(metadata_module),
198+
metadata_module,
197199
crate_hash: tcx.crate_hash(LOCAL_CRATE),
198200
metadata,
199201
windows_subsystem: None, // Windows is not yet supported

0 commit comments

Comments
 (0)