From 8d4afbe4136933b47082dd1efa9c1132a31dfb0d Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Wed, 20 Feb 2019 22:27:00 +0200 Subject: Use informational target machine for metadata Since there is nothing to optimise there... --- src/librustc_codegen_ssa/back/write.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/librustc_codegen_ssa') diff --git a/src/librustc_codegen_ssa/back/write.rs b/src/librustc_codegen_ssa/back/write.rs index 859dfb99d92..55b7855ac08 100644 --- a/src/librustc_codegen_ssa/back/write.rs +++ b/src/librustc_codegen_ssa/back/write.rs @@ -1075,7 +1075,13 @@ fn start_executing_work( None }; - let ol = tcx.backend_optimization_level(LOCAL_CRATE); + let ol = if tcx.sess.opts.debugging_opts.no_codegen + || !tcx.sess.opts.output_types.should_codegen() { + // If we know that we won’t be doing codegen, create target machines without optimisation. + config::OptLevel::No + } else { + tcx.backend_optimization_level(LOCAL_CRATE) + }; let cgcx = CodegenContext:: { backend: backend.clone(), crate_types: sess.crate_types.borrow().clone(), -- cgit 1.4.1-3-g733a5