git: c0c181405379 - stable/12 - Stop clang 13 from defining conflicting macros on PowerPC

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 25 Dec 2021 11:56:24 UTC
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=c0c181405379add206c7db9e50bad4ed61cb549c

commit c0c181405379add206c7db9e50bad4ed61cb549c
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-10-01 19:43:21 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-25 11:51:38 +0000

    Stop clang 13 from defining conflicting macros on PowerPC
    
    Merge commit c9539f957f57 from llvm git (by Nemanja Ivanovic):
    
      [PowerPC] Define XL-compatible macros only for AIX and Linux
    
      Since XLC only ever shipped on PowerPC AIX and Linux, it is not
      reasonable to provide the compatibility macros on any target other
      than those two. This patch restricts those macros to AIX/Linux.
    
      Differential revision: https://reviews.llvm.org/D110213
    
    PR:             258209
    (cherry picked from commit 39dadd0628cd1f28be39a3ab35969545b7401623)
---
 contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
index 59656888e25f..ecfbe284fb2e 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/PPC.cpp
@@ -243,7 +243,10 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
 void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
                                      MacroBuilder &Builder) const {
 
-  defineXLCompatMacros(Builder);
+  // We define the XLC compatibility macros only on AIX and Linux since XLC
+  // was never available on any other platforms.
+  if (getTriple().isOSAIX() || getTriple().isOSLinux())
+    defineXLCompatMacros(Builder);
 
   // Target identification.
   Builder.defineMacro("__ppc__");