[clang] d01e336 - [Driver] Enable ASan on Solaris/SPARC (#107403)

via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 25 09:15:49 PDT 2024


Author: Rainer Orth
Date: 2024-09-25T18:15:45+02:00
New Revision: d01e336336f2b7fb4137e3dcc7d5c0b06ca1f3d6

URL: https://github.com/llvm/llvm-project/commit/d01e336336f2b7fb4137e3dcc7d5c0b06ca1f3d6
DIFF: https://github.com/llvm/llvm-project/commit/d01e336336f2b7fb4137e3dcc7d5c0b06ca1f3d6.diff

LOG: [Driver] Enable ASan on Solaris/SPARC (#107403)

Once PR #107223 lands, ASan can be enabled on Solaris/SPARC. This patch
does just that. As on Solaris/x86, the dynamic ASan runtime lib needs to
be linked with `-z now` to avoid an `AsanInitInternal` cycle.

Tested on `sparcv9-sun-solaris2.11` and `sparc64-unknown-linux-gnu`.

Added: 
    

Modified: 
    clang/lib/Driver/ToolChains/Solaris.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index cf39038dcac37c..fd3232b7c1b06f 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -266,8 +266,7 @@ void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA,
       }
     }
     // Avoid AsanInitInternal cycle, Issue #64126.
-    if (ToolChain.getTriple().isX86() && SA.needsSharedRt() &&
-        SA.needsAsanRt()) {
+    if (SA.needsSharedRt() && SA.needsAsanRt()) {
       CmdArgs.push_back("-z");
       CmdArgs.push_back("now");
     }
@@ -334,10 +333,11 @@ Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
 }
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
+  const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
-  // FIXME: Omit X86_64 until 64-bit support is figured out.
-  if (IsX86) {
+  // FIXME: Omit SparcV9 and X86_64 until 64-bit support is figured out.
+  if (IsSparc || IsX86) {
     Res |= SanitizerKind::Address;
     Res |= SanitizerKind::PointerCompare;
     Res |= SanitizerKind::PointerSubtract;


        


More information about the cfe-commits mailing list