blob: ebbd83dd3f4986a68997075922238009217b7321 [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 \
Brad Bishopc342db32019-05-15 21:57:59 -040021 file://0004-Fix-out-of-tree-builds.patch \
22 file://0005-Modify-vg_test-wrapper-to-support-PTEST-formats.patch \
23 file://0001-Remove-tests-that-fail-to-build-on-some-PPC32-config.patch \
24 file://use-appropriate-march-mcpu-mfpu-for-ARM-test-apps.patch \
25 file://avoid-neon-for-targets-which-don-t-support-it.patch \
26 file://valgrind-make-ld-XXX.so-strlen-intercept-optional.patch \
27 file://0001-makefiles-Drop-setting-mcpu-to-cortex-a8-on-arm-arch.patch \
28 file://0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch \
29 file://0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch \
30 file://0002-context-APIs-are-not-available-on-musl.patch \
31 file://0003-correct-include-directive-path-for-config.h.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040032 file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040033 file://0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch \
34 file://0002-memcheck-x86-Define-__THROW-if-not-defined.patch \
35 file://0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch \
36 file://0001-fix-opcode-not-supported-on-mips32-linux.patch \
37 file://0001-Guard-against-__GLIBC_PREREQ-for-musl-libc.patch \
38 file://0001-Make-local-functions-static-to-avoid-assembler-error.patch \
39 file://0001-Return-a-valid-exit_code-from-vg_regtest.patch \
40 file://0001-valgrind-filter_xml_frames-do-not-filter-usr.patch \
Andrew Geisslerc9f78652020-09-18 14:11:35 -050041 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050042 file://s390x_vec_op_t.patch \
43 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
Andrew Geissler82c905d2020-04-13 13:39:40 -050044 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
Andrew Geisslerc926e172021-05-07 16:11:35 -050045 file://0001-Add-missing-musl.supp.patch \
46 file://0001-drd-tests-swapcontext-Add-SIGALRM-handler-to-avoid-s.patch \
Brad Bishopc342db32019-05-15 21:57:59 -040047 "
Andrew Geisslerc926e172021-05-07 16:11:35 -050048SRC_URI[md5sum] = "afe11b5572c3121a781433b7c0ab741b"
49SRC_URI[sha256sum] = "ad3aec668e813e40f238995f60796d9590eee64a16dff88421430630e69285a2"
Brad Bishopc342db32019-05-15 21:57:59 -040050UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
51
52COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
53
Andrew Geisslerc9f78652020-09-18 14:11:35 -050054# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
55# argument. Change expected stderr files accordingly.
56do_patch_append() {
57 bb.build.exec_func('do_sed_paths', d)
58}
59
60do_sed_paths() {
61 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
62 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
63}
64
Brad Bishopc342db32019-05-15 21:57:59 -040065# valgrind supports armv7 and above
66COMPATIBLE_HOST_armv4 = 'null'
67COMPATIBLE_HOST_armv5 = 'null'
68COMPATIBLE_HOST_armv6 = 'null'
69
Andrew Geisslerd25ed322020-06-27 00:28:28 -050070# valgrind fails with powerpc soft-float
71COMPATIBLE_HOST_powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
72
Brad Bishopc342db32019-05-15 21:57:59 -040073# X32 isn't supported by valgrind at this time
74COMPATIBLE_HOST_linux-gnux32 = 'null'
75COMPATIBLE_HOST_linux-muslx32 = 'null'
76
77# Disable for some MIPS variants
78COMPATIBLE_HOST_mipsarchr6 = 'null'
79COMPATIBLE_HOST_linux-gnun32 = 'null'
80
81# Disable for powerpc64 with musl
82COMPATIBLE_HOST_libc-musl_powerpc64 = 'null'
83
Andrew Geissler82c905d2020-04-13 13:39:40 -050084# brokenseip is unfortunately required by ptests to pass
85inherit autotools-brokensep ptest multilib_header
Brad Bishopc342db32019-05-15 21:57:59 -040086
87EXTRA_OECONF = "--enable-tls --without-mpicc"
88EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
89
90# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
91EXTRA_OECONF_append_arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
92
93EXTRA_OEMAKE = "-w"
94
95CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
96
97# valgrind likes to control its own optimisation flags. It generally defaults
98# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
99# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
100# which fixes build path issue in DWARF.
101SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
102
103do_configure_prepend () {
104 rm -rf ${S}/config.h
105 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
106 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
107}
108
109do_install_append () {
Andrew Geisslerc926e172021-05-07 16:11:35 -0500110 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
Brad Bishopc342db32019-05-15 21:57:59 -0400111 oe_multilib_header valgrind/config.h
112}
113
114VALGRINDARCH ?= "${TARGET_ARCH}"
115VALGRINDARCH_aarch64 = "arm64"
116VALGRINDARCH_x86-64 = "amd64"
117VALGRINDARCH_x86 = "x86"
118VALGRINDARCH_mips = "mips32"
119VALGRINDARCH_mipsel = "mips32"
120VALGRINDARCH_mips64el = "mips64"
121VALGRINDARCH_powerpc = "ppc"
122VALGRINDARCH_powerpc64 = "ppc64"
123VALGRINDARCH_powerpc64el = "ppc64le"
124
Andrew Geisslerc926e172021-05-07 16:11:35 -0500125INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
Brad Bishopc342db32019-05-15 21:57:59 -0400126
127RDEPENDS_${PN} += "perl"
128
129# valgrind needs debug information for ld.so at runtime in order to
130# redirect functions like strlen.
131RRECOMMENDS_${PN} += "${TCLIBC}-dbg"
132
Brad Bishopa34c0302019-09-23 22:34:48 -0400133RDEPENDS_${PN}-ptest += " bash coreutils file \
134 gdb libgomp \
135 perl \
Andrew Geisslerc9f78652020-09-18 14:11:35 -0500136 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
Andrew Geisslerc926e172021-05-07 16:11:35 -0500137 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
138 perl-module-carp perl-module-symbol \
139 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg"
Brad Bishopc342db32019-05-15 21:57:59 -0400140RDEPENDS_${PN}-ptest_append_libc-glibc = " glibc-utils"
141
142# One of the tests contains a bogus interpreter path on purpose.
143# Skip file dependency check
144SKIP_FILEDEPS_${PN}-ptest = '1'
145INSANE_SKIP_${PN}-ptest = "debug-deps"
146
147do_compile_ptest() {
148 oe_runmake check
149}
150
151do_install_ptest() {
152 chmod +x ${B}/tests/vg_regtest
153
154 # The test application binaries are not automatically installed.
155 # Grab them from the build directory.
156 #
157 # The regression tests require scripts and data files that are not
158 # copied to the build directory. They must be copied from the
Andrew Geisslerc926e172021-05-07 16:11:35 -0500159 # source directory.
Brad Bishopc342db32019-05-15 21:57:59 -0400160 saved_dir=$PWD
161 for parent_dir in ${S} ${B} ; do
162 cd $parent_dir
163
Brad Bishopc342db32019-05-15 21:57:59 -0400164 subdirs=" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400165 .in_place \
Brad Bishopc342db32019-05-15 21:57:59 -0400166 cachegrind/tests \
167 callgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400168 dhat/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400169 drd/tests \
170 gdbserver_tests \
171 helgrind/tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400172 lackey/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400173 massif/tests \
174 memcheck/tests \
175 none/tests \
176 tests \
Brad Bishopa34c0302019-09-23 22:34:48 -0400177 exp-bbv/tests \
Brad Bishopc342db32019-05-15 21:57:59 -0400178 "
Brad Bishopc342db32019-05-15 21:57:59 -0400179 # Get the vg test scripts, filters, and expected files
180 for dir in $subdirs ; do
181 find $dir | cpio -pvdu ${D}${PTEST_PATH}
182 done
183 cd $saved_dir
184 done
185
Brad Bishopa34c0302019-09-23 22:34:48 -0400186 # The scripts reference config.h so add it to the top ptest dir.
187 cp ${B}/config.h ${D}${PTEST_PATH}
188 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
Andrew Geisslerd1e89492021-02-12 15:35:20 -0600189 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
Brad Bishopa34c0302019-09-23 22:34:48 -0400190
191 # Add an executable need by none/tests/bigcode
192 mkdir ${D}${PTEST_PATH}/perf
193 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
194
195 # Add an executable needed by memcheck/tests/vcpu_bz2
196 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
197
198 # Make the ptest dir look like the top level valgrind src dir
199 # This is checked by the gdbserver_tests/make_local_links script
200 mkdir ${D}${PTEST_PATH}/coregrind
201 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
202
203 # Add an executable needed by massif tests
204 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
205
Brad Bishopc342db32019-05-15 21:57:59 -0400206 find ${D}${PTEST_PATH} \
Brad Bishopa34c0302019-09-23 22:34:48 -0400207 \( \
208 -name "Makefile*" \
Brad Bishopc342db32019-05-15 21:57:59 -0400209 -o -name "*.o" \
Brad Bishopa34c0302019-09-23 22:34:48 -0400210 \) \
Brad Bishopc342db32019-05-15 21:57:59 -0400211 -exec rm {} \;
Brad Bishopa34c0302019-09-23 22:34:48 -0400212
213 # These files need to be newer so touch them.
Brad Bishop15ae2502019-06-18 21:44:24 -0400214 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
Brad Bishopc342db32019-05-15 21:57:59 -0400215
216 # find *_annotate in ${bindir} for yocto build
217 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
218 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
219
220 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
221 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
222
Andrew Geisslerc926e172021-05-07 16:11:35 -0500223 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
224 sed -i s:${S}:${PTEST_PATH}:g \
225 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
226
Brad Bishopc342db32019-05-15 21:57:59 -0400227 # handle multilib
228 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geisslerc926e172021-05-07 16:11:35 -0500229 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
Brad Bishopa34c0302019-09-23 22:34:48 -0400230 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
Andrew Geissler82c905d2020-04-13 13:39:40 -0500231
232 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
233 # https://bugs.kde.org/show_bug.cgi?id=402833
234 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
235
Andrew Geisslerc926e172021-05-07 16:11:35 -0500236 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
237 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
238
Andrew Geissler82c905d2020-04-13 13:39:40 -0500239 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
240 # via dwarfsrcfiles either, so it needs to be installed manually.
241 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
242 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
Brad Bishopc342db32019-05-15 21:57:59 -0400243}
Andrew Geissler82c905d2020-04-13 13:39:40 -0500244
245# avoid stripping some generated binaries otherwise some of the tests will fail
246# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
Andrew Geisslerc926e172021-05-07 16:11:35 -0500247INHIBIT_PACKAGE_STRIP_FILES += "\
Andrew Geissler82c905d2020-04-13 13:39:40 -0500248 ${PKGD}${PTEST_PATH}/none/tests/tls \
249 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
250 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
251 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
252 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
253 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
254"