diff options
| author | bors <bors@rust-lang.org> | 2022-12-17 12:10:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-17 12:10:27 +0000 |
| commit | aef17b7ae6160352e2814c8686f7e4b2ee04d9e4 (patch) | |
| tree | 4d8e4467ec0b26ecdf43aed5c3d81b7c6415d7d5 /compiler/rustc_codegen_llvm/src | |
| parent | 49c2279ef658d8732597c4da93897d84838f3df5 (diff) | |
| parent | 73d374f3e7d5fe9635a23937cdc2f7e1d1c29224 (diff) | |
| download | rust-aef17b7ae6160352e2814c8686f7e4b2ee04d9e4.tar.gz rust-aef17b7ae6160352e2814c8686f7e4b2ee04d9e4.zip | |
Auto merge of #105421 - jacobbramley:jb/branch-prot-check, r=nagisa
Check AArch64 branch-protection earlier in the pipeline. As suggested in #93516. r? `@nagisa`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/errors.rs | 4 |
2 files changed, 6 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index aa1735f38ac..f3bff5d5716 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -3,7 +3,6 @@ use crate::back::write::to_llvm_code_model; use crate::callee::get_fn; use crate::coverageinfo; use crate::debuginfo; -use crate::errors::BranchProtectionRequiresAArch64; use crate::llvm; use crate::llvm_util; use crate::type_::Type; @@ -281,9 +280,7 @@ pub unsafe fn create_module<'ll>( } if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection { - if sess.target.arch != "aarch64" { - sess.emit_err(BranchProtectionRequiresAArch64); - } else { + if sess.target.arch == "aarch64" { llvm::LLVMRustAddModuleFlag( llmod, llvm::LLVMModFlagBehavior::Error, @@ -309,6 +306,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." + ); } } diff --git a/compiler/rustc_codegen_llvm/src/errors.rs b/compiler/rustc_codegen_llvm/src/errors.rs index af9f31fc324..b4620997242 100644 --- a/compiler/rustc_codegen_llvm/src/errors.rs +++ b/compiler/rustc_codegen_llvm/src/errors.rs @@ -52,10 +52,6 @@ pub(crate) struct SymbolAlreadyDefined<'a> { } #[derive(Diagnostic)] -#[diag(codegen_llvm_branch_protection_requires_aarch64)] -pub(crate) struct BranchProtectionRequiresAArch64; - -#[derive(Diagnostic)] #[diag(codegen_llvm_invalid_minimum_alignment)] pub(crate) struct InvalidMinimumAlignment { pub err: String, |
