[clang] [Clang][Sanitizers] Enable NSAN on Linux only (PR #96120)

Alexander Shaposhnikov via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 19 15:50:56 PDT 2024


https://github.com/alexander-shaposhnikov created https://github.com/llvm/llvm-project/pull/96120

Enable nsan on Linux only.
Adding support for X86_64 MacOS requires minimal efforts
(might need to copy some bits from other sanitizers (in compiler-rt)).
Currently the functionality has been tested on Linux only.


>From 35f34c7f5bb22cc5e0038f9ec7d07f568fb630c8 Mon Sep 17 00:00:00 2001
From: Alexander Shaposhnikov <ashaposhnikov at google.com>
Date: Wed, 19 Jun 2024 22:40:02 +0000
Subject: [PATCH] [Clang][Sanitizers] Enable NSAN on Linux only

---
 clang/lib/Driver/ToolChains/Darwin.cpp | 3 ---
 clang/test/Driver/fsanitize.c          | 4 ++--
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 64ab328a6d25f..ec509831bf60c 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -3474,9 +3474,6 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
     Res |= SanitizerKind::Thread;
   }
 
-  if (IsX86_64)
-    Res |= SanitizerKind::NumericalStability;
-
   return Res;
 }
 
diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index db14f6e195c64..aaea518aa634e 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -468,8 +468,8 @@
 // RUN: not %clang --target=mips-unknown-linux -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-MIPS-LINUX
 // CHECK-NSAN-MIPS-LINUX: error: unsupported option '-fsanitize=numerical' for target 'mips-unknown-linux'
 
-// RUN: %clang --target=x86_64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-X86-64-MACOS
-// CHECK-NSAN-X86-64-MACOS: "-fsanitize=numerical"
+// RUN: not %clang --target=x86_64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-X86-64-MACOS
+// CHECK-NSAN-X86-64-MACOS: error: unsupported option '-fsanitize=numerical' for target 'x86_64-apple-macos'
 
 // RUN: not %clang --target=arm64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-ARM64-MACOS
 // CHECK-NSAN-ARM64-MACOS: error: unsupported option '-fsanitize=numerical' for target 'arm64-apple-macos'



More information about the cfe-commits mailing list