Skip to content

Commit bf85e46

Browse files
committed
Only write metadata module when necessary
1 parent d2cd337 commit bf85e46

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
@@ -98,7 +98,7 @@ fn run_jit<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, log: &mut Option<File>) ->
9898
fn run_aot<'a, 'tcx: 'a>(
9999
tcx: TyCtxt<'a, 'tcx, 'tcx>,
100100
metadata: EncodedMetadata,
101-
_need_metadata_module: bool,
101+
need_metadata_module: bool,
102102
log: &mut Option<File>,
103103
) -> Box<CodegenResults> {
104104
let new_module = |name: String| {
@@ -166,7 +166,7 @@ fn run_aot<'a, 'tcx: 'a>(
166166
rustc_incremental::save_dep_graph(tcx);
167167
rustc_incremental::finalize_session_directory(tcx.sess, tcx.crate_hash(LOCAL_CRATE));
168168

169-
let metadata_module = {
169+
let metadata_module = if need_metadata_module {
170170
use rustc::mir::mono::CodegenUnitNameBuilder;
171171

172172
let cgu_name_builder = &mut CodegenUnitNameBuilder::new(tcx);
@@ -186,13 +186,15 @@ fn run_aot<'a, 'tcx: 'a>(
186186
let obj = metadata_artifact.emit().unwrap();
187187
std::fs::write(&tmp_file, obj).unwrap();
188188

189-
CompiledModule {
189+
Some(CompiledModule {
190190
name: metadata_cgu_name,
191191
kind: ModuleKind::Metadata,
192192
object: Some(tmp_file),
193193
bytecode: None,
194194
bytecode_compressed: None,
195-
}
195+
})
196+
} else {
197+
None
196198
};
197199

198200
Box::new(CodegenResults {
@@ -213,7 +215,7 @@ fn run_aot<'a, 'tcx: 'a>(
213215
} else {
214216
None
215217
},
216-
metadata_module: Some(metadata_module),
218+
metadata_module,
217219
crate_hash: tcx.crate_hash(LOCAL_CRATE),
218220
metadata,
219221
windows_subsystem: None, // Windows is not yet supported

0 commit comments

Comments
 (0)