commit:     40b1dc94e0b30a2a4a557f8b4d0249ab86dc037a
Author:     Yixun Lan <dlan <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  4 12:02:37 2022 +0000
Commit:     Yixun Lan <dlan <AT> gentoo <DOT> org>
CommitDate: Mon Apr  4 12:02:37 2022 +0000
URL:        https://gitweb.gentoo.org/proj/riscv.git/commit/?id=40b1dc94

dev-util/valgrind: experimental support for riscv

https://github.com/petrpavlu/valgrind-riscv64

Package-Manager: Portage-3.0.30, Repoman-3.0.3
Signed-off-by: Yixun Lan <dlan <AT> gentoo.org>

 ...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-9999.ebuild             | 120 +++++++++++++++++++++
 4 files changed, 179 insertions(+)

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..446b8b7
--- /dev/null
+++ b/dev-util/valgrind/metadata.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE pkgmetadata SYSTEM "https://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-9999.ebuild 
b/dev-util/valgrind/valgrind-9999.ebuild
new file mode 100644
index 0000000..6d6dab4
--- /dev/null
+++ b/dev-util/valgrind/valgrind-9999.ebuild
@@ -0,0 +1,120 @@
+# Copyright 1999-2022 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="https://www.valgrind.org";
+LICENSE="GPL-2"
+SLOT="0"
+IUSE="mpi"
+
+if [[ ${PV} == "9999" ]]; then
+       EGIT_REPO_URI="https://github.com/petrpavlu/valgrind-riscv64";
+       EGIT_BRANCH="riscv64-linux"
+       inherit git-r3
+else
+       SRC_URI="https://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
+
+       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";
+}

Reply via email to