about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/context.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-04-05 09:25:41 +0000
committerbors <bors@rust-lang.org>2025-04-05 09:25:41 +0000
commit0e9c3e52e492c9edacae96feb8deeb1695731273 (patch)
tree0a0a1f1434db516910192532d884807c82671805 /compiler/rustc_codegen_llvm/src/context.rs
parentda8321773a5c3306e1ff159cf0560c9f89f016b9 (diff)
parent0823b34bfb8321ee622b8cd51da1c453b95616c7 (diff)
downloadrust-0e9c3e52e492c9edacae96feb8deeb1695731273.tar.gz
rust-0e9c3e52e492c9edacae96feb8deeb1695731273.zip
Auto merge of #139401 - matthiaskrgr:rollup-uqdfj6u, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - #138368 (KCFI: Add KCFI arity indicator support)
 - #138381 (Implement `SliceIndex` for `ByteStr`)
 - #139092 (Move `fd` into `std::sys`)
 - #139398 (Change notifications for Exploit Mitigations PG)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/context.rs16
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.