heaptrack: Update to latest tip of trunk

* It has cmake 4 fixes
* Drop all patches, they are no more needed
* Fix build with glibc-2.43/c23
* Enabled on riscv64, since libunwind now supports it

Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Khem Raj 2025-11-10 19:09:09 -08:00
parent 94d633bbe8
commit 430667a97c
No known key found for this signature in database
GPG Key ID: BB053355919D3314
8 changed files with 80 additions and 328 deletions

View File

@ -0,0 +1,47 @@
From 5afb9b9267b59f60b53978858e21ec2369659de7 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 10 Nov 2025 18:53:38 -0800
Subject: [PATCH] libheaptrack: Fix build on c23
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
C23/glibc is now including once_init in stdlib.h
https://patchwork.sourceware.org/project/glibc/patch/78061085-f04a-0c45-107b-5a8a15521083@redhat.com/#213088
This is a name collision with the new C once_flag/call_once that
glibc exposes (via <stdlib.h>) and C++s std::once_flag/std::call_once
Fixes
../sources/heaptrack-1.5.0+git/src/track/libheaptrack.cpp:301:16: error: reference to 'once_flag' is ambiguous
301 | static once_flag once;
| ^
../recipe-sysroot/usr/include/bits/types/once_flag.h:24:21: note: candidate found by name lookup is 'once_flag'
24 | typedef __once_flag once_flag;
| ^
../recipe-sysroot/usr/lib/aarch64-yoe-linux/15.2.0/../../../include/c++/15.2.0/mutex:809:10: note: candidate found by name lookup is 'std::once_flag'
809 | struct once_flag
| ^
Upstream-Status: Submitted [https://invent.kde.org/sdk/heaptrack/-/merge_requests/56]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/track/libheaptrack.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/track/libheaptrack.cpp b/src/track/libheaptrack.cpp
index 4be3dcd..f7576a2 100644
--- a/src/track/libheaptrack.cpp
+++ b/src/track/libheaptrack.cpp
@@ -298,8 +298,8 @@ public:
}
// do some once-only initializations
- static once_flag once;
- call_once(once, [] {
+ static std::once_flag once;
+ std::call_once(once, [] {
debugLog<MinimalOutput>("%s", "doing once-only initialization");
Trace::setup();

View File

@ -1,26 +0,0 @@
From 18671cd6028f996c138c6eb4282caf313f3fc605 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Nov 2020 15:25:18 -0800
Subject: [PATCH] libheaptrack: Replace __pid_t with pid_t
__pid_t is for internal libc use
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/track/libheaptrack.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/track/libheaptrack.cpp b/src/track/libheaptrack.cpp
index e138bce..4120ecd 100644
--- a/src/track/libheaptrack.cpp
+++ b/src/track/libheaptrack.cpp
@@ -79,7 +79,7 @@ chrono::milliseconds elapsedTime()
return chrono::duration_cast<chrono::milliseconds>(clock::now() - startTime());
}
-__pid_t gettid()
+pid_t gettid()
{
return syscall(SYS_gettid);
}

View File

@ -1,41 +0,0 @@
From bcfc4c8d7dc70bd81367c183a68cc9ee02ab4744 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Fri, 28 May 2021 17:52:57 -0700
Subject: [PATCH] track: Check for unw_set_caching_policy before using
llvm libunwind does not implement unw_cache_* functions yet
Include inttypes.h got PRI* macros
Upstream-Status: Submitted [https://github.com/KDE/heaptrack/pull/33]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/track/trace_libunwind.cpp | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/track/trace_libunwind.cpp b/src/track/trace_libunwind.cpp
index c76337c..96b2176 100644
--- a/src/track/trace_libunwind.cpp
+++ b/src/track/trace_libunwind.cpp
@@ -26,6 +26,7 @@
#define UNW_LOCAL_ONLY
#include <libunwind.h>
+#include <inttypes.h>
#include <stdio.h>
@@ -60,9 +61,11 @@ void Trace::print()
void Trace::setup()
{
// configure libunwind for better speed
+#if UNW_CACHE_PER_THREAD
if (unw_set_caching_policy(unw_local_addr_space, UNW_CACHE_PER_THREAD)) {
fprintf(stderr, "WARNING: Failed to enable per-thread libunwind caching.\n");
}
+#endif
#if LIBUNWIND_HAS_UNW_SET_CACHE_SIZE
if (unw_set_cache_size(unw_local_addr_space, 1024, 0)) {
fprintf(stderr, "WARNING: Failed to set libunwind cache size.\n");
--
2.31.1

View File

@ -1,38 +0,0 @@
From 8ebcf5f2dd27dbeb6c81e9c40a5d17916cb243e6 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Nov 2020 15:26:31 -0800
Subject: [PATCH] heaptrack_inject: Include dlfcn.h for dlopen/dlclose
Do not use __WORDSIZE which is for libc internal use
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/track/heaptrack_inject.cpp | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/track/heaptrack_inject.cpp b/src/track/heaptrack_inject.cpp
index 325d87e..fb1c154 100644
--- a/src/track/heaptrack_inject.cpp
+++ b/src/track/heaptrack_inject.cpp
@@ -28,6 +28,7 @@
#include <link.h>
#include <malloc.h>
#include <unistd.h>
+#include <dlfcn.h>
#include <sys/mman.h>
@@ -39,9 +40,10 @@
* @brief Experimental support for symbol overloading after runtime injection.
*/
-#if __WORDSIZE == 64
+#include <limits.h>
+#if ULONG_MAX == 0xffffffffffffffff
#define ELF_R_SYM(i) ELF64_R_SYM(i)
-#elif __WORDSIZE == 32
+#elif ULONG_MAX == 0xffffffff
#define ELF_R_SYM(i) ELF32_R_SYM(i)
#else
#error unsupported word size

View File

@ -1,118 +0,0 @@
From b8435c6523d9377f04d5e21629f3dc68b8865016 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Nov 2020 15:31:45 -0800
Subject: [PATCH] heaptrack_preload: Make noexcept attribute conditional
musl does not define these functions with noexcept and hence compiler
complains about them
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
src/track/heaptrack_preload.cpp | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/track/heaptrack_preload.cpp b/src/track/heaptrack_preload.cpp
index 63110ce..ee85331 100644
--- a/src/track/heaptrack_preload.cpp
+++ b/src/track/heaptrack_preload.cpp
@@ -171,11 +171,17 @@ void init()
}
}
+#ifdef __GLIBC__
+#define NOEXECPT noexcept
+#else
+#define NOEXECPT
+#endif
+
extern "C" {
/// TODO: memalign, pvalloc, ...?
-void* malloc(size_t size) noexcept
+void* malloc(size_t size) NOEXECPT
{
if (!hooks::malloc) {
hooks::init();
@@ -186,7 +192,7 @@ void* malloc(size_t size) noexcept
return ptr;
}
-void free(void* ptr) noexcept
+void free(void* ptr) NOEXECPT
{
if (!hooks::free) {
hooks::init();
@@ -204,7 +210,7 @@ void free(void* ptr) noexcept
hooks::free(ptr);
}
-void* realloc(void* ptr, size_t size) noexcept
+void* realloc(void* ptr, size_t size) NOEXECPT
{
if (!hooks::realloc) {
hooks::init();
@@ -219,7 +225,7 @@ void* realloc(void* ptr, size_t size) noexcept
return ret;
}
-void* calloc(size_t num, size_t size) noexcept
+void* calloc(size_t num, size_t size) NOEXECPT
{
if (!hooks::calloc) {
hooks::init();
@@ -235,7 +241,7 @@ void* calloc(size_t num, size_t size) noexcept
}
#if HAVE_CFREE
-void cfree(void* ptr) noexcept
+void cfree(void* ptr) NOEXECPT
{
if (!hooks::cfree) {
hooks::init();
@@ -252,7 +258,7 @@ void cfree(void* ptr) noexcept
}
#endif
-int posix_memalign(void** memptr, size_t alignment, size_t size) noexcept
+int posix_memalign(void** memptr, size_t alignment, size_t size) NOEXECPT
{
if (!hooks::posix_memalign) {
hooks::init();
@@ -268,7 +274,7 @@ int posix_memalign(void** memptr, size_t alignment, size_t size) noexcept
}
#if HAVE_ALIGNED_ALLOC
-void* aligned_alloc(size_t alignment, size_t size) noexcept
+void* aligned_alloc(size_t alignment, size_t size) NOEXECPT
{
if (!hooks::aligned_alloc) {
hooks::init();
@@ -285,7 +291,7 @@ void* aligned_alloc(size_t alignment, size_t size) noexcept
#endif
#if HAVE_VALLOC
-void* valloc(size_t size) noexcept
+void* valloc(size_t size) NOEXECPT
{
if (!hooks::valloc) {
hooks::init();
@@ -301,7 +307,7 @@ void* valloc(size_t size) noexcept
}
#endif
-void* dlopen(const char* filename, int flag) noexcept
+void* dlopen(const char* filename, int flag) NOEXECPT
{
if (!hooks::dlopen) {
hooks::init();
@@ -316,7 +322,7 @@ void* dlopen(const char* filename, int flag) noexcept
return ret;
}
-int dlclose(void* handle) noexcept
+int dlclose(void* handle) NOEXECPT
{
if (!hooks::dlclose) {
hooks::init();

View File

@ -1,42 +0,0 @@
From 200f71ea8c0756594ac7e079ccc686d9a20cea5c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 23 Nov 2020 15:32:58 -0800
Subject: [PATCH] backtrace: Always include stdint.h
in OE we will always have system headers which supports C99/stdint.h
Upstream-Status: Inappropriate [Unless upstream drops legacy]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
3rdparty/libbacktrace/backtrace.h | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/3rdparty/libbacktrace/backtrace.h b/3rdparty/libbacktrace/backtrace.h
index 14863cf..d0ac38f 100644
--- a/3rdparty/libbacktrace/backtrace.h
+++ b/3rdparty/libbacktrace/backtrace.h
@@ -36,24 +36,8 @@ POSSIBILITY OF SUCH DAMAGE. */
#include <stddef.h>
#include <stdio.h>
-/* We want to get a definition for uintptr_t, but we still care about
- systems that don't have <stdint.h>. */
-#if defined(__GLIBC__) && __GLIBC__ >= 2
-
-#include <stdint.h>
-
-#elif defined(HAVE_STDINT_H)
-
#include <stdint.h>
-#else
-
-/* Systems that don't have <stdint.h> must provide gstdint.h, e.g.,
- from GCC_HEADER_STDINT in configure.ac. */
-#include "gstdint.h"
-
-#endif
-
#ifdef __cplusplus
extern "C" {
#endif

View File

@ -1,63 +0,0 @@
SUMMARY = "Heap memory profiler for Linux"
DESCRIPTION = "Heaptrack traces all memory allocations and annotates these \
events with stack traces. Dedicated analysis tools then allow you to interpret \
the heap memory profile to find hotspots to reduce memory, leaks, allocation \
hotspots and temporary allocations"
HOMEPAGE = "https://phabricator.kde.org/source/heaptrack/"
LICENSE = "LGPL-2.1-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=4fbd65380cdd255951079008b364516c"
DEPENDS = "zlib boost libunwind elfutils"
SRC_URI = "git://github.com/KDE/heaptrack.git;protocol=https;branch=master \
file://0001-libheaptrack-Replace-__pid_t-with-pid_t.patch \
file://0002-heaptrack_inject-Include-dlfcn.h-for-dlopen-dlclose.patch \
file://0003-heaptrack_preload-Make-noexcept-attribute-conditiona.patch \
file://0004-backtrace-Always-include-stdint.h.patch \
file://0001-track-Check-for-unw_set_caching_policy-before-using.patch \
"
SRCREV = "bc9e3744bcc47de978673d1e382f4125a1ab5fa8"
inherit cmake
EXTRA_OECMAKE += "-DHEAPTRACK_BUILD_GUI=OFF \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
"
# libunwind is not yet ported to RISCV
COMPATIBLE_HOST:riscv32 = "null"
COMPATIBLE_HOST:riscv64 = "null"
BBCLASSEXTEND = "native"
# http://errors.yoctoproject.org/Errors/Details/766879/
# buildResult:
# variable: "LIBUNWIND_HAS_UNW_BACKTRACE"
# cached: true
# stdout: |
# Change Dir: '/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build/CMakeFiles/CMakeScratch/TryCompile-kguYrO'
#
# Run Build Command(s): ninja -v cmTC_51d86
# [1/2] ccache /OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot-native/usr/bin/aarch64-webos-linux/aarch64-webos-linux-gcc --sysroot=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot -DLIBUNWIND_HAS_UNW_BACKTRACE -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type --sysroot=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/git=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/git=/usr/src/debug/heaptrack/1.2.0 -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot= -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot= -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot-native= -o CMakeFiles/cmTC_51d86.dir/src.c.o -c /OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build/CMakeFiles/CMakeScratch/TryCompile-kguYrO/src.c
# FAILED: CMakeFiles/cmTC_51d86.dir/src.c.o
# ccache /OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot-native/usr/bin/aarch64-webos-linux/aarch64-webos-linux-gcc --sysroot=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot -DLIBUNWIND_HAS_UNW_BACKTRACE -mcpu=cortex-a72+crc -mbranch-protection=standard -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security -Werror=return-type --sysroot=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot -O2 -pipe -g -feliminate-unused-debug-types -fcanon-prefix-map -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/git=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/git=/usr/src/debug/heaptrack/1.2.0 -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build=/usr/src/debug/heaptrack/1.2.0 -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot= -fmacro-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot= -fdebug-prefix-map=/OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/recipe-sysroot-native= -o CMakeFiles/cmTC_51d86.dir/src.c.o -c /OE/lge/build/webos/styhead/BUILD/work/raspberrypi4_64-webos-linux/heaptrack/1.2.0/build/CMakeFiles/CMakeScratch/TryCompile-kguYrO/src.c
# src.c: In function 'main':
# src.c:3:43: error: passing argument 1 of 'unw_backtrace' from incompatible pointer type [-Wincompatible-pointer-types]
# 3 | int main() { void* buf[10]; unw_backtrace(&buf, 10); return 0; }
# | ^~~~
# | |
# | void * (*)[10]
# In file included from ../../../../recipe-sysroot/usr/include/libunwind-aarch64.h:232,
# from ../../../../recipe-sysroot/usr/include/libunwind-64.h:7,
# from ../../../../recipe-sysroot/usr/include/libunwind.h:27,
# from src.c:2:
# ../../../../recipe-sysroot/usr/include/libunwind-common.h:290:27: note: expected 'void **' but argument is of type 'void * (*)[10]'
# 290 | extern int unw_backtrace (void **, int);
# | ^~~~~~~
# ninja: build stopped: subcommand failed.
#
# exitCode: 1
#
CFLAGS += "-Wno-error=incompatible-pointer-types"

View File

@ -0,0 +1,33 @@
SUMMARY = "Heap memory profiler for Linux"
DESCRIPTION = "Heaptrack traces all memory allocations and annotates these \
events with stack traces. Dedicated analysis tools then allow you to interpret \
the heap memory profile to find hotspots to reduce memory, leaks, allocation \
hotspots and temporary allocations"
HOMEPAGE = "https://phabricator.kde.org/source/heaptrack/"
LICENSE = "LGPL-2.1-only"
LIC_FILES_CHKSUM = "file://LICENSES/Apache-2.0.txt;md5=c846ebb396f8b174b10ded4771514fcc \
file://LICENSES/BSD-3-Clause.txt;md5=f225922a2c12dfa5218fb70c49db3ea6 \
file://LICENSES/BSL-1.0.txt;md5=4c66a2bad475d1a8f152667a4d0ada34 \
file://LICENSES/GPL-2.0-or-later.txt;md5=3d26203303a722dedc6bf909d95ba815 \
file://LICENSES/LGPL-2.1-only.txt;md5=41890f71f740302b785c27661123bff5 \
file://LICENSES/LGPL-2.1-or-later.txt;md5=147a320ed8b16b036829a0c71d424153 \
file://LICENSES/MIT.txt;md5=7dda4e90ded66ab88b86f76169f28663"
DEPENDS = "zlib boost libunwind elfutils"
SRC_URI = "git://github.com/KDE/heaptrack.git;protocol=https;branch=master \
file://0001-libheaptrack-Fix-build-on-c23.patch \
"
SRCREV = "0a15d643791e9829ef3f754ac10e3bed966152c5"
PV .= "+git"
inherit cmake
EXTRA_OECMAKE += "-DHEAPTRACK_BUILD_GUI=OFF"
# libunwind is not yet ported to RISCV32
COMPATIBLE_HOST:riscv32 = "null"
BBCLASSEXTEND = "native"
TOOLCHAIN = "gcc"