diff options
| author | Arvind Mukund <armu30@gmail.com> | 2022-12-20 11:44:12 -0800 |
|---|---|---|
| committer | Arvind Mukund <armu30@gmail.com> | 2022-12-20 11:47:11 -0800 |
| commit | 5480ac540cdb88a1512334c5680ccf7cd76a38c8 (patch) | |
| tree | de482692c6cb734b2137b9aec029748e3133debb /compiler/rustc_codegen_llvm/src | |
| parent | 55c4164fffb8c4389727cff554dd77012c624087 (diff) | |
| download | rust-5480ac540cdb88a1512334c5680ccf7cd76a38c8.tar.gz rust-5480ac540cdb88a1512334c5680ccf7cd76a38c8.zip | |
Use `Error` behavior for LLVM versions prior to 15
CI fails when building with LLVM-13. This raises unknown behavior constant `8` from IRVerifier.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 9c7d3dabd6f..d9ccba07a34 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -280,29 +280,35 @@ pub unsafe fn create_module<'ll>( } if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection { + let behavior = if llvm_version >= (15, 0, 0) { + llvm::LLVMModFlagBehavior::Min + } else { + llvm::LLVMModFlagBehavior::Error + }; + if sess.target.arch == "aarch64" { llvm::LLVMRustAddModuleFlag( llmod, - llvm::LLVMModFlagBehavior::Min, + behavior, "branch-target-enforcement\0".as_ptr().cast(), bti.into(), ); llvm::LLVMRustAddModuleFlag( llmod, - llvm::LLVMModFlagBehavior::Min, + behavior, "sign-return-address\0".as_ptr().cast(), pac_ret.is_some().into(), ); let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A }); llvm::LLVMRustAddModuleFlag( llmod, - llvm::LLVMModFlagBehavior::Min, + behavior, "sign-return-address-all\0".as_ptr().cast(), pac_opts.leaf.into(), ); llvm::LLVMRustAddModuleFlag( llmod, - llvm::LLVMModFlagBehavior::Min, + behavior, "sign-return-address-with-bkey\0".as_ptr().cast(), u32::from(pac_opts.key == PAuthKey::B), ); |
