commit:     1ea5ea8366262f347d003d9c337f7a92a81477ac
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 21 15:19:58 2022 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Jul 21 15:19:58 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1ea5ea83

dev-util/valgrind: add musl support

Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Anthony G. Basile <blueness <AT> gentoo.org>

 .../valgrind/files/valgrind-3.13.0-malloc.patch    | 26 ++++++++++++++++++++++
 dev-util/valgrind/valgrind-3.19.0.ebuild           |  6 +++++
 dev-util/valgrind/valgrind-9999.ebuild             |  6 +++++
 3 files changed, 38 insertions(+)

diff --git a/dev-util/valgrind/files/valgrind-3.13.0-malloc.patch 
b/dev-util/valgrind/files/valgrind-3.13.0-malloc.patch
new file mode 100644
index 000000000000..ac6d90fef50f
--- /dev/null
+++ b/dev-util/valgrind/files/valgrind-3.13.0-malloc.patch
@@ -0,0 +1,26 @@
+From: https://git.alpinelinux.org/aports/tree/main/valgrind/
+
+--- valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c
++++ valgrind-3.13.0/coregrind/m_replacemalloc/vg_replace_malloc.c
+@@ -765,13 +765,15 @@ static void init(void);
+       DO_INIT; \
+       MALLOC_TRACE("realloc(%p,%llu)", ptrV, (ULong)new_size ); \
+       \
+-      if (ptrV == NULL) \
+-         /* We need to call a malloc-like function; so let's use \
+-            one which we know exists. */ \
+-         return VG_REPLACE_FUNCTION_EZU(10010,VG_Z_LIBC_SONAME,malloc) \
+-                   (new_size); \
++      if (ptrV == NULL) { \
++         TRIGGER_MEMCHECK_ERROR_IF_UNDEFINED(new_size); \
++         v = (void*)VALGRIND_NON_SIMD_CALL1( info.tl_malloc, new_size ); \
++         MALLOC_TRACE(" = %p\n", v ); \
++         return v; \
++      } \
+       if (new_size <= 0) { \
+-         VG_REPLACE_FUNCTION_EZU(10050,VG_Z_LIBC_SONAME,free)(ptrV); \
++         if (ptrV != NULL)  \
++            VALGRIND_NON_SIMD_CALL1( info.tl_free, ptrV ); \
+          MALLOC_TRACE(" = 0\n"); \
+          return NULL; \
+       } \

diff --git a/dev-util/valgrind/valgrind-3.19.0.ebuild 
b/dev-util/valgrind/valgrind-3.19.0.ebuild
index 5a2a07829d30..4ff9c8e71913 100644
--- a/dev-util/valgrind/valgrind-3.19.0.ebuild
+++ b/dev-util/valgrind/valgrind-3.19.0.ebuild
@@ -34,6 +34,12 @@ src_prepare() {
 
        eapply 
"${FILESDIR}"/${PN}-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch
 
+       # conditionally copy musl specific suppressions && apply patch
+       if use elibc_musl ; then
+               cp "${FILESDIR}/musl.supp" "${S}"
+               eapply "${FILESDIR}/valgrind-3.13.0-malloc.patch"
+       fi
+
        if [[ ${CHOST} == *-solaris* ]] ; then
                # upstream doesn't support this, but we don't build with
                # Sun/Oracle ld, we have a GNU toolchain, so get some things

diff --git a/dev-util/valgrind/valgrind-9999.ebuild 
b/dev-util/valgrind/valgrind-9999.ebuild
index 5a2a07829d30..4ff9c8e71913 100644
--- a/dev-util/valgrind/valgrind-9999.ebuild
+++ b/dev-util/valgrind/valgrind-9999.ebuild
@@ -34,6 +34,12 @@ src_prepare() {
 
        eapply 
"${FILESDIR}"/${PN}-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch
 
+       # conditionally copy musl specific suppressions && apply patch
+       if use elibc_musl ; then
+               cp "${FILESDIR}/musl.supp" "${S}"
+               eapply "${FILESDIR}/valgrind-3.13.0-malloc.patch"
+       fi
+
        if [[ ${CHOST} == *-solaris* ]] ; then
                # upstream doesn't support this, but we don't build with
                # Sun/Oracle ld, we have a GNU toolchain, so get some things

Reply via email to