Skip to content

Commit c638ba1

Browse files
[Clang][Sanitizers] Enable NSAN on X86_64 only (#95885)
This is a follow-up to #93783. The current set of patches covers only x86_64, therefore we should not enable this flag on arm64 yet.
1 parent f0a76d5 commit c638ba1

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3457,7 +3457,6 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
34573457
Res |= SanitizerKind::PointerCompare;
34583458
Res |= SanitizerKind::PointerSubtract;
34593459
Res |= SanitizerKind::Leak;
3460-
Res |= SanitizerKind::NumericalStability;
34613460
Res |= SanitizerKind::Fuzzer;
34623461
Res |= SanitizerKind::FuzzerNoLink;
34633462
Res |= SanitizerKind::ObjCCast;
@@ -3474,6 +3473,10 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
34743473
isTargetTvOSSimulator() || isTargetWatchOSSimulator())) {
34753474
Res |= SanitizerKind::Thread;
34763475
}
3476+
3477+
if (IsX86_64)
3478+
Res |= SanitizerKind::NumericalStability;
3479+
34773480
return Res;
34783481
}
34793482

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
826826
if (IsX86_64 || IsAArch64) {
827827
Res |= SanitizerKind::KernelHWAddress;
828828
}
829-
if (IsX86_64 || IsAArch64)
829+
if (IsX86_64)
830830
Res |= SanitizerKind::NumericalStability;
831831

832832
// Work around "Cannot represent a difference across sections".

clang/test/Driver/fsanitize.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,17 +462,17 @@
462462
// RUN: %clang --target=x86_64-linux-gnu -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-X86-64-LINUX
463463
// CHECK-NSAN-X86-64-LINUX: "-fsanitize=numerical"
464464

465-
// RUN: %clang --target=aarch64-unknown-linux-gnu -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-AARCH64-LINUX
466-
// CHECK-NSAN-AARCH64-LINUX: "-fsanitize=numerical"
465+
// RUN: not %clang --target=aarch64-unknown-linux-gnu -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-AARCH64-LINUX
466+
// CHECK-NSAN-AARCH64-LINUX: error: unsupported option '-fsanitize=numerical' for target 'aarch64-unknown-linux-gnu'
467467

468468
// RUN: not %clang --target=mips-unknown-linux -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-MIPS-LINUX
469469
// CHECK-NSAN-MIPS-LINUX: error: unsupported option '-fsanitize=numerical' for target 'mips-unknown-linux'
470470

471471
// RUN: %clang --target=x86_64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-X86-64-MACOS
472472
// CHECK-NSAN-X86-64-MACOS: "-fsanitize=numerical"
473473

474-
// RUN: %clang --target=arm64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-ARM64-MACOS
475-
// CHECK-NSAN-ARM64-MACOS: "-fsanitize=numerical"
474+
// RUN: not %clang --target=arm64-apple-macos -fsanitize=numerical %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NSAN-ARM64-MACOS
475+
// CHECK-NSAN-ARM64-MACOS: error: unsupported option '-fsanitize=numerical' for target 'arm64-apple-macos'
476476

477477
// RUN: %clang --target=x86_64-apple-darwin -fsanitize=thread %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-TSAN-X86-64-DARWIN
478478
// CHECK-TSAN-X86-64-DARWIN-NOT: unsupported option

0 commit comments

Comments
 (0)