Skip to content

Commit 73d374f

Browse files
committed
bug! if branch-protection makes it to non-AArch64 codegen.
1 parent f4d51b8 commit 73d374f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,8 @@ pub unsafe fn create_module<'ll>(
274274
}
275275
}
276276

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

0 commit comments

Comments
 (0)