Andrew Geissler | 9aee500 | 2022-03-30 16:27:02 +0000 | [diff] [blame] | 1 | An all-in-one patch that fixes several issues: |
| 2 | |
| 3 | 1) UnscaledCycleClock not fully implemented for ppc*-musl (disabled on musl) |
| 4 | 2) powerpc stacktrace implementation only works on glibc (disabled on musl) |
| 5 | 3) powerpc stacktrace implementation has ppc64 assumptions (fixed) |
| 6 | 4) examine_stack.cpp makes glibc assumptions on powerpc (fixed) |
| 7 | |
| 8 | Sourced from void linux |
| 9 | |
| 10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
| 11 | |
| 12 | --- a/absl/base/internal/unscaledcycleclock.cc |
| 13 | +++ b/absl/base/internal/unscaledcycleclock.cc |
| 14 | @@ -20,7 +20,7 @@ |
| 15 | #include <intrin.h> |
| 16 | #endif |
| 17 | |
| 18 | -#if defined(__powerpc__) || defined(__ppc__) |
| 19 | +#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__) |
| 20 | #ifdef __GLIBC__ |
| 21 | #include <sys/platform/ppc.h> |
| 22 | #elif defined(__FreeBSD__) |
| 23 | @@ -59,7 +59,7 @@ double UnscaledCycleClock::Frequency() { |
| 24 | return base_internal::NominalCPUFrequency(); |
| 25 | } |
| 26 | |
| 27 | -#elif defined(__powerpc__) || defined(__ppc__) |
| 28 | +#elif (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__) |
| 29 | |
| 30 | int64_t UnscaledCycleClock::Now() { |
| 31 | #ifdef __GLIBC__ |
| 32 | --- a/absl/base/internal/unscaledcycleclock.h |
| 33 | +++ b/absl/base/internal/unscaledcycleclock.h |
| 34 | @@ -46,7 +46,8 @@ |
| 35 | |
| 36 | // The following platforms have an implementation of a hardware counter. |
| 37 | #if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \ |
| 38 | - defined(__powerpc__) || defined(__ppc__) || defined(__riscv) || \ |
| 39 | + ((defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)) || \ |
| 40 | + defined(__riscv) || \ |
| 41 | defined(_M_IX86) || defined(_M_X64) |
| 42 | #define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1 |
| 43 | #else |
| 44 | --- a/absl/debugging/internal/examine_stack.cc |
| 45 | +++ b/absl/debugging/internal/examine_stack.cc |
| 46 | @@ -27,6 +27,10 @@ |
| 47 | #include <csignal> |
| 48 | #include <cstdio> |
| 49 | |
| 50 | +#if defined(__powerpc__) |
| 51 | +#include <asm/ptrace.h> |
| 52 | +#endif |
| 53 | + |
| 54 | #include "absl/base/attributes.h" |
| 55 | #include "absl/base/internal/raw_logging.h" |
| 56 | #include "absl/base/macros.h" |
| 57 | @@ -63,8 +67,10 @@ void* GetProgramCounter(void* vuc) { |
| 58 | return reinterpret_cast<void*>(context->uc_mcontext.pc); |
| 59 | #elif defined(__powerpc64__) |
| 60 | return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]); |
| 61 | -#elif defined(__powerpc__) |
| 62 | +#elif defined(__powerpc__) && defined(__GLIBC__) |
| 63 | return reinterpret_cast<void*>(context->uc_mcontext.uc_regs->gregs[32]); |
| 64 | +#elif defined(__powerpc__) |
| 65 | + return reinterpret_cast<void*>(((struct pt_regs *)context->uc_regs)->gregs[32]); |
| 66 | #elif defined(__riscv) |
| 67 | return reinterpret_cast<void*>(context->uc_mcontext.__gregs[REG_PC]); |
| 68 | #elif defined(__s390__) && !defined(__s390x__) |
| 69 | --- a/absl/debugging/internal/stacktrace_config.h |
| 70 | +++ b/absl/debugging/internal/stacktrace_config.h |
| 71 | @@ -59,7 +59,7 @@ |
| 72 | #elif defined(__i386__) || defined(__x86_64__) |
| 73 | #define ABSL_STACKTRACE_INL_HEADER \ |
| 74 | "absl/debugging/internal/stacktrace_x86-inl.inc" |
| 75 | -#elif defined(__ppc__) || defined(__PPC__) |
| 76 | +#elif (defined(__ppc__) || defined(__PPC__)) && defined(__GLIBC__) |
| 77 | #define ABSL_STACKTRACE_INL_HEADER \ |
| 78 | "absl/debugging/internal/stacktrace_powerpc-inl.inc" |
| 79 | #elif defined(__aarch64__) |