diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-04-05 10:18:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-05 10:18:03 +0200 |
| commit | 543160dd62f4d435d85bc0b4160dad4ac8659992 (patch) | |
| tree | 877098f3f22be514bb211e9dbe60d30f76fca2a9 /compiler/rustc_codegen_llvm/src/context.rs | |
| parent | 1e008dd5d83e782ad37fc9cf6824733f824cc8cd (diff) | |
| parent | a98546b961a7fc707155aecbde094fbcecce81fd (diff) | |
| download | rust-543160dd62f4d435d85bc0b4160dad4ac8659992.tar.gz rust-543160dd62f4d435d85bc0b4160dad4ac8659992.zip | |
Rollup merge of #138368 - rcvalle:rust-kcfi-arity, r=davidtwco
KCFI: Add KCFI arity indicator support Adds KCFI arity indicator support to the Rust compiler (see https://github.com/rust-lang/rust/issues/138311, https://github.com/llvm/llvm-project/pull/121070, and https://lore.kernel.org/lkml/CANiq72=3ghFxy8E=AU9p+0imFxKr5iU3sd0hVUXed5BA+KjdNQ@mail.gmail.com/).
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 3be8cd5f6ac..1e8861116e2 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -328,6 +328,22 @@ pub(crate) unsafe fn create_module<'ll>( pfe.prefix().into(), ); } + + // Add "kcfi-arity" module flag if KCFI arity indicator is enabled. (See + // https://github.com/llvm/llvm-project/pull/117121.) + if sess.is_sanitizer_kcfi_arity_enabled() { + // KCFI arity indicator requires LLVM 21.0.0 or later. + if llvm_version < (21, 0, 0) { + tcx.dcx().emit_err(crate::errors::SanitizerKcfiArityRequiresLLVM2100); + } + + llvm::add_module_flag_u32( + llmod, + llvm::ModuleFlagMergeBehavior::Override, + "kcfi-arity", + 1, + ); + } } // Control Flow Guard is currently only supported by MSVC and LLVM on Windows. |
