Skip to content

Commit 39e3050

Browse files
authored
[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`.
1 parent 9b7a22e commit 39e3050

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

clang/docs/ReleaseNotes.rst

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ code bases.
3939

4040
- The ``le32`` and ``le64`` targets have been removed.
4141

42+
- ``clang -m32`` defaults to ``-mcpu=v9`` on SPARC Linux now. Distros
43+
still supporting SPARC V8 CPUs need to specify ``-mcpu=v8`` with a
44+
`config file
45+
<https://clang.llvm.org/docs/UsersManual.html#configuration-files>`_.
46+
4247
- The ``clang-rename`` tool has been removed.
4348

4449
C/C++ Language Potentially Breaking Changes

clang/lib/Driver/ToolChains/Arch/Sparc.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,8 @@ std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
125125
return std::string(CPUName);
126126
}
127127

128-
if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
128+
if (Triple.getArch() == llvm::Triple::sparc &&
129+
(Triple.isOSSolaris() || Triple.isOSLinux()))
129130
return "v9";
130131
return "";
131132
}

clang/test/Preprocessor/predefined-arch-macros.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -4137,7 +4137,8 @@
41374137
// CHECK_SPARC: #define __sparc__ 1
41384138
// CHECK_SPARC-NOT: #define __sparcv9 1
41394139
// CHECK_SPARC-NOT: #define __sparcv9__ 1
4140-
// CHECK_SPARC: #define __sparcv8 1
4140+
// CHECK_SPARC: #define __sparc_v9__ 1
4141+
// CHECK_SPARC-NOT: #define __sparcv8 1
41414142
// CHECK_SPARC-NOT: #define __sparcv9 1
41424143
// CHECK_SPARC-NOT: #define __sparcv9__ 1
41434144

0 commit comments

Comments
 (0)