https://github.com/JawsKim created https://github.com/llvm/llvm-project/pull/211749
`-fsanitize-kcfi-arity` was still processed after KCFI had been disabled with `-fno-sanitize=kcfi`. This change only processes `-fsanitize-kcfi-arity` when KCFI remains enabled in the final sanitizer set, avoiding both the unsupported target diagnostic and forwarding the option to cc1. Adds a regression test for this case. >From a3047231ec709d7bf4f7ae69e77d32c51b2a73b0 Mon Sep 17 00:00:00 2001 From: Jinseok Kim <[email protected]> Date: Fri, 24 Jul 2026 16:45:44 +0900 Subject: [PATCH] [Clang][Driver] Ignore -fsanitize-kcfi-arity when KCFI is disabled Signed-off-by: Jinseok Kim <[email protected]> --- clang/lib/Driver/SanitizerArgs.cpp | 2 +- clang/test/Driver/fsanitize-cfi.c | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/lib/Driver/SanitizerArgs.cpp b/clang/lib/Driver/SanitizerArgs.cpp index c77ba78122a81..7bbb3c985b185 100644 --- a/clang/lib/Driver/SanitizerArgs.cpp +++ b/clang/lib/Driver/SanitizerArgs.cpp @@ -1565,7 +1565,7 @@ void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args, if (CfiICallNormalizeIntegers) CmdArgs.push_back("-fsanitize-cfi-icall-experimental-normalize-integers"); - if (KcfiArity) { + if (KcfiArity && Sanitizers.has(SanitizerKind::KCFI)) { if (!TC.getTriple().isOSLinux() || !TC.getTriple().isArch64Bit()) { TC.getDriver().Diag(clang::diag::err_drv_kcfi_arity_unsupported_target) << TC.getTriple().str(); diff --git a/clang/test/Driver/fsanitize-cfi.c b/clang/test/Driver/fsanitize-cfi.c index c58ad3b8c2f1c..a9d7809bb524a 100644 --- a/clang/test/Driver/fsanitize-cfi.c +++ b/clang/test/Driver/fsanitize-cfi.c @@ -96,3 +96,7 @@ // RUN: not %clang --target=x86_64-linux-gnu -fsanitize=kcfi,function %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-KCFI-FUNCTION // CHECK-KCFI-FUNCTION: error: invalid argument '-fsanitize=kcfi' not allowed with '-fsanitize=function' + +// RUN: %clang --target=i386-linux-gnu -c %s -### -fsanitize=address,kcfi -fno-sanitize=kcfi -fsanitize-kcfi-arity 2>&1 | FileCheck %s --check-prefix=CHECK-KCFI-ARITY-DISABLED --implicit-check-not=error: --implicit-check-not=-fsanitize-kcfi-arity + +// CHECK-KCFI-ARITY-DISABLED: "-cc1"{{.*}}"-fsanitize=address" _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
