gperftools: allow building for powerpc

Add pending patches submitted upstream, which fix the build failures
discovered on powerpc with musl, and drop the powerpc exclusion from
DEPENDS.

Patches are from https://github.com/gperftools/gperftools/pull/1616

Signed-off-by: Josef Schlehofer <pepe.schlehofer@gmail.com>
This commit is contained in:
Josef Schlehofer committed 2026-07-29 00:03:17 +02:00
1 parent 774ec304f7
commit efbd9b9820
4 files changed
+100 -2

No files matched your search

+2 -2
View File
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=gperftools
PKG_VERSION:=2.17.2
PKG_RELEASE:=3
PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/gperftools/gperftools/tar.gz/$(PKG_NAME)-$(PKG_VERSION)?
@@ -27,7 +27,7 @@ define Package/gperftools
CATEGORY:=Libraries
TITLE:=Gperftools Runtime
URL:=https://github.com/gperftools/gperftools
DEPENDS:=+PACKAGE_libunwind:libunwind +libstdcpp @!(powerpc)
DEPENDS:=+PACKAGE_libunwind:libunwind +libstdcpp
ABI_VERSION:=4
endef
@@ -0,0 +1,27 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
Date: Tue, 23 Sep 2025 18:35:30 +0200
Subject: [PATCH] powerpc: include <asm/ptrace.h> for PT_NIP declaration
This patch conditionally includes <asm/ptrace.h> when available to
ensure PT_NIP is properly declared, fixing build failures such as:
error: 'PT_NIP' was not declared in this scope; did you mean 'PT_NUM'?
It happened on musl and powerpc
---
src/stacktrace_powerpc-linux-inl.h | 3 +++
1 file changed, 3 insertions(+)
--- a/src/stacktrace_powerpc-linux-inl.h
+++ b/src/stacktrace_powerpc-linux-inl.h
@@ -48,6 +48,9 @@
#include <gperftools/stacktrace.h>
#include <base/vdso_support.h>
+#ifdef HAVE_ASM_PTRACE_H
+#include <asm/ptrace.h>
+#endif
#if HAVE_SYS_UCONTEXT_H
#include <sys/ucontext.h>
#elif HAVE_UCONTEXT_H
@@ -0,0 +1,37 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
Date: Wed, 24 Sep 2025 10:57:08 +0200
Subject: [PATCH] elf_mem_image: derive ELF class from pointer size, not
__WORDSIZE
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
__WORDSIZE is a non-standard glibc macro that musl does not expose
through the headers included here, so the build fails on musl-based
systems:
src/base/elf_mem_image.cc:95:18: error: '__WORDSIZE' was not declared in this scope
95 | typedef ElfClass<__WORDSIZE> CurrentElfClass;
| ^~~~~~~~~~
This code is ELF-only, where the pointer size can be assumed to be the
word size, so compute the ELF class from sizeof(void*) instead of
relying on a libc-specific macro.
Co-authored-by: Karel Kočí <cynerd@email.cz>
---
src/base/elf_mem_image.cc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/src/base/elf_mem_image.cc
+++ b/src/base/elf_mem_image.cc
@@ -92,7 +92,7 @@ template <> class ElfClass<64> {
}
};
-typedef ElfClass<__WORDSIZE> CurrentElfClass;
+typedef ElfClass<sizeof(void*) * 8> CurrentElfClass;
// Extract an element from one of the ELF tables, cast it to desired type.
// This is just a simple arithmetic and a glorified cast.
@@ -0,0 +1,34 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Josef Schlehofer <pepe.schlehofer@gmail.com>
Date: Tue, 23 Sep 2025 18:40:37 +0200
Subject: [PATCH] powerpc: fix PT_NIP access in ucontext for glibc vs non-glibc
The layout of ucontext_t differs between glibc and some
other C libraries. Specifically, the instruction pointer (PT_NIP) is
accessed through:
uc.uc_mcontext.uc_regs->gregs[PT_NIP] (glibc)
uc.uc_mcontext.gregs[PT_NIP] (non-glibc)
Without this distinction, builds on non-glibc systems fail with
invalid field access errors.
Based on https://gcc.gnu.org/cgit/gcc/commit/?id=6a4e9934545c112eef5eb7248636baa96cbfd2c0
---
src/stacktrace_powerpc-linux-inl.h | 4 ++++
1 file changed, 4 insertions(+)
--- a/src/stacktrace_powerpc-linux-inl.h
+++ b/src/stacktrace_powerpc-linux-inl.h
@@ -207,7 +207,11 @@ static int GET_STACK_TRACE_OR_FRAMES {
ucontext_t uc;
// We don't care about the rest, since IP value is at 'uc' field.A
} *sigframe = reinterpret_cast<rt_signal_frame_32*>(current);
+#if defined(__GLIBC__)
result[n] = (void*) sigframe->uc.uc_mcontext.uc_regs->gregs[PT_NIP];
+#else
+ result[n] = (void*) sigframe->uc.uc_mcontext.gregs[PT_NIP];
+#endif
}
#endif