[clang] 987b493 - [PPC] Undefine __ppc64__ to match GCC

Fangrui Song via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 22 17:01:44 PST 2022


Author: Fangrui Song
Date: 2022-11-22T17:01:39-08:00
New Revision: 987b49395c604c794bee4439af4d3a47b4b58276

URL: https://github.com/llvm/llvm-project/commit/987b49395c604c794bee4439af4d3a47b4b58276
DIFF: https://github.com/llvm/llvm-project/commit/987b49395c604c794bee4439af4d3a47b4b58276.diff

LOG: [PPC] Undefine __ppc64__ to match GCC

GCC only defines `__ppc64__` for darwin while the darwin support has been
removed from llvm-project. The existence of `__ppc64__` makes some software
think we are compiling for big-endian PowerPC Mac; also it lures users to write
code which is not portable to GCC.

It is straightforward if a distro wants to keep the macro: add
`-D__ppc64__=1` to a Clang configuration file.

Reviewed By: thesamesam, nemanjai

Differential Revision: https://reviews.llvm.org/D137511

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/lib/Basic/Targets/PPC.cpp
    clang/test/Preprocessor/init-ppc64.c

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8c665bf3f8f4b..98c934b42a273 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -181,6 +181,9 @@ code bases.
   ``$prefix/lib/clang/$CLANG_MAJOR_VERSION`` and can be queried using
   ``clang -print-resource-dir``, just like before.
 
+- To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use
+  ``__powerpc64__`` instead.
+
 What's New in Clang |release|?
 ==============================
 Some of the major new features and improvements to Clang are listed

diff  --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index ca01b44ae3a5d..724fbc4f172ac 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -281,7 +281,6 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts,
   if (PointerWidth == 64) {
     Builder.defineMacro("_ARCH_PPC64");
     Builder.defineMacro("__powerpc64__");
-    Builder.defineMacro("__ppc64__");
     Builder.defineMacro("__PPC64__");
   } else if (getTriple().isOSAIX()) {
     // The XL compilers on AIX define _ARCH_PPC64 for both 32 and 64-bit modes.

diff  --git a/clang/test/Preprocessor/init-ppc64.c b/clang/test/Preprocessor/init-ppc64.c
index f0ccd1638c04d..42e5232824de7 100644
--- a/clang/test/Preprocessor/init-ppc64.c
+++ b/clang/test/Preprocessor/init-ppc64.c
@@ -198,7 +198,6 @@
 // PPC64:#define __WCHAR_WIDTH__ 32
 // PPC64:#define __WINT_TYPE__ int
 // PPC64:#define __WINT_WIDTH__ 32
-// PPC64:#define __ppc64__ 1
 // PPC64:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64le-none-none -target-cpu pwr7 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64LE %s
@@ -403,7 +402,6 @@
 // PPC64LE:#define __WCHAR_WIDTH__ 32
 // PPC64LE:#define __WINT_TYPE__ int
 // PPC64LE:#define __WINT_WIDTH__ 32
-// PPC64LE:#define __ppc64__ 1
 // PPC64LE:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-none-none -target-cpu 630 -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC630 %s
@@ -865,7 +863,6 @@
 // PPC64-AIX:#define __WINT_WIDTH__ 32
 // PPC64-AIX:#define __powerpc64__ 1
 // PPC64-AIX:#define __powerpc__ 1
-// PPC64-AIX:#define __ppc64__ 1
 // PPC64-AIX:#define __ppc__ 1
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=powerpc64-unknown-linux-gnu -fno-signed-char < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-LINUX %s
@@ -1064,7 +1061,6 @@
 // PPC64-LINUX:#define __WINT_WIDTH__ 32
 // PPC64-LINUX:#define __powerpc64__ 1
 // PPC64-LINUX:#define __powerpc__ 1
-// PPC64-LINUX:#define __ppc64__ 1
 // PPC64-LINUX:#define __ppc__ 1
 
 // RUN: %clang_cc1 -E -dM -ffreestanding -fgnuc-version=4.2.1 -triple=powerpc64-unknown-linux-gnu < /dev/null | FileCheck -match-full-lines -check-prefix PPC64-ELFv1 %s


        


More information about the cfe-commits mailing list