blob: 60b248681ed2dce563d9ff51fac2d19c1f3348eb [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"
5LICENSE = "GPLv2 & GPLv2+ & BSD"
6LIC_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 \
Brad Bishopc342db32019-05-15 21:57:59 -040048 "
Andrew Geisslerc926e172021-05-07 16:11:35 -050049SRC_URI[md5sum] = "afe11b5572c3121a781433b7c0ab741b"
50SRC_URI[sha256sum] = "ad3aec668e813e40f238995f60796d9590eee64a16dff88421430630e69285a2"
Brad Bishopc342db32019-05-15 21:57:59 -040051UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
52
53COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
54
Andrew Geisslerc9f78652020-09-18 14:11:35 -050055# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
56# argument. Change expected stderr files accordingly.
57do_patch_append() {
58 bb.build.exec_func('do_sed_paths', d)
59}
60
61do_sed_paths() {
62 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
63 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
64}
65
Brad Bishopc342db32019-05-15 21:57:59 -040066# valgrind supports armv7 and above
67COMPATIBLE_HOST_armv4 = 'null'
68COMPATIBLE_HOST_armv5 = 'null'
69COMPATIBLE_HOST_armv6 = 'null'
70
Andrew Geisslerd25ed322020-06-27 00:28:28 -050071# valgrind fails with powerpc soft-float
72COMPATIBLE_HOST_powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
73
Brad Bishopc342db32019-05-15 21:57:59 -040074# X32 isn't supported by valgrind at this time
75COMPATIBLE_HOST_linux-gnux32 = 'null'
76COMPATIBLE_HOST_linux-muslx32 = 'null'
77
78# Disable for some MIPS variants
79COMPATIBLE_HOST_mipsarchr6 = 'null'
80COMPATIBLE_HOST_linux-gnun32 = 'null'
81
82# Disable for powerpc64 with musl
83COMPATIBLE_HOST_libc-musl_powerpc64 = 'null'
84
Andrew Geissler82c905d2020-04-13 13:39:40 -050085# brokenseip is unfortunately required by ptests to pass
86inherit autotools-brokensep ptest multilib_header
Brad Bishopc342db32019-05-15 21:57:59 -040087
88EXTRA_OECONF = "--enable-tls --without-mpicc"
89EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
90
91# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
92EXTRA_OECONF_append_arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
93
94EXTRA_OEMAKE = "-w"
95
96CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
97
98# valgrind likes to control its own optimisation flags. It generally defaults
99# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
100# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
101# which fixes build path issue in DWARF.
102SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
103
104do_configure_prepend () {
105 rm -rf ${S}/config.h
106 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
107 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
108}
109
110do_install_append () {
Andrew Geisslerc926e172021-05-07 16:11:35 -0500111 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
Brad Bishopc342db32019-05-15 21:57:59 -0400112 oe_multilib_header valgrind/config.h
113}
114
115VALGRINDARCH ?= "${TARGET_ARCH}"
116VALGRINDARCH_aarch64 = "arm64"
117VALGRINDARCH_x86-64 = "amd64"
118VALGRINDARCH_x86 = "x86"
119VALGRINDARCH_mips = "mips32"
120VALGRINDARCH_mipsel = "mips32"
121VALGRINDARCH_mips64el = "mips64"
122VALGRINDARCH_powerpc = "ppc"
123VALGRINDARCH_powerpc64 = "ppc64"
Andrew Geissler09036742021-06-25 14:25:14 -0500124VALGRINDARCH_powerpc64le = "ppc64le"
Brad Bishopc342db32019-05-15 21:57:59 -0400125
Andrew Geisslerc926e172021-05-07 16:11:35 -0500126INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
Brad Bishopc342db32019-05-15 21:57:59 -0400127
128RDEPENDS_${PN} += "perl"
129
130# valgrind needs debug information for ld.so at runtime in order to
131# redirect functions like strlen.
132RRECOMMENDS_${PN} += "${TCLIBC}-dbg"
133
William A. Kennington IIIac69b482021-06-02 12:28:27 -0700134RDEPENDS_${PN}-ptest += " bash coreutils curl file \
Brad Bishopa34c0302019-09-23 22:34:48 -0400135 gdb libgomp \
136 perl \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500137 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
Andrew Geisslerc926e172021-05-07 16:11:35 -0500138 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
139 perl-module-carp perl-module-symbol \
140 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg"
Brad Bishopc342db32019-05-15 21:57:59 -0400141RDEPENDS_${PN}-ptest_append_libc-glibc = " glibc-utils"
142
143# One of the tests contains a bogus interpreter path on purpose.
144# Skip file dependency check
145SKIP_FILEDEPS_${PN}-ptest = '1'
146INSANE_SKIP_${PN}-ptest = "debug-deps"
147
148do_compile_ptest() {
149 oe_runmake check
150}
151
152do_install_ptest() {
153 chmod +x ${B}/tests/vg_regtest
154
155 # The test application binaries are not automatically installed.
156 # Grab them from the build directory.
157 #
158 # The regression tests require scripts and data files that are not
159 # copied to the build directory. They must be copied from the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500160 # source directory.
Brad Bishopc342db32019-05-15 21:57:59 -0400161 saved_dir=$PWD
162 for parent_dir in ${S} ${B} ; do
163 cd $parent_dir
164
Brad Bishopc342db32019-05-15 21:57:59 -0400165 subdirs=" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400166 .in_place \
Brad Bishopc342db32019-05-15 21:57:59 -0400167 cachegrind/tests \
168 callgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400169 dhat/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400170 drd/tests \
171 gdbserver_tests \
172 helgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400173 lackey/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400174 massif/tests \
175 memcheck/tests \
176 none/tests \
177 tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400178 exp-bbv/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400179 "
Brad Bishopc342db32019-05-15 21:57:59 -0400180 # Get the vg test scripts, filters, and expected files
181 for dir in $subdirs ; do
182 find $dir | cpio -pvdu ${D}${PTEST_PATH}
183 done
184 cd $saved_dir
185 done
186
Brad Bishopa34c0302019-09-23 22:34:48 -0400187 # The scripts reference config.h so add it to the top ptest dir.
188 cp ${B}/config.h ${D}${PTEST_PATH}
189 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600190 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
Andrew Geissler09036742021-06-25 14:25:14 -0500191 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
Brad Bishopa34c0302019-09-23 22:34:48 -0400192
193 # Add an executable need by none/tests/bigcode
194 mkdir ${D}${PTEST_PATH}/perf
195 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
196
197 # Add an executable needed by memcheck/tests/vcpu_bz2
198 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
199
200 # Make the ptest dir look like the top level valgrind src dir
201 # This is checked by the gdbserver_tests/make_local_links script
202 mkdir ${D}${PTEST_PATH}/coregrind
203 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
204
205 # Add an executable needed by massif tests
206 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
207
Brad Bishopc342db32019-05-15 21:57:59 -0400208 find ${D}${PTEST_PATH} \
Brad Bishopa34c0302019-09-23 22:34:48 -0400209 \( \
210 -name "Makefile*" \
Brad Bishopc342db32019-05-15 21:57:59 -0400211 -o -name "*.o" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400212 \) \
Brad Bishopc342db32019-05-15 21:57:59 -0400213 -exec rm {} \;
Brad Bishopa34c0302019-09-23 22:34:48 -0400214
215 # These files need to be newer so touch them.
Brad Bishop15ae2502019-06-18 21:44:24 -0400216 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
Brad Bishopc342db32019-05-15 21:57:59 -0400217
218 # find *_annotate in ${bindir} for yocto build
219 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
220 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
221
222 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
223 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
224
Andrew Geisslerc926e172021-05-07 16:11:35 -0500225 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
226 sed -i s:${S}:${PTEST_PATH}:g \
227 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
228
Brad Bishopc342db32019-05-15 21:57:59 -0400229 # handle multilib
230 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geisslerc926e172021-05-07 16:11:35 -0500231 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
Brad Bishopa34c0302019-09-23 22:34:48 -0400232 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geissler82c905d2020-04-13 13:39:40 -0500233
234 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
235 # https://bugs.kde.org/show_bug.cgi?id=402833
236 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
237
Andrew Geisslerc926e172021-05-07 16:11:35 -0500238 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
239 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
240
Andrew Geissler82c905d2020-04-13 13:39:40 -0500241 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
242 # via dwarfsrcfiles either, so it needs to be installed manually.
243 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
244 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
Brad Bishopc342db32019-05-15 21:57:59 -0400245}
Andrew Geissler82c905d2020-04-13 13:39:40 -0500246
247# avoid stripping some generated binaries otherwise some of the tests will fail
248# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
Andrew Geisslerc926e172021-05-07 16:11:35 -0500249INHIBIT_PACKAGE_STRIP_FILES += "\
Andrew Geissler82c905d2020-04-13 13:39:40 -0500250 ${PKGD}${PTEST_PATH}/none/tests/tls \
251 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
252 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
253 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
254 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
255 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
256"