void-packages/srcpkgs/grpc/patches/google-sucks.patch

112 lines
4.8 KiB
Diff

An all-in-one patch that fixes several issues:
1) no sys/platform/ppc.h outside of glibc (disabled on musl)
2) generic stacktrace implementation only works on glibc (disabled on musl)
3) powerpc stacktrace implementation only works on glibc (disabled on musl)
4) powerpc stacktrace implementation has ppc64 assumptions (fixed)
5) examine_stack.cpp makes glibc assumptions on powerpc (fixed)
--- third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc
+++ third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.cc
@@ -20,7 +20,7 @@
#include <intrin.h>
#endif
-#if defined(__powerpc__) || defined(__ppc__)
+#if (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)
#include <sys/platform/ppc.h>
#endif
@@ -54,7 +54,7 @@ double UnscaledCycleClock::Frequency() {
return base_internal::NominalCPUFrequency();
}
-#elif defined(__powerpc__) || defined(__ppc__)
+#elif (defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)
int64_t UnscaledCycleClock::Now() {
return __ppc_get_timebase();
--- third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
+++ third_party/abseil-cpp/absl/base/internal/unscaledcycleclock.h
@@ -46,7 +46,7 @@
// The following platforms have an implementation of a hardware counter.
#if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__) || \
- defined(__powerpc__) || defined(__ppc__) || \
+ ((defined(__powerpc__) || defined(__ppc__)) && defined(__GLIBC__)) || \
defined(_M_IX86) || defined(_M_X64)
#define ABSL_HAVE_UNSCALED_CYCLECLOCK_IMPLEMENTATION 1
#else
--- third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc
+++ third_party/abseil-cpp/absl/debugging/internal/examine_stack.cc
@@ -23,6 +23,10 @@
#include <csignal>
#include <cstdio>
+#if defined(__powerpc__)
+#include <asm/ptrace.h>
+#endif
+
#include "absl/base/attributes.h"
#include "absl/base/internal/raw_logging.h"
#include "absl/base/macros.h"
@@ -51,8 +55,10 @@ void* GetProgramCounter(void* vuc) {
return reinterpret_cast<void*>(context->uc_mcontext.pc);
#elif defined(__powerpc64__)
return reinterpret_cast<void*>(context->uc_mcontext.gp_regs[32]);
-#elif defined(__powerpc__)
+#elif defined(__powerpc64__) || (defined(__powerpc__) && defined(__GLIBC__))
return reinterpret_cast<void*>(context->uc_mcontext.regs->nip);
+#elif defined(__powerpc__)
+ return reinterpret_cast<void*>(((struct pt_regs *)context->uc_regs)->nip);
#elif defined(__s390__) && !defined(__s390x__)
return reinterpret_cast<void*>(context->uc_mcontext.psw.addr & 0x7fffffff);
#elif defined(__s390__) && defined(__s390x__)
--- third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h
+++ third_party/abseil-cpp/absl/debugging/internal/stacktrace_config.h
@@ -34,13 +34,13 @@
# if defined(__i386__) || defined(__x86_64__)
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_x86-inl.inc"
-# elif defined(__ppc__) || defined(__PPC__)
+# elif (defined(__ppc__) || defined(__PPC__)) && defined(__GLIBC__)
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_powerpc-inl.inc"
# elif defined(__aarch64__)
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_aarch64-inl.inc"
-# elif defined(__arm__)
+# elif defined(__arm__) && defined(__GLIBC__)
// Note: When using glibc this may require -funwind-tables to function properly.
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_generic-inl.inc"
@@ -49,10 +49,10 @@
"absl/debugging/internal/stacktrace_unimplemented-inl.inc"
# endif
#else // defined(NO_FRAME_POINTER)
-# if defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)
+# if (defined(__i386__) || defined(__x86_64__) || defined(__aarch64__)) && defined(__GLIBC__)
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_generic-inl.inc"
-# elif defined(__ppc__) || defined(__PPC__)
+# elif (defined(__ppc__) || defined(__PPC__)) && defined(__GLIBC__)
#define ABSL_STACKTRACE_INL_HEADER \
"absl/debugging/internal/stacktrace_generic-inl.inc"
# else
--- third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc
+++ third_party/abseil-cpp/absl/debugging/internal/stacktrace_powerpc-inl.inc
@@ -130,8 +130,13 @@ static void **NextStackFrame(void **old_sp, const void *uc) {
StacktracePowerPCGetLR(new_sp) == kernel_sigtramp_rt64_address) {
const ucontext_t* signal_context =
reinterpret_cast<const ucontext_t*>(uc);
+#if defined(__powerpc64__)
void **const sp_before_signal =
reinterpret_cast<void**>(signal_context->uc_mcontext.gp_regs[PT_R1]);
+#else
+ void **const sp_before_signal =
+ reinterpret_cast<void**>(signal_context->uc_mcontext.uc_regs->gregs[PT_R1]);
+#endif
// Check that alleged sp before signal is nonnull and is reasonably
// aligned.
if (sp_before_signal != nullptr &&