[clang] 39e3050 - [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (#109278)

via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 21 10:53:39 PDT 2024


Author: Rainer Orth
Date: 2024-09-21T19:53:35+02:00
New Revision: 39e30508a7f6ec5477b11611946a491af5ebdeda

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

LOG: [Driver][Sparc] Default to -mcpu=v9 for 32-bit Linux/sparc64 (#109278)

While working on supporting PR #109101 on Linux/sparc64, I was reminded
that `clang -m32` still defaults to generating V8 code, although the
64-bit kernel requires a V9 CPU.

This patch corrects that.

Tested on `sparc64-unknown-linux-gnu`, `x86_64-pc-linux-gnu`,
`sparcv9-sun-solaris2.11`, and `amd64-pc-solaris2.11`.

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Driver/ToolChains/Arch/Sparc.cpp
    clang/test/Preprocessor/predefined-arch-macros.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f4535db7356194..97b79e6c5ca928 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -39,6 +39,11 @@ code bases.
 
 - The ``le32`` and ``le64`` targets have been removed.
 
+- ``clang -m32`` defaults to ``-mcpu=v9`` on SPARC Linux now.  Distros
+  still supporting SPARC V8 CPUs need to specify ``-mcpu=v8`` with a
+  `config file
+  <https://clang.llvm.org/docs/UsersManual.html#configuration-files>`_.
+  
 - The ``clang-rename`` tool has been removed.
 
 C/C++ Language Potentially Breaking Changes

diff  --git a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index f7f0a265fef68b..55fbc8b30698b9 100644
--- a/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -125,7 +125,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
     return std::string(CPUName);
   }
 
-  if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
+  if (Triple.getArch() == llvm::Triple::sparc &&
+      (Triple.isOSSolaris() || Triple.isOSLinux()))
     return "v9";
   return "";
 }

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c b/clang/test/Preprocessor/predefined-arch-macros.c
index a149c69ee0cdb2..35801e758cc58a 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4137,7 +4137,8 @@
 // CHECK_SPARC: #define __sparc__ 1
 // CHECK_SPARC-NOT: #define __sparcv9 1
 // CHECK_SPARC-NOT: #define __sparcv9__ 1
-// CHECK_SPARC: #define __sparcv8 1
+// CHECK_SPARC: #define __sparc_v9__ 1
+// CHECK_SPARC-NOT: #define __sparcv8 1
 // CHECK_SPARC-NOT: #define __sparcv9 1
 // CHECK_SPARC-NOT: #define __sparcv9__ 1
 


        


More information about the cfe-commits mailing list