PKGBUILDs/extra/valgrind/PKGBUILD
2023-07-02 03:06:16 +00:00

136 lines
5.1 KiB
Bash

# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>
# Contributor: Dan McGee <dan@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>
# README
# this package requires glibc-debug to run the check() function
# as -debug packages are not available in [core], it has to be applied manually
# whenever the tests shall run
#
# For a fresh build:
# $repo-x86_64-build -- -I ../../glibc/trunk/glibc-debug*.pkg.tar.zst
# $repo-x86_64-build
# ${repo}pkg
# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
# - hold for toolchain update
# - patch from Fedora for AArch64
# - removed lib32 package make/optdepends
noautobuild=1
pkgname=valgrind
pkgver=3.21.0
pkgrel=2
pkgdesc='Tool to help find memory-management problems in programs'
arch=('x86_64')
license=('GPL')
url='https://valgrind.org/'
depends=('glibc' 'perl' 'debuginfod')
makedepends=('gdb' 'docbook-xml'
'docbook-xsl' 'docbook-sgml')
checkdepends=('procps-ng')
provides=('valgrind-multilib')
replaces=('valgrind-multilib')
options=('!emptydirs' '!strip')
source=(https://sourceware.org/pub/valgrind/valgrind-${pkgver}.tar.bz2{,.asc}
valgrind-3.7.0-respect-flags.patch
fix-perl-errors.patch
valgrind-3.13.0-arm64-hwcap.patch)
validpgpkeys=(
0E9FFD0C16A1856CF9C7C690BA0166E698FA6035 # Julian Seward <jseward@acm.org>
EC3CFE88F6CA0788774F5C1D1AA44BE649DE760A # Mark Wielaard <mjw@gnu.org>
)
sha512sums=('3e86cda2f2d6cd30807fac7933ba2c46a97a2b4a868db989e6b0cceeadf029af7ee34ba900466a346948289aacb30f4399799bb83b97cc49a4d2d810441e5cfd'
'SKIP'
'e0cec39381cefeca09ae4794cca309dfac7c8693e6315e137e64f5c33684598726d41cfbb4edf764fe985503b13ff596184ca5fc32b159d500ec092e4cf8838c'
'20b251bfc7bef8dfd232f9b679e907114c575299916164a608e2fe7fab5f30bf7241f25e37ab4194c56b0a21e682b3cea2fd892aab30fa2ce3863ef744f27f18'
'5af853399c6abdf8016fd1c2be854b3952b7d7e9ca16c870f84eed72e606e639d5f64de32e60105899f5201b53156380ae460111e05209e843301492742c9bfd')
b2sums=('1f7306d288eb5ecfb2b2f0b2dc68960ecd4a7213b96a2e4ecb9990a755e8c233b0e9d190c0f807019bde669f44a631c8dafe9eb521d739561e6f889f7bdaca5c'
'SKIP'
'af556fdf3c02e37892bfe9afebc954cf2f1b2fa9b75c1caacfa9f3b456ebc02bf078475f9ee30079b3af5d150d41415a947c3d04235c1ea8412cf92b959c484a'
'78e5ebeda69302ad380923fe0e76ef8fc3443ffa29cc3104fe629335c8ceda1b4198cb5c72bdefb0e47c77ea02d2ca7bfb478cbf8731f8ded0e0c7c5d83981ee'
'ff8cf51a6034c13ffbc412c387e83a32fa59f96e01be8faf6b52aa6d55bd5e5836c16d75f2291d87450709d0c75689b21870514006c603c6419940a9b977e609')
options=(!lto) # https://bugs.kde.org/show_bug.cgi?id=338252
prepare() {
cd valgrind-${pkgver}
patch -Np1 < ../valgrind-3.7.0-respect-flags.patch
patch -Np1 < ../valgrind-3.13.0-arm64-hwcap.patch
sed -i 's|sgml/docbook/xsl-stylesheets|xml/docbook/xsl-stylesheets-1.79.2-nons|' docs/Makefile.am
patch -p1 -i ../fix-perl-errors.patch # https://bugs.kde.org/show_bug.cgi?id=470121
autoreconf -ifv
}
build() {
# valgrind does not like some of our flags
CPPFLAGS=${CPPFLAGS/-D_FORTIFY_SOURCE=2/}
CFLAGS=${CFLAGS/-fstack-protector-strong -fno-plt/}
CXXFLAGS=${CXXFLAGS/-fstack-protector-strong -fno-plt/}
cd valgrind-${pkgver}
./configure \
--prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--libexecdir=/usr/lib \
--mandir=/usr/share/man
make
make -C docs man-pages
}
check() {
# only run if glibc-debug is supplied manually
if ! pacman -Q glibc-debug; then echo -e "\033[1;31mcheck() not run, supply glibc-debug if unintended!\033[0m"; return 0; fi
cd valgrind-${pkgver}
# Make sure a basic binary runs. There should be no errors.
./vg-in-place --error-exitcode=1 /bin/true
# Make sure no extra FLAGS leak through, the testsuite
# sets all flags necessary. See also configure above.
make check CPPFLAGS= CFLAGS= CXXFLAGS= LDFLAGS=
# XXX: run full regtest but only report issues some tests fail duo
# current toolchain and expectations, take a manual look if its fine
#echo "===============TESTING==================="
#make regtest || true
# Make sure test failures show up in build.log
# Gather up the diffs (at most the first 20 lines for each one)
#local f max_lines=20 diff_files=()
#mapfile -d '' diff_files < <(find . -name '*.diff' -print0 | sort -z)
#if (( ${#diff_files[@]} == 0 )); then
#echo "Congratulations, all tests passed!"
#else
#warning "Some tests failed!"
#for f in "${diff_files[@]}"; do
#echo "================================================="
#echo "${f}"
#echo "================================================="
#if (( $(wc -l < "${f}") < ${max_lines} )); then
#cat "${f}"
#else
#head -n ${max_lines} "${f}"
#echo "<truncated beyond ${max_lines} lines>"
#fi
#done | tee diffs
#fi
#echo "===============END TESTING==============="
}
package() {
cd valgrind-${pkgver}
make DESTDIR="${pkgdir}" install
install -Dm644 docs/*.1 -t "$pkgdir/usr/share/man/man1"
if check_option 'debug' n; then
find "${pkgdir}/usr/bin" -type f -executable -exec strip $STRIP_BINARIES {} + || :
fi
}
# vim: ts=2 sw=2 et: