[PATCH] D98574: [Sparc] Define the same macros for -mcpu=v9 as GCC on Linux
John Paul Adrian Glaubitz via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Mar 13 00:52:06 PST 2021
glaubitz created this revision.
glaubitz added reviewers: jrtc27, ro, efriedma, brad, jfb, venkatra, jyknight.
Herald added a subscriber: fedor.sergeev.
glaubitz requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
When targeting SPARC V8+ or V9 on Linux, GCC only defines the macro
__sparc_v9__ while clang also defines additional macros such as
__sparcv9 that are used on Solaris and the BSDs only. Make sure,
clang behaves as GCC on Linux and defines __sparc_v9__ only to avoid
compatibility problems.
Fixes PR49562
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98574
Files:
clang/lib/Basic/Targets/Sparc.cpp
Index: clang/lib/Basic/Targets/Sparc.cpp
===================================================================
--- clang/lib/Basic/Targets/Sparc.cpp
+++ clang/lib/Basic/Targets/Sparc.cpp
@@ -156,9 +156,12 @@
Builder.defineMacro("__sparcv8__");
break;
case CG_V9:
- Builder.defineMacro("__sparcv9");
- Builder.defineMacro("__sparcv9__");
Builder.defineMacro("__sparc_v9__");
+ // Linux doesn't need these variants, but the BSDs do.
+ if (getTriple().getOS() != llvm::Triple::Linux) {
+ Builder.defineMacro("__sparcv9");
+ Builder.defineMacro("__sparcv9__");
+ }
break;
}
}
@@ -239,13 +242,17 @@
void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
MacroBuilder &Builder) const {
SparcTargetInfo::getTargetDefines(Opts, Builder);
- Builder.defineMacro("__sparcv9");
Builder.defineMacro("__arch64__");
- // Solaris doesn't need these variants, but the BSDs do.
- if (getTriple().getOS() != llvm::Triple::Solaris) {
- Builder.defineMacro("__sparc64__");
+ if (getTriple().getOS() == llvm::Triple::Linux) {
Builder.defineMacro("__sparc_v9__");
- Builder.defineMacro("__sparcv9__");
+ } else {
+ Builder.defineMacro("__sparcv9");
+ // Solaris doesn't need these variants, but the BSDs do.
+ if (getTriple().getOS() != llvm::Triple::Solaris) {
+ Builder.defineMacro("__sparc64__");
+ Builder.defineMacro("__sparc_v9__");
+ Builder.defineMacro("__sparcv9__");
+ }
}
Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98574.330429.patch
Type: text/x-patch
Size: 1608 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210313/3bbdc359/attachment.bin>
More information about the cfe-commits
mailing list