This is an archive of the discontinued LLVM Phabricator instance.

[libunwind] build fix for GCC on PPC32
ClosedPublic

Authored by thesamesam on Jan 26 2022, 11:36 PM.

Details

Reviewers
MaskRay
mgorny
Group Reviewers
Restricted Project
Commits
rGcd20e579df07: [unwind] fix build with GCC on PPC32
Summary

Originally reported downstream in Gentoo here.

/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:77:3: error: #error Architecture not supported
   77 | # error Architecture not supported
      |   ^~~~~
[...]
/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp: In function ‘int __unw_init_local(unw_cursor_t*, unw_context_t*)’:
/var/tmp/portage/sys-libs/llvm-libunwind-13.0.0/work/libunwind/src/libunwind.cpp:80:57: error: ‘REGISTER_KIND’ was not declared in this scope
   80 |   new (reinterpret_cast<UnwindCursor<LocalAddressSpace, REGISTER_KIND> *>(cursor))
      |                                                         ^~~~~~~~~~~~~
[...]

PPC is actually a supported architecture, but GCC (tested with 11.2.0) on powerpc32 seems to only define:
__PPC__, _ARCH_PPC, __PPC, __powerpc and not __ppc__.

This instead uses __powerpc__ which should be around on PPC32 and PPC64 (but we check it after PPC64, so it's fine).

Diff Detail

Event Timeline

thesamesam created this revision.Jan 26 2022, 11:36 PM
thesamesam requested review of this revision.Jan 26 2022, 11:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 11:36 PM
Arfrever added inline comments.
libunwind/include/__libunwind_config.h
58

It would probably suffice:

# elif defined(__powerpc__)

Similarly in other places.

libunwind/src/assembly.h
219
#if defined(__powerpc__) || defined(__powerpc64__)

In the future, please include more context in the diff :)

https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface "To make reviews easier, please always include as much context as possible with your diff!"

libunwind/include/__libunwind_config.h
58

__powerpc__ sounds good.

Both ppc32 and ppc64 define __powerpc__ and __PPC__. Can you also check whether this works for powerpc32?

MaskRay retitled this revision from llvm-libunwind build fix for GCC on PPC32 to [libunwind] build fix for GCC on PPC32.EditedJan 27 2022, 12:49 AM

__PPC__, _ARCH_PPC, __PPC, __powerpc and not __ppc__.

WoW, this looks like a Clang problem...

In GCC, __ppc__ is defined for FreeBSD/Darwin/etc but not Linux. Clang makes it apply to other systems.

thesamesam edited the summary of this revision. (Show Details)
thesamesam marked 3 inline comments as done.
MaskRay accepted this revision.Jan 27 2022, 12:22 PM

Thanks!

This revision is now accepted and ready to land.Jan 27 2022, 12:22 PM
mgorny accepted this revision.Jan 27 2022, 1:13 PM
mgorny added a subscriber: mgorny.

LGTM. Thanks.

This revision was landed with ongoing or failed builds.Jan 27 2022, 2:05 PM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJan 27 2022, 2:05 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript

@mgorny @MaskRay Please consider adding yourselves to the libunwind review groups if you aren't, and accepting as the group when a patch can be shipped. There would be a lot of value in having folks "own" libunwind more officially. Cheers and thanks for reviewing.

@mgorny @MaskRay Please consider adding yourselves to the libunwind review groups if you aren't, and accepting as the group when a patch can be shipped. There would be a lot of value in having folks "own" libunwind more officially. Cheers and thanks for reviewing.

Thanks. I am in #libunwind:) I have should added #libunwind when I saw this.