Port SanitizerMemtagRequiresMte

This commit is contained in:
SLASHLogin 2022-08-26 12:19:10 +02:00
parent 02403ee31d
commit 978b5f73e4
3 changed files with 9 additions and 1 deletions

View File

@ -12,6 +12,7 @@ use rustc_target::spec::{FramePointer, SanitizerSet, StackProbeType, StackProtec
use smallvec::SmallVec;
use crate::attributes;
use crate::errors::SanitizerMemtagRequiresMte;
use crate::llvm::AttributePlace::Function;
use crate::llvm::{self, AllocKindFlags, Attribute, AttributeKind, AttributePlace, MemoryEffects};
use crate::llvm_util;
@ -82,7 +83,7 @@ pub fn sanitize_attrs<'ll>(
let mte_feature =
features.iter().map(|s| &s[..]).rfind(|n| ["+mte", "-mte"].contains(&&n[..]));
if let None | Some("-mte") = mte_feature {
cx.tcx.sess.err("`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`");
cx.tcx.sess.emit_err(SanitizerMemtagRequiresMte);
}
attrs.push(llvm::AttributeKind::SanitizeMemTag.create_attr(cx.llcx));

View File

@ -80,3 +80,7 @@ pub(crate) struct LinkageConstOrMutType {
#[primary_span]
pub span: Span,
}
#[derive(SessionDiagnostic)]
#[diag(codegen_llvm::sanitizer_memtag_requires_mte)]
pub(crate) struct SanitizerMemtagRequiresMte;

View File

@ -33,3 +33,6 @@ codegen_llvm_invalid_minimum_alignment =
codegen_llvm_linkage_const_or_mut_type =
must have type `*const T` or `*mut T` due to `#[linkage]` attribute
codegen_llvm_sanitizer_memtag_requires_mte =
`-Zsanitizer=memtag` requires `-Ctarget-feature=+mte`