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

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 16:33:22 UTC
The branch stable/13 has been updated by dim:

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

commit e881c55cdc08098dd988e907af750516b597a3c8
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-10-01 19:43:21 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-06 16:30:08 +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__");