Skip to content

Commit

Permalink
bug! if branch-protection makes it to non-AArch64 codegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobbramley committed Dec 13, 2022
1 parent f4d51b8 commit 73d374f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,8 @@ pub unsafe fn create_module<'ll>(
}
}

// AArch64-only options (checked in rustc_session).
if sess.target.arch == "aarch64" {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch == "aarch64" {
llvm::LLVMRustAddModuleFlag(
llmod,
llvm::LLVMModFlagBehavior::Error,
Expand All @@ -302,6 +301,11 @@ pub unsafe fn create_module<'ll>(
"sign-return-address-with-bkey\0".as_ptr().cast(),
u32::from(pac_opts.key == PAuthKey::B),
);
} else {
bug!(
"branch-protection used on non-AArch64 target; \
this should be checked in rustc_session."
);
}
}

Expand Down

0 comments on commit 73d374f

Please sign in to comment.