Skip to content

Commit 55c4164

Browse files
committed
Correct ModFlagBehavior for Aarch64 on LLVM-15
When building with Fat LTO and BTI enabled on aarch64, the BTI is set to `Module::Min` for alloc shim but is set to `Module::Error` for the crate. This was fine when we were using LLVM-14 but LLVM-15 changes it's behaviour to support for compiling with different `mbranch-protection` flags. Refer: rust-lang/llvm-project@b0343a3
1 parent 696563e commit 55c4164

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,26 +283,26 @@ pub unsafe fn create_module<'ll>(
283283
if sess.target.arch == "aarch64" {
284284
llvm::LLVMRustAddModuleFlag(
285285
llmod,
286-
llvm::LLVMModFlagBehavior::Error,
286+
llvm::LLVMModFlagBehavior::Min,
287287
"branch-target-enforcement\0".as_ptr().cast(),
288288
bti.into(),
289289
);
290290
llvm::LLVMRustAddModuleFlag(
291291
llmod,
292-
llvm::LLVMModFlagBehavior::Error,
292+
llvm::LLVMModFlagBehavior::Min,
293293
"sign-return-address\0".as_ptr().cast(),
294294
pac_ret.is_some().into(),
295295
);
296296
let pac_opts = pac_ret.unwrap_or(PacRet { leaf: false, key: PAuthKey::A });
297297
llvm::LLVMRustAddModuleFlag(
298298
llmod,
299-
llvm::LLVMModFlagBehavior::Error,
299+
llvm::LLVMModFlagBehavior::Min,
300300
"sign-return-address-all\0".as_ptr().cast(),
301301
pac_opts.leaf.into(),
302302
);
303303
llvm::LLVMRustAddModuleFlag(
304304
llmod,
305-
llvm::LLVMModFlagBehavior::Error,
305+
llvm::LLVMModFlagBehavior::Min,
306306
"sign-return-address-with-bkey\0".as_ptr().cast(),
307307
u32::from(pac_opts.key == PAuthKey::B),
308308
);

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ pub enum LLVMModFlagBehavior {
7979
Append = 5,
8080
AppendUnique = 6,
8181
Max = 7,
82+
Min = 8,
8283
}
8384

8485
// Consts for the LLVM CallConv type, pre-cast to usize.

0 commit comments

Comments
 (0)