commit: ad7a235ec99e3ca42aced787d6ffd6484bfa2d1d Author: Dave Hughes <davidhughes205 <AT> gmail <DOT> com> AuthorDate: Mon Apr 19 02:04:52 2021 +0000 Commit: Dave Hughes <davidhughes205 <AT> gmail <DOT> com> CommitDate: Mon Apr 19 02:05:10 2021 +0000 URL: https://gitweb.gentoo.org/proj/musl.git/commit/?id=ad7a235e
dev-util/valgrind: add musl patch + suppressions Bug: https://bugs.gentoo.org/782766 Closes: https://bugs.gentoo.org/782766 Package-Manager: Portage-3.0.18, Repoman-3.0.3 Signed-off-by: Dave Hughes <davidhughes205 <AT> gmail.com> dev-util/valgrind/Manifest | 2 + dev-util/valgrind/files/musl.supp | 47 ++++++++ .../valgrind/files/valgrind-3.13.0-malloc.patch | 26 +++++ ...5.0-Build-ldst_multiple-test-with-fno-pie.patch | 22 ++++ .../files/valgrind-3.7.0-respect-flags.patch | 13 +++ dev-util/valgrind/metadata.xml | 24 ++++ dev-util/valgrind/valgrind-3.16.1.ebuild | 125 +++++++++++++++++++++ dev-util/valgrind/valgrind-3.17.0.ebuild | 125 +++++++++++++++++++++ dev-util/valgrind/valgrind-9999.ebuild | 125 +++++++++++++++++++++ 9 files changed, 509 insertions(+) diff --git a/dev-util/valgrind/Manifest b/dev-util/valgrind/Manifest new file mode 100644 index 0000000..f819814 --- /dev/null +++ b/dev-util/valgrind/Manifest @@ -0,0 +1,2 @@ +DIST valgrind-3.16.1.tar.bz2 16262776 BLAKE2B 1c333c26827f7a8356869e8758da9dd6a7444642ac4f6377c84fdab8349b9cee1e9bf2cf2eb86043c4feffab342dd97da20e76d7566d0296189e6ea8483a8c65 SHA512 2a4173efe1b6facdd2f5c5ee8ed006704168eba1813736fccc8191d60363afd96197512cf42037e65f18d4ddd49adc74a54c47210df216fba3c46bf68ef0f950 +DIST valgrind-3.17.0.tar.bz2 16459075 BLAKE2B 96569db9bc3c25ca195a4caa64da6e96b9bff7edd82727fccccaa8307162e29f4e150386c7c9611152fc1afde609d0922aa84067957b72dff03810ee23045e9c SHA512 94de78942a7059e1ab84d1c0c0b8f3efd1c2d15c70b97bc7edc8136812778adb6f8187149d53a60a8c6a7c8b40534f9be5cfed0eb3c0c314545b681f950b108f diff --git a/dev-util/valgrind/files/musl.supp b/dev-util/valgrind/files/musl.supp new file mode 100644 index 0000000..69adac7 --- /dev/null +++ b/dev-util/valgrind/files/musl.supp @@ -0,0 +1,47 @@ +# From: https://git.alpinelinux.org/aports/tree/main/valgrind/ +# Suppressions for musl libc +# See: https://www.openwall.com/lists/musl/2017/06/15/4 + +{ + musl-dynlink-false-positive1 + Memcheck:Leak + fun:calloc + fun:load_direct_deps + fun:load_deps + fun:load_deps + fun:__dls3 + fun:__dls2b + fun:__dls2 +} + +{ + musl-dynlink-false-positive2 + Memcheck:Leak + fun:calloc + fun:load_direct_deps + fun:load_deps + fun:load_deps + fun:__dls3 + fun:__dls2 +} + +{ + musl-dynlink-false-positive3 + Memcheck:Leak + fun:calloc + fun:load_library + fun:load_preload + fun:__dls3 + fun:__dls2b + fun:__dls2 +} + +{ + musl-dynlink-false-positive4 + Memcheck:Leak + fun:calloc + fun:load_library + fun:load_preload + fun:__dls3 + fun:__dls2 +} 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 0000000..ac6d90f --- /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/files/valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch b/dev-util/valgrind/files/valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch new file mode 100644 index 0000000..4417665 --- /dev/null +++ b/dev-util/valgrind/files/valgrind-3.15.0-Build-ldst_multiple-test-with-fno-pie.patch @@ -0,0 +1,22 @@ +From beab8d9f8d65230567270331017184c8762faa42 Mon Sep 17 00:00:00 2001 +From: Matt Turner <[email protected]> +Date: Mon, 4 Nov 2019 09:12:16 -0800 +Subject: [PATCH] Build ldst_multiple test with -fno-pie + +Bug: https://bugs.gentoo.org/685070 +--- + none/tests/ppc32/Makefile.am | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/none/tests/ppc32/Makefile.am b/none/tests/ppc32/Makefile.am +index 11697c99a..222efd3f2 100644 +--- a/none/tests/ppc32/Makefile.am ++++ b/none/tests/ppc32/Makefile.am +@@ -156,3 +156,4 @@ test_isa_2_07_part2_LDADD = -lm + test_tm_LDADD = -lm + test_touch_tm_LDADD = -lm + ++ldst_multiple_CFLAGS = $(AM_CFLAGS) -fno-pie +-- +2.23.0 + diff --git a/dev-util/valgrind/files/valgrind-3.7.0-respect-flags.patch b/dev-util/valgrind/files/valgrind-3.7.0-respect-flags.patch new file mode 100644 index 0000000..860e09c --- /dev/null +++ b/dev-util/valgrind/files/valgrind-3.7.0-respect-flags.patch @@ -0,0 +1,13 @@ +diff -Naur valgrind-3.7.0.orig//mpi/Makefile.am valgrind-3.7.0/mpi/Makefile.am +--- valgrind-3.7.0.orig//mpi/Makefile.am 2011-10-26 17:24:23.000000000 -0400 ++++ valgrind-3.7.0/mpi/Makefile.am 2011-11-10 16:03:14.000000000 -0500 +@@ -7,9 +7,6 @@ + CC = $(MPI_CC) + DEFS = + DEFAULT_INCLUDES = +-CPPFLAGS = +-CFLAGS = +-LDFLAGS = + + EXTRA_DIST = \ + mpiwrap_type_test.c diff --git a/dev-util/valgrind/metadata.xml b/dev-util/valgrind/metadata.xml new file mode 100644 index 0000000..0bf3fac --- /dev/null +++ b/dev-util/valgrind/metadata.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>[email protected]</email> + <name>Anthony G. Basile</name> + </maintainer> + <longdescription> + Valgrind is a GPL'd tool to help you find memory-management problems + in your programs. When a program is run under Valgrind's supervision, + all reads and writes of memory are checked, and calls to + malloc/new/free/delete are intercepted. As a result, Valgrind can + detect problems such as + + - Use of uninitialised memory + - Reading/writing memory after it has been free'd + - Reading/writing off the end of malloc'd blocks + - Reading/writing inappropriate areas on the stack + - Memory leaks -- where pointers to malloc'd blocks are lost forever + - Passing of uninitialised and/or unaddressible memory to system calls + - Mismatched use of malloc/new/new [] vs free/delete/delete [] + - Some abuses of the POSIX Pthreads API + </longdescription> +</pkgmetadata> diff --git a/dev-util/valgrind/valgrind-3.16.1.ebuild b/dev-util/valgrind/valgrind-3.16.1.ebuild new file mode 100644 index 0000000..6ca99db --- /dev/null +++ b/dev-util/valgrind/valgrind-3.16.1.ebuild @@ -0,0 +1,125 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +inherit autotools flag-o-matic toolchain-funcs multilib pax-utils + +DESCRIPTION="An open-source memory debugger for GNU/Linux" +HOMEPAGE="http://www.valgrind.org" +LICENSE="GPL-2" +SLOT="0" +IUSE="mpi" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://sourceware.org/git/${PN}.git" + inherit git-r3 +else + SRC_URI="ftp://sourceware.org/pub/valgrind/${P}.tar.bz2" + KEYWORDS="-* amd64 arm arm64 ppc ppc64 x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" +fi + +DEPEND="mpi? ( virtual/mpi )" +RDEPEND="${DEPEND}" + +src_prepare() { + # Correct hard coded doc location + sed -i -e "s:doc/valgrind:doc/${PF}:" docs/Makefile.am || die + + # Don't force multiarch stuff on OSX, bug #306467 + sed -i -e 's:-arch \(i386\|x86_64\)::g' Makefile.all.am || die + + # Respect CFLAGS, LDFLAGS + eapply "${FILESDIR}"/${PN}-3.7.0-respect-flags.patch + + 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 + # working the Linux/GNU way + find "${S}" -name "Makefile.am" -o -name "Makefile.tool.am" | xargs \ + sed -i -e 's:-M,/usr/lib/ld/map.noexstk:-z,noexecstack:' || die + cp "${S}"/coregrind/link_tool_exe_{linux,solaris}.in + fi + + # Allow users to test their own patches + eapply_user + + # Regenerate autotools files + eautoreconf +} + +src_configure() { + local myconf=() + + # Respect ar, bug #468114 + tc-export AR + + # -fomit-frame-pointer "Assembler messages: Error: junk `8' after expression" + # while compiling insn_sse.c in none/tests/x86 + # -fstack-protector more undefined references to __guard and __stack_smash_handler + # because valgrind doesn't link to glibc (bug #114347) + # -fstack-protector-all Fails same way as -fstack-protector/-fstack-protector-strong. + # Note: -fstack-protector-explicit is a no-op for Valgrind, no need to strip it + # -fstack-protector-strong See -fstack-protector (bug #620402) + # -m64 -mx32 for multilib-portage, bug #398825 + # -ggdb3 segmentation fault on startup + filter-flags -fomit-frame-pointer + filter-flags -fstack-protector + filter-flags -fstack-protector-all + filter-flags -fstack-protector-strong + filter-flags -m64 -mx32 + replace-flags -ggdb3 -ggdb2 + + if use amd64 || use ppc64; then + ! has_multilib_profile && myconf+=("--enable-only64bit") + fi + + # Force bitness on darwin, bug #306467 + use x64-macos && myconf+=("--enable-only64bit") + + # Don't use mpicc unless the user asked for it (bug #258832) + if ! use mpi; then + myconf+=("--without-mpicc") + fi + + econf "${myconf[@]}" +} + +src_install() { + default + + if [[ ${PV} == "9999" ]]; then + # Otherwise FAQ.txt won't exist: + emake -C docs FAQ.txt + mv docs/FAQ.txt . || die "Couldn't move FAQ.txt" + fi + + dodoc FAQ.txt + + pax-mark m "${ED}"/usr/$(get_libdir)/valgrind/*-*-linux + + if [[ ${CHOST} == *-darwin* ]] ; then + # fix install_names on shared libraries, can't turn them into bundles, + # as dyld won't load them any more then, bug #306467 + local l + for l in "${ED}"/usr/lib/valgrind/*.so ; do + install_name_tool -id "${EPREFIX}"/usr/lib/valgrind/${l##*/} "${l}" + done + fi +} + +pkg_postinst() { + elog "Valgrind will not work if glibc does not have debug symbols." + elog "To fix this you can add splitdebug to FEATURES in make.conf" + elog "and remerge glibc. See:" + elog "https://bugs.gentoo.org/show_bug.cgi?id=214065" + elog "https://bugs.gentoo.org/show_bug.cgi?id=274771" + elog "https://bugs.gentoo.org/show_bug.cgi?id=388703" +} diff --git a/dev-util/valgrind/valgrind-3.17.0.ebuild b/dev-util/valgrind/valgrind-3.17.0.ebuild new file mode 100644 index 0000000..c1a165b --- /dev/null +++ b/dev-util/valgrind/valgrind-3.17.0.ebuild @@ -0,0 +1,125 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +inherit autotools flag-o-matic toolchain-funcs multilib pax-utils + +DESCRIPTION="An open-source memory debugger for GNU/Linux" +HOMEPAGE="http://www.valgrind.org" +LICENSE="GPL-2" +SLOT="0" +IUSE="mpi" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://sourceware.org/git/${PN}.git" + inherit git-r3 +else + SRC_URI="ftp://sourceware.org/pub/valgrind/${P}.tar.bz2" + KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" +fi + +DEPEND="mpi? ( virtual/mpi )" +RDEPEND="${DEPEND}" + +src_prepare() { + # Correct hard coded doc location + sed -i -e "s:doc/valgrind:doc/${PF}:" docs/Makefile.am || die + + # Don't force multiarch stuff on OSX, bug #306467 + sed -i -e 's:-arch \(i386\|x86_64\)::g' Makefile.all.am || die + + # Respect CFLAGS, LDFLAGS + eapply "${FILESDIR}"/${PN}-3.7.0-respect-flags.patch + + 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 + # working the Linux/GNU way + find "${S}" -name "Makefile.am" -o -name "Makefile.tool.am" | xargs \ + sed -i -e 's:-M,/usr/lib/ld/map.noexstk:-z,noexecstack:' || die + cp "${S}"/coregrind/link_tool_exe_{linux,solaris}.in + fi + + # Allow users to test their own patches + eapply_user + + # Regenerate autotools files + eautoreconf +} + +src_configure() { + local myconf=() + + # Respect ar, bug #468114 + tc-export AR + + # -fomit-frame-pointer "Assembler messages: Error: junk `8' after expression" + # while compiling insn_sse.c in none/tests/x86 + # -fstack-protector more undefined references to __guard and __stack_smash_handler + # because valgrind doesn't link to glibc (bug #114347) + # -fstack-protector-all Fails same way as -fstack-protector/-fstack-protector-strong. + # Note: -fstack-protector-explicit is a no-op for Valgrind, no need to strip it + # -fstack-protector-strong See -fstack-protector (bug #620402) + # -m64 -mx32 for multilib-portage, bug #398825 + # -ggdb3 segmentation fault on startup + filter-flags -fomit-frame-pointer + filter-flags -fstack-protector + filter-flags -fstack-protector-all + filter-flags -fstack-protector-strong + filter-flags -m64 -mx32 + replace-flags -ggdb3 -ggdb2 + + if use amd64 || use ppc64; then + ! has_multilib_profile && myconf+=("--enable-only64bit") + fi + + # Force bitness on darwin, bug #306467 + use x64-macos && myconf+=("--enable-only64bit") + + # Don't use mpicc unless the user asked for it (bug #258832) + if ! use mpi; then + myconf+=("--without-mpicc") + fi + + econf "${myconf[@]}" +} + +src_install() { + default + + if [[ ${PV} == "9999" ]]; then + # Otherwise FAQ.txt won't exist: + emake -C docs FAQ.txt + mv docs/FAQ.txt . || die "Couldn't move FAQ.txt" + fi + + dodoc FAQ.txt + + pax-mark m "${ED}"/usr/$(get_libdir)/valgrind/*-*-linux + + if [[ ${CHOST} == *-darwin* ]] ; then + # fix install_names on shared libraries, can't turn them into bundles, + # as dyld won't load them any more then, bug #306467 + local l + for l in "${ED}"/usr/lib/valgrind/*.so ; do + install_name_tool -id "${EPREFIX}"/usr/lib/valgrind/${l##*/} "${l}" + done + fi +} + +pkg_postinst() { + elog "Valgrind will not work if glibc does not have debug symbols." + elog "To fix this you can add splitdebug to FEATURES in make.conf" + elog "and remerge glibc. See:" + elog "https://bugs.gentoo.org/show_bug.cgi?id=214065" + elog "https://bugs.gentoo.org/show_bug.cgi?id=274771" + elog "https://bugs.gentoo.org/show_bug.cgi?id=388703" +} diff --git a/dev-util/valgrind/valgrind-9999.ebuild b/dev-util/valgrind/valgrind-9999.ebuild new file mode 100644 index 0000000..c1a165b --- /dev/null +++ b/dev-util/valgrind/valgrind-9999.ebuild @@ -0,0 +1,125 @@ +# Copyright 1999-2021 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=7 +inherit autotools flag-o-matic toolchain-funcs multilib pax-utils + +DESCRIPTION="An open-source memory debugger for GNU/Linux" +HOMEPAGE="http://www.valgrind.org" +LICENSE="GPL-2" +SLOT="0" +IUSE="mpi" + +if [[ ${PV} == "9999" ]]; then + EGIT_REPO_URI="https://sourceware.org/git/${PN}.git" + inherit git-r3 +else + SRC_URI="ftp://sourceware.org/pub/valgrind/${P}.tar.bz2" + KEYWORDS="-* ~amd64 ~arm ~arm64 ~ppc ~ppc64 ~x86 ~amd64-linux ~x86-linux ~x64-macos ~x64-solaris" +fi + +DEPEND="mpi? ( virtual/mpi )" +RDEPEND="${DEPEND}" + +src_prepare() { + # Correct hard coded doc location + sed -i -e "s:doc/valgrind:doc/${PF}:" docs/Makefile.am || die + + # Don't force multiarch stuff on OSX, bug #306467 + sed -i -e 's:-arch \(i386\|x86_64\)::g' Makefile.all.am || die + + # Respect CFLAGS, LDFLAGS + eapply "${FILESDIR}"/${PN}-3.7.0-respect-flags.patch + + 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 + # working the Linux/GNU way + find "${S}" -name "Makefile.am" -o -name "Makefile.tool.am" | xargs \ + sed -i -e 's:-M,/usr/lib/ld/map.noexstk:-z,noexecstack:' || die + cp "${S}"/coregrind/link_tool_exe_{linux,solaris}.in + fi + + # Allow users to test their own patches + eapply_user + + # Regenerate autotools files + eautoreconf +} + +src_configure() { + local myconf=() + + # Respect ar, bug #468114 + tc-export AR + + # -fomit-frame-pointer "Assembler messages: Error: junk `8' after expression" + # while compiling insn_sse.c in none/tests/x86 + # -fstack-protector more undefined references to __guard and __stack_smash_handler + # because valgrind doesn't link to glibc (bug #114347) + # -fstack-protector-all Fails same way as -fstack-protector/-fstack-protector-strong. + # Note: -fstack-protector-explicit is a no-op for Valgrind, no need to strip it + # -fstack-protector-strong See -fstack-protector (bug #620402) + # -m64 -mx32 for multilib-portage, bug #398825 + # -ggdb3 segmentation fault on startup + filter-flags -fomit-frame-pointer + filter-flags -fstack-protector + filter-flags -fstack-protector-all + filter-flags -fstack-protector-strong + filter-flags -m64 -mx32 + replace-flags -ggdb3 -ggdb2 + + if use amd64 || use ppc64; then + ! has_multilib_profile && myconf+=("--enable-only64bit") + fi + + # Force bitness on darwin, bug #306467 + use x64-macos && myconf+=("--enable-only64bit") + + # Don't use mpicc unless the user asked for it (bug #258832) + if ! use mpi; then + myconf+=("--without-mpicc") + fi + + econf "${myconf[@]}" +} + +src_install() { + default + + if [[ ${PV} == "9999" ]]; then + # Otherwise FAQ.txt won't exist: + emake -C docs FAQ.txt + mv docs/FAQ.txt . || die "Couldn't move FAQ.txt" + fi + + dodoc FAQ.txt + + pax-mark m "${ED}"/usr/$(get_libdir)/valgrind/*-*-linux + + if [[ ${CHOST} == *-darwin* ]] ; then + # fix install_names on shared libraries, can't turn them into bundles, + # as dyld won't load them any more then, bug #306467 + local l + for l in "${ED}"/usr/lib/valgrind/*.so ; do + install_name_tool -id "${EPREFIX}"/usr/lib/valgrind/${l##*/} "${l}" + done + fi +} + +pkg_postinst() { + elog "Valgrind will not work if glibc does not have debug symbols." + elog "To fix this you can add splitdebug to FEATURES in make.conf" + elog "and remerge glibc. See:" + elog "https://bugs.gentoo.org/show_bug.cgi?id=214065" + elog "https://bugs.gentoo.org/show_bug.cgi?id=274771" + elog "https://bugs.gentoo.org/show_bug.cgi?id=388703" +}
