Skip to content

Commit

Permalink
[PPC] Undefine __ppc64__ to match GCC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
MaskRay committed Nov 23, 2022
1 parent 169f055 commit 987b493
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Basic/Targets/PPC.cpp
Expand Up @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions clang/test/Preprocessor/init-ppc64.c
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 987b493

Please sign in to comment.