Skip to content

Commit 59b8aed

Browse files
committed
Port branch protection on aarch64
1 parent ec1e101 commit 59b8aed

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::back::write::to_llvm_code_model;
33
use crate::callee::get_fn;
44
use crate::coverageinfo;
55
use crate::debuginfo;
6+
use crate::errors::BranchProtectionRequiresAArch64;
67
use crate::llvm;
78
use crate::llvm_util;
89
use crate::type_::Type;
@@ -275,7 +276,7 @@ pub unsafe fn create_module<'ll>(
275276

276277
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
277278
if sess.target.arch != "aarch64" {
278-
sess.err("-Zbranch-protection is only supported on aarch64");
279+
sess.emit_err(BranchProtectionRequiresAArch64);
279280
} else {
280281
llvm::LLVMRustAddModuleFlag(
281282
llmod,

compiler/rustc_codegen_llvm/src/errors.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ pub(crate) struct SymbolAlreadyDefined<'a> {
5555
pub span: Span,
5656
pub symbol_name: &'a str,
5757
}
58+
59+
#[derive(SessionDiagnostic)]
60+
#[diag(codegen_llvm::branch_protection_requires_aarch64)]
61+
pub(crate) struct BranchProtectionRequiresAArch64;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ codegen_llvm_instrument_coverage_requires_llvm_12 =
2121
2222
codegen_llvm_symbol_already_defined =
2323
symbol `{$symbol_name}` is already defined
24+
25+
codegen_llvm_branch_protection_requires_aarch64 =
26+
-Zbranch-protection is only supported on aarch64

0 commit comments

Comments
 (0)