Move error on -Cinstrument-coverage earlier and elaborate that it is LLVM specific

cc rust-lang/rustc_codegen_cranelift#1494
This commit is contained in:
bjorn3 2024-06-04 16:02:36 +02:00
parent 8f1d41e2a0
commit eb449c1339

View File

@ -172,7 +172,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
} }
fn init(&self, sess: &Session) { fn init(&self, sess: &Session) {
use rustc_session::config::Lto; use rustc_session::config::{InstrumentCoverage, Lto};
match sess.lto() { match sess.lto() {
Lto::No | Lto::ThinLocal => {} Lto::No | Lto::ThinLocal => {}
Lto::Thin | Lto::Fat => { Lto::Thin | Lto::Fat => {
@ -180,6 +180,11 @@ impl CodegenBackend for CraneliftCodegenBackend {
} }
} }
if sess.opts.cg.instrument_coverage() != InstrumentCoverage::No {
sess.dcx()
.fatal("`-Cinstrument-coverage` is LLVM specific and not supported by Cranelift");
}
let mut config = self.config.borrow_mut(); let mut config = self.config.borrow_mut();
if config.is_none() { if config.is_none() {
let new_config = BackendConfig::from_opts(&sess.opts.cg.llvm_args) let new_config = BackendConfig::from_opts(&sess.opts.cg.llvm_args)