Skip to content

Commit 4c625dc

Browse files
committed
Port Instrument coverage requires llvm 12 to the new struct
1 parent 05ae7ec commit 4c625dc

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::common::CodegenCx;
22
use crate::coverageinfo;
3+
use crate::errors::InstrumentCoverageRequiresLLVM12;
34
use crate::llvm;
45

56
use llvm::coverageinfo::CounterMappingRegion;
@@ -37,7 +38,7 @@ pub fn finalize<'ll, 'tcx>(cx: &CodegenCx<'ll, 'tcx>) {
3738
// LLVM 12.
3839
let version = coverageinfo::mapping_version();
3940
if version < 4 {
40-
tcx.sess.fatal("rustc option `-C instrument-coverage` requires LLVM 12 or higher.");
41+
tcx.sess.emit_fatal(InstrumentCoverageRequiresLLVM12);
4142
}
4243

4344
debug!("Generating coverage map for CodegenUnit: `{}`", cx.codegen_unit.name());

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,7 @@ pub(crate) struct ErrorCreatingImportLibrary<'a> {
4242
pub lib_name: &'a str,
4343
pub error: String,
4444
}
45+
46+
#[derive(SessionDiagnostic)]
47+
#[diag(codegen_llvm::instrument_coverage_requires_llvm_12)]
48+
pub(crate) struct InstrumentCoverageRequiresLLVM12;

compiler/rustc_error_messages/locales/en-US/codegen_llvm.ftl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ codegen_llvm_unknown_feature_fill_request =
1515
1616
codegen_llvm_error_creating_import_library =
1717
Error creating import library for {$lib_name}: {$error}
18+
19+
codegen_llvm_instrument_coverage_requires_llvm_12 =
20+
rustc option `-C instrument-coverage` requires LLVM 12 or higher.

0 commit comments

Comments
 (0)