r367351 - [Driver] Support -fsanitize=function on Solaris/x86

Rainer Orth via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 30 13:04:53 PDT 2019


Author: ro
Date: Tue Jul 30 13:04:53 2019
New Revision: 367351

URL: http://llvm.org/viewvc/llvm-project?rev=367351&view=rev
Log:
[Driver] Support -fsanitize=function on Solaris/x86

UBSan-Standalone-x86_64 :: TestCases/TypeCheck/Function/function.cpp currently
FAILs on Solaris/x86_64:

  clang-9: error: unsupported option '-fsanitize=function' for target 'x86_64-pc-solaris2.11'

AFAICS, there's nothing more to do then enable that sanitizer in the driver (for x86 only),
which is what this patch does, together with updating another testcase.

Tested on x86_64-pc-solaris2.11.

Differential Revision: https://reviews.llvm.org/D64488

Modified:
    cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
    cfe/trunk/test/Driver/fsanitize.c

Modified: cfe/trunk/lib/Driver/ToolChains/Solaris.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Solaris.cpp?rev=367351&r1=367350&r2=367351&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Solaris.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Solaris.cpp Tue Jul 30 13:04:53 2019
@@ -177,6 +177,7 @@ Solaris::Solaris(const Driver &D, const
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 until 64-bit support is figured out.
   if (IsX86) {
@@ -184,6 +185,8 @@ SanitizerMask Solaris::getSupportedSanit
     Res |= SanitizerKind::PointerCompare;
     Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+    Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }

Modified: cfe/trunk/test/Driver/fsanitize.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/fsanitize.c?rev=367351&r1=367350&r2=367351&view=diff
==============================================================================
--- cfe/trunk/test/Driver/fsanitize.c (original)
+++ cfe/trunk/test/Driver/fsanitize.c Tue Jul 30 13:04:53 2019
@@ -727,6 +727,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target i386--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FSAN-UBSAN-PS4




More information about the cfe-commits mailing list