blob: 3fa483d8bc0257c86a09627592eacb1ebdf5ea3d [file] [log] [blame]
Brad Bishopc342db32019-05-15 21:57:59 -04001SUMMARY = "Valgrind memory debugger and instrumentation framework"
2HOMEPAGE = "http://valgrind.org/"
Andrew Geissler90fd73c2021-03-05 15:25:55 -06003DESCRIPTION = "Valgrind is an instrumentation framework for building dynamic analysis tools. There are Valgrind tools that can automatically detect many memory management and threading bugs, and profile your programs in detail."
Brad Bishopc342db32019-05-15 21:57:59 -04004BUGTRACKER = "http://valgrind.org/support/bug_reports.html"
Andrew Geissler5199d832021-09-24 16:47:35 -05005LICENSE = "GPLv2 & GPLv2+ & BSD-3-Clause"
Brad Bishopc342db32019-05-15 21:57:59 -04006LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
Andrew Geissler4ed12e12020-06-05 18:00:41 -05007 file://include/pub_tool_basics.h;beginline=6;endline=29;md5=41c410e8d3f305aee7aaa666b2e4f366 \
Brad Bishopc342db32019-05-15 21:57:59 -04008 file://include/valgrind.h;beginline=1;endline=56;md5=ad3b317f3286b6b704575d9efe6ca5df \
9 file://COPYING.DOCS;md5=24ea4c7092233849b4394699333b5c56"
10
Brad Bishop96ff1982019-08-19 13:50:42 -040011DEPENDS = " \
Brad Bishopc342db32019-05-15 21:57:59 -040012 ${@bb.utils.contains('DISTRO_FEATURES', 'ptest', 'boost', '', d)} \
13 "
14
15SRC_URI = "https://sourceware.org/pub/valgrind/valgrind-${PV}.tar.bz2 \
16 file://fixed-perl-path.patch \
17 file://Added-support-for-PPC-instructions-mfatbu-mfatbl.patch \
18 file://run-ptest \
Brad Bishopa34c0302019-09-23 22:34:48 -040019 file://remove-for-aarch64 \
Andrew Geisslerd1e89492021-02-12 15:35:20 -060020 file://remove-for-all \
Andrew Geissler09036742021-06-25 14:25:14 -050021 file://taskset_nondeterministic_tests \
Brad Bishopc342db32019-05-15 21:57:59 -040022 file://0004-Fix-out-of-tree-builds.patch \
23 file://0005-Modify-vg_test-wrapper-to-support-PTEST-formats.patch \
24 file://0001-Remove-tests-that-fail-to-build-on-some-PPC32-config.patch \
25 file://use-appropriate-march-mcpu-mfpu-for-ARM-test-apps.patch \
26 file://avoid-neon-for-targets-which-don-t-support-it.patch \
27 file://valgrind-make-ld-XXX.so-strlen-intercept-optional.patch \
28 file://0001-makefiles-Drop-setting-mcpu-to-cortex-a8-on-arm-arch.patch \
29 file://0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch \
30 file://0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch \
31 file://0002-context-APIs-are-not-available-on-musl.patch \
32 file://0003-correct-include-directive-path-for-config.h.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040033 file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040034 file://0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch \
35 file://0002-memcheck-x86-Define-__THROW-if-not-defined.patch \
36 file://0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch \
37 file://0001-fix-opcode-not-supported-on-mips32-linux.patch \
38 file://0001-Guard-against-__GLIBC_PREREQ-for-musl-libc.patch \
39 file://0001-Make-local-functions-static-to-avoid-assembler-error.patch \
40 file://0001-Return-a-valid-exit_code-from-vg_regtest.patch \
41 file://0001-valgrind-filter_xml_frames-do-not-filter-usr.patch \
Andrew Geisslerc9f78652020-09-18 14:11:35 -050042 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050043 file://s390x_vec_op_t.patch \
44 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050045 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
Andrew Geisslerc926e172021-05-07 16:11:35 -050046 file://0001-Add-missing-musl.supp.patch \
47 file://0001-drd-tests-swapcontext-Add-SIGALRM-handler-to-avoid-s.patch \
Patrick Williams213cb262021-08-07 19:21:33 -050048 file://6da22a4d246519cd1a638cfc7eff00cdd74413c4.patch \
49 file://200b6a5a0ea3e1e154663b0fc575bfe2becf177d.patch \
50 file://a1364805fc74b5690f763033c0c9b43f27613572.patch \
51 file://52ed51fc35f8a6148c2940eb46932b02dd3b9b23.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040052 "
Andrew Geisslerc926e172021-05-07 16:11:35 -050053SRC_URI[md5sum] = "afe11b5572c3121a781433b7c0ab741b"
54SRC_URI[sha256sum] = "ad3aec668e813e40f238995f60796d9590eee64a16dff88421430630e69285a2"
Brad Bishopc342db32019-05-15 21:57:59 -040055UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
56
57COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
58
Andrew Geisslerc9f78652020-09-18 14:11:35 -050059# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
60# argument. Change expected stderr files accordingly.
Patrick Williams213cb262021-08-07 19:21:33 -050061do_patch:append() {
Andrew Geisslerc9f78652020-09-18 14:11:35 -050062 bb.build.exec_func('do_sed_paths', d)
63}
64
65do_sed_paths() {
66 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
67 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
68}
69
Brad Bishopc342db32019-05-15 21:57:59 -040070# valgrind supports armv7 and above
Patrick Williams213cb262021-08-07 19:21:33 -050071COMPATIBLE_HOST:armv4 = 'null'
72COMPATIBLE_HOST:armv5 = 'null'
73COMPATIBLE_HOST:armv6 = 'null'
Brad Bishopc342db32019-05-15 21:57:59 -040074
Andrew Geisslerd25ed322020-06-27 00:28:28 -050075# valgrind fails with powerpc soft-float
Patrick Williams213cb262021-08-07 19:21:33 -050076COMPATIBLE_HOST:powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
Andrew Geisslerd25ed322020-06-27 00:28:28 -050077
Brad Bishopc342db32019-05-15 21:57:59 -040078# X32 isn't supported by valgrind at this time
Patrick Williams213cb262021-08-07 19:21:33 -050079COMPATIBLE_HOST:linux-gnux32 = 'null'
80COMPATIBLE_HOST:linux-muslx32 = 'null'
Brad Bishopc342db32019-05-15 21:57:59 -040081
82# Disable for some MIPS variants
Patrick Williams213cb262021-08-07 19:21:33 -050083COMPATIBLE_HOST:mipsarchr6 = 'null'
84COMPATIBLE_HOST:linux-gnun32 = 'null'
Brad Bishopc342db32019-05-15 21:57:59 -040085
86# Disable for powerpc64 with musl
Patrick Williams213cb262021-08-07 19:21:33 -050087COMPATIBLE_HOST:libc-musl:powerpc64 = 'null'
Brad Bishopc342db32019-05-15 21:57:59 -040088
Andrew Geissler82c905d2020-04-13 13:39:40 -050089# brokenseip is unfortunately required by ptests to pass
90inherit autotools-brokensep ptest multilib_header
Brad Bishopc342db32019-05-15 21:57:59 -040091
92EXTRA_OECONF = "--enable-tls --without-mpicc"
93EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
94
95# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
Patrick Williams213cb262021-08-07 19:21:33 -050096EXTRA_OECONF:append:arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
Brad Bishopc342db32019-05-15 21:57:59 -040097
98EXTRA_OEMAKE = "-w"
99
100CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
101
102# valgrind likes to control its own optimisation flags. It generally defaults
103# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
104# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
105# which fixes build path issue in DWARF.
106SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
107
Patrick Williams213cb262021-08-07 19:21:33 -0500108do_configure:prepend () {
Brad Bishopc342db32019-05-15 21:57:59 -0400109 rm -rf ${S}/config.h
110 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
111 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
112}
113
Patrick Williams213cb262021-08-07 19:21:33 -0500114do_install:append () {
Andrew Geisslerc926e172021-05-07 16:11:35 -0500115 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
Brad Bishopc342db32019-05-15 21:57:59 -0400116 oe_multilib_header valgrind/config.h
117}
118
119VALGRINDARCH ?= "${TARGET_ARCH}"
Patrick Williams213cb262021-08-07 19:21:33 -0500120VALGRINDARCH:aarch64 = "arm64"
121VALGRINDARCH:x86-64 = "amd64"
122VALGRINDARCH:x86 = "x86"
123VALGRINDARCH:mips = "mips32"
124VALGRINDARCH:mipsel = "mips32"
125VALGRINDARCH:mips64el = "mips64"
126VALGRINDARCH:powerpc = "ppc"
127VALGRINDARCH:powerpc64 = "ppc64"
128VALGRINDARCH:powerpc64le = "ppc64le"
Brad Bishopc342db32019-05-15 21:57:59 -0400129
Andrew Geisslerc926e172021-05-07 16:11:35 -0500130INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
Brad Bishopc342db32019-05-15 21:57:59 -0400131
Patrick Williams213cb262021-08-07 19:21:33 -0500132RDEPENDS:${PN} += "perl"
Brad Bishopc342db32019-05-15 21:57:59 -0400133
134# valgrind needs debug information for ld.so at runtime in order to
135# redirect functions like strlen.
Patrick Williams213cb262021-08-07 19:21:33 -0500136RRECOMMENDS:${PN} += "${TCLIBC}-dbg"
Brad Bishopc342db32019-05-15 21:57:59 -0400137
Patrick Williams213cb262021-08-07 19:21:33 -0500138RDEPENDS:${PN}-ptest += " bash coreutils curl file \
Brad Bishopa34c0302019-09-23 22:34:48 -0400139 gdb libgomp \
140 perl \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500141 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
Andrew Geisslerc926e172021-05-07 16:11:35 -0500142 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
143 perl-module-carp perl-module-symbol \
144 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg"
Patrick Williams213cb262021-08-07 19:21:33 -0500145RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-utils"
Brad Bishopc342db32019-05-15 21:57:59 -0400146
147# One of the tests contains a bogus interpreter path on purpose.
148# Skip file dependency check
Patrick Williams213cb262021-08-07 19:21:33 -0500149SKIP_FILEDEPS:${PN}-ptest = '1'
150INSANE_SKIP:${PN}-ptest = "debug-deps"
Brad Bishopc342db32019-05-15 21:57:59 -0400151
152do_compile_ptest() {
153 oe_runmake check
154}
155
156do_install_ptest() {
157 chmod +x ${B}/tests/vg_regtest
158
159 # The test application binaries are not automatically installed.
160 # Grab them from the build directory.
161 #
162 # The regression tests require scripts and data files that are not
163 # copied to the build directory. They must be copied from the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500164 # source directory.
Brad Bishopc342db32019-05-15 21:57:59 -0400165 saved_dir=$PWD
166 for parent_dir in ${S} ${B} ; do
167 cd $parent_dir
168
Brad Bishopc342db32019-05-15 21:57:59 -0400169 subdirs=" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400170 .in_place \
Brad Bishopc342db32019-05-15 21:57:59 -0400171 cachegrind/tests \
172 callgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400173 dhat/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400174 drd/tests \
175 gdbserver_tests \
176 helgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400177 lackey/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400178 massif/tests \
179 memcheck/tests \
180 none/tests \
181 tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400182 exp-bbv/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400183 "
Brad Bishopc342db32019-05-15 21:57:59 -0400184 # Get the vg test scripts, filters, and expected files
185 for dir in $subdirs ; do
186 find $dir | cpio -pvdu ${D}${PTEST_PATH}
187 done
188 cd $saved_dir
189 done
190
Brad Bishopa34c0302019-09-23 22:34:48 -0400191 # The scripts reference config.h so add it to the top ptest dir.
192 cp ${B}/config.h ${D}${PTEST_PATH}
193 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600194 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
Andrew Geissler09036742021-06-25 14:25:14 -0500195 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
Brad Bishopa34c0302019-09-23 22:34:48 -0400196
197 # Add an executable need by none/tests/bigcode
198 mkdir ${D}${PTEST_PATH}/perf
199 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
200
201 # Add an executable needed by memcheck/tests/vcpu_bz2
202 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
203
204 # Make the ptest dir look like the top level valgrind src dir
205 # This is checked by the gdbserver_tests/make_local_links script
206 mkdir ${D}${PTEST_PATH}/coregrind
207 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
208
209 # Add an executable needed by massif tests
210 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
211
Brad Bishopc342db32019-05-15 21:57:59 -0400212 find ${D}${PTEST_PATH} \
Brad Bishopa34c0302019-09-23 22:34:48 -0400213 \( \
214 -name "Makefile*" \
Brad Bishopc342db32019-05-15 21:57:59 -0400215 -o -name "*.o" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400216 \) \
Brad Bishopc342db32019-05-15 21:57:59 -0400217 -exec rm {} \;
Brad Bishopa34c0302019-09-23 22:34:48 -0400218
219 # These files need to be newer so touch them.
Brad Bishop15ae2502019-06-18 21:44:24 -0400220 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
Brad Bishopc342db32019-05-15 21:57:59 -0400221
222 # find *_annotate in ${bindir} for yocto build
223 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
224 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
225
226 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
227 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
228
Andrew Geisslerc926e172021-05-07 16:11:35 -0500229 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
230 sed -i s:${S}:${PTEST_PATH}:g \
231 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
232
Brad Bishopc342db32019-05-15 21:57:59 -0400233 # handle multilib
234 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geisslerc926e172021-05-07 16:11:35 -0500235 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
Brad Bishopa34c0302019-09-23 22:34:48 -0400236 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geissler82c905d2020-04-13 13:39:40 -0500237
238 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
239 # https://bugs.kde.org/show_bug.cgi?id=402833
240 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
241
Andrew Geisslerc926e172021-05-07 16:11:35 -0500242 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
243 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
244
Andrew Geissler82c905d2020-04-13 13:39:40 -0500245 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
246 # via dwarfsrcfiles either, so it needs to be installed manually.
247 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
248 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
Brad Bishopc342db32019-05-15 21:57:59 -0400249}
Andrew Geissler82c905d2020-04-13 13:39:40 -0500250
251# avoid stripping some generated binaries otherwise some of the tests will fail
252# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
Andrew Geisslerc926e172021-05-07 16:11:35 -0500253INHIBIT_PACKAGE_STRIP_FILES += "\
Andrew Geissler82c905d2020-04-13 13:39:40 -0500254 ${PKGD}${PTEST_PATH}/none/tests/tls \
255 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
256 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
257 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
258 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
259 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
260"