This is an archive of the discontinued LLVM Phabricator instance.

[PPC] Undefine __ppc64__ to match GCC
ClosedPublic

Authored by MaskRay on Nov 6 2022, 4:02 PM.

Details

Summary

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.

Diff Detail

Event Timeline

MaskRay created this revision.Nov 6 2022, 4:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 4:02 PM
MaskRay requested review of this revision.Nov 6 2022, 4:02 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2022, 4:02 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
MaskRay edited the summary of this revision. (Show Details)Nov 6 2022, 4:03 PM
q66 added a comment.Nov 6 2022, 4:06 PM

The __ppc__ macro should get the same treatment. That said, I believe there are instances of both macros being used across the LLVM codebase, and those cases are valid, so that should also be updated (one instance i know of is the limits header of libcxx, there are likely more)

This needs to go in Breaking Changes in the release notes, not least so we can link to it when updating upstreams.

What do you mean by "while the darwin support has been removed from llvm-project."? I don't think that's the case, if you mean that LLVM.org's LLVM lacks support for Darwin.

MaskRay edited the summary of this revision. (Show Details)Nov 6 2022, 6:52 PM

This needs to go in Breaking Changes in the release notes, not least so we can link to it when updating upstreams.

What do you mean by "while the darwin support has been removed from llvm-project."? I don't think that's the case, if you mean that LLVM.org's LLVM lacks support for Darwin.

Clarified it to "The darwin ppc support has been removed from llvm-project."

The __ppc__ macro should get the same treatment. That said, I believe there are instances of both macros being used across the LLVM codebase, and those cases are valid, so that should also be updated (one instance i know of is the limits header of libcxx, there are likely more)

__ppc__ is defined for FreeBSD in GCC, so perhaps we can make a separate change making __ppc__ only defined for FreeBSD (@dim @Bdragon28 @jhibbits).

MaskRay updated this revision to Diff 473543.Nov 6 2022, 7:08 PM
MaskRay edited the summary of this revision. (Show Details)

update releasenote

As mentioned by @q66 above, this can't go in until usage of this macro in the Clang/LLVM codebase is fixed. Looks like the uses in clang/lib/Headers/ppc_wrappers and some of the uses in libcxx and libunwind must be fixed while others should probably also be fixed to avoid confusion.

nemanjai requested changes to this revision.Nov 6 2022, 7:25 PM

I am going to block this since the uses of the macros in clang/lib/Headers/ppc_wrappers will likely cause build bot failures.

This revision now requires changes to proceed.Nov 6 2022, 7:25 PM
qiucf added a subscriber: qiucf.Nov 6 2022, 9:17 PM

I am going to block this since the uses of the macros in clang/lib/Headers/ppc_wrappers will likely cause build bot failures.

clang/lib/Headers/ppc_wrappers was fixed yesterday. The only dependency is D137513 :)

thesamesam accepted this revision.Nov 7 2022, 5:46 PM

Hi @nemanjai , I think there is no relevant __ppc64__ in llvm-project now. (The libc++ change has landed and third_party/benchmark has a non-interesting use as that code has defined(__powerpc64__) as well).

nemanjai accepted this revision.Nov 22 2022, 4:57 PM

LGTM.
Thanks so much for fixing up the existing code.

This revision is now accepted and ready to land.Nov 22 2022, 4:57 PM
This revision was automatically updated to reflect the committed changes.