blob: 74ac7ec9d5c6f1e4f7f85eb8ce59c51ea01886ca [file] [log] [blame]
Andrew Geisslereff27472021-10-29 15:35:00 -05001SUMMARY = "Valgrind memory debugger and instrumentation framework"
2HOMEPAGE = "http://valgrind.org/"
3DESCRIPTION = "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."
4BUGTRACKER = "http://valgrind.org/support/bug_reports.html"
Andrew Geissler7e0e3c02022-02-25 20:34:39 +00005LICENSE = "GPL-2.0-only & GPL-2.0-or-later & BSD-3-Clause"
Andrew Geisslereff27472021-10-29 15:35:00 -05006LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263 \
7 file://include/pub_tool_basics.h;beginline=6;endline=29;md5=41c410e8d3f305aee7aaa666b2e4f366 \
8 file://include/valgrind.h;beginline=1;endline=56;md5=ad3b317f3286b6b704575d9efe6ca5df \
9 file://COPYING.DOCS;md5=24ea4c7092233849b4394699333b5c56"
10
11DEPENDS = " \
12 ${@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 \
19 file://remove-for-aarch64 \
20 file://remove-for-all \
21 file://taskset_nondeterministic_tests \
Andrew Geisslereff27472021-10-29 15:35:00 -050022 file://0005-Modify-vg_test-wrapper-to-support-PTEST-formats.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050023 file://use-appropriate-march-mcpu-mfpu-for-ARM-test-apps.patch \
24 file://avoid-neon-for-targets-which-don-t-support-it.patch \
25 file://valgrind-make-ld-XXX.so-strlen-intercept-optional.patch \
26 file://0001-makefiles-Drop-setting-mcpu-to-cortex-a8-on-arm-arch.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050027 file://0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050028 file://0003-correct-include-directive-path-for-config.h.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050029 file://0001-Return-a-valid-exit_code-from-vg_regtest.patch \
30 file://0001-valgrind-filter_xml_frames-do-not-filter-usr.patch \
31 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
32 file://s390x_vec_op_t.patch \
33 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
34 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
Andrew Geissler595f6302022-01-24 19:11:47 +000035 file://0001-docs-Disable-manual-validation.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050036 "
Patrick Williams73bd93f2024-02-20 08:07:48 -060037SRC_URI[sha256sum] = "c811db5add2c5f729944caf47c4e7a65dcaabb9461e472b578765dd7bf6d2d4c"
Andrew Geisslereff27472021-10-29 15:35:00 -050038UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
39
40COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
41
42# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
43# argument. Change expected stderr files accordingly.
44do_patch:append() {
45 bb.build.exec_func('do_sed_paths', d)
46}
47
48do_sed_paths() {
49 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
50 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
51}
52
53# valgrind supports armv7 and above
54COMPATIBLE_HOST:armv4 = 'null'
55COMPATIBLE_HOST:armv5 = 'null'
56COMPATIBLE_HOST:armv6 = 'null'
57
58# valgrind fails with powerpc soft-float
59COMPATIBLE_HOST:powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
60
61# X32 isn't supported by valgrind at this time
62COMPATIBLE_HOST:linux-gnux32 = 'null'
63COMPATIBLE_HOST:linux-muslx32 = 'null'
64
65# Disable for some MIPS variants
66COMPATIBLE_HOST:mipsarchr6 = 'null'
67COMPATIBLE_HOST:linux-gnun32 = 'null'
68
69# Disable for powerpc64 with musl
70COMPATIBLE_HOST:libc-musl:powerpc64 = 'null'
71
72# brokenseip is unfortunately required by ptests to pass
73inherit autotools-brokensep ptest multilib_header
74
75EXTRA_OECONF = "--enable-tls --without-mpicc"
76EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
77
78# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
79EXTRA_OECONF:append:arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
80
81EXTRA_OEMAKE = "-w"
82
83CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
84
85# valgrind likes to control its own optimisation flags. It generally defaults
86# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
87# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
88# which fixes build path issue in DWARF.
89SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
90
Patrick Williamsac13d5f2023-11-24 18:59:46 -060091# Split out various helper scripts to separate packages to avoid the
92# main package depending on perl and python.
93PACKAGES =+ "${PN}-cachegrind ${PN}-massif ${PN}-callgrind"
94
95FILES:${PN}-cachegrind = "${bindir}/cg_*"
96FILES:${PN}-massif = "${bindir}/ms_*"
97FILES:${PN}-callgrind = "${bindir}/callgrind_*"
98
99RDEPENDS:${PN}-cachegrind = "${PN} python3-core"
100RDEPENDS:${PN}-massif = "${PN} perl"
101RDEPENDS:${PN}-callgrind = "${PN} perl"
102
Andrew Geisslereff27472021-10-29 15:35:00 -0500103do_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 () {
110 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
111 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:powerpc64le = "ppc64le"
124
125INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
126
Andrew Geisslereff27472021-10-29 15:35:00 -0500127# valgrind needs debug information for ld.so at runtime in order to
128# redirect functions like strlen.
129RRECOMMENDS:${PN} += "${TCLIBC}-dbg"
130
131RDEPENDS:${PN}-ptest += " bash coreutils curl file \
Patrick Williams73bd93f2024-02-20 08:07:48 -0600132 gdb \
133 ${TCLIBC}-src gcc-runtime-dbg \
134 libgomp \
Andrew Geisslereff27472021-10-29 15:35:00 -0500135 perl \
136 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
137 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
138 perl-module-carp perl-module-symbol \
Patrick Williams73bd93f2024-02-20 08:07:48 -0600139 procps \
140 python3-compile \
141 sed \
142 util-linux-taskset \
143 ${PN}-dbg ${PN}-src \
144 ${PN}-cachegrind ${PN}-massif ${PN}-callgrind \
145"
Andrew Geisslerfc113ea2023-03-31 09:59:46 -0500146RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-utils glibc-gconv-utf-32"
Andrew Geisslereff27472021-10-29 15:35:00 -0500147
148# One of the tests contains a bogus interpreter path on purpose.
149# Skip file dependency check
150SKIP_FILEDEPS:${PN}-ptest = '1'
151INSANE_SKIP:${PN}-ptest = "debug-deps"
152
153do_compile_ptest() {
Andrew Geissler615f2f12022-07-15 14:00:58 -0500154 oe_runmake check
Andrew Geisslereff27472021-10-29 15:35:00 -0500155}
156
Patrick Williams03907ee2022-05-01 06:28:52 -0500157
Andrew Geisslereff27472021-10-29 15:35:00 -0500158do_install_ptest() {
159 chmod +x ${B}/tests/vg_regtest
160
161 # The test application binaries are not automatically installed.
162 # Grab them from the build directory.
163 #
164 # The regression tests require scripts and data files that are not
165 # copied to the build directory. They must be copied from the
166 # source directory.
167 saved_dir=$PWD
168 for parent_dir in ${S} ${B} ; do
169 cd $parent_dir
170
171 subdirs=" \
172 .in_place \
173 cachegrind/tests \
174 callgrind/tests \
175 dhat/tests \
176 drd/tests \
177 gdbserver_tests \
178 helgrind/tests \
179 lackey/tests \
180 massif/tests \
181 memcheck/tests \
182 none/tests \
183 tests \
184 exp-bbv/tests \
185 "
186 # Get the vg test scripts, filters, and expected files
187 for dir in $subdirs ; do
188 find $dir | cpio -pvdu ${D}${PTEST_PATH}
189 done
190 cd $saved_dir
191 done
192
193 # The scripts reference config.h so add it to the top ptest dir.
194 cp ${B}/config.h ${D}${PTEST_PATH}
195 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
196 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
197 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
198
199 # Add an executable need by none/tests/bigcode
200 mkdir ${D}${PTEST_PATH}/perf
201 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
202
203 # Add an executable needed by memcheck/tests/vcpu_bz2
204 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
205
206 # Make the ptest dir look like the top level valgrind src dir
207 # This is checked by the gdbserver_tests/make_local_links script
208 mkdir ${D}${PTEST_PATH}/coregrind
209 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
210
211 # Add an executable needed by massif tests
212 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
213
214 find ${D}${PTEST_PATH} \
215 \( \
216 -name "Makefile*" \
217 -o -name "*.o" \
218 \) \
219 -exec rm {} \;
220
Andrew Geisslereff27472021-10-29 15:35:00 -0500221 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
222 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
223
224 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
225 sed -i s:${S}:${PTEST_PATH}:g \
226 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
227
228 # handle multilib
229 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
230 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
231 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
232
Patrick Williams73bd93f2024-02-20 08:07:48 -0600233 # enable cachegrind ptests
234 ln -s ${bindir}/cg_annotate ${D}/${PTEST_PATH}/cachegrind/cg_annotate
235 ln -s ${bindir}/cg_diff ${D}/${PTEST_PATH}/cachegrind/cg_diff
236 ln -s ${bindir}/cg_merge ${D}/${PTEST_PATH}/cachegrind/cg_merge
237
Andrew Geisslereff27472021-10-29 15:35:00 -0500238 # 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
242 # 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
Patrick Williams03907ee2022-05-01 06:28:52 -0500245 # https://bugs.kde.org/show_bug.cgi?id=445743
246 rm ${D}${PTEST_PATH}/drd/tests/pth_mutex_signal
247
Andrew Geisslereff27472021-10-29 15:35:00 -0500248 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
249 # via dwarfsrcfiles either, so it needs to be installed manually.
Patrick Williamsac13d5f2023-11-24 18:59:46 -0600250 mkdir -p ${D}${TARGET_DBGSRC_DIR}/none/tests/
251 install ${S}/none/tests/tls.c ${D}${TARGET_DBGSRC_DIR}/none/tests/
Andrew Geisslereff27472021-10-29 15:35:00 -0500252}
253
Andrew Geissler517393d2023-01-13 08:55:19 -0600254do_install_ptest:append:x86-64 () {
255 # https://bugs.kde.org/show_bug.cgi?id=463456
256 rm ${D}${PTEST_PATH}/memcheck/tests/origin6-fp.vgtest
257 # https://bugs.kde.org/show_bug.cgi?id=463458
258 rm ${D}${PTEST_PATH}/memcheck/tests/vcpu_fnfns.vgtest
259 # https://bugs.kde.org/show_bug.cgi?id=463463
260 rm ${D}${PTEST_PATH}/none/tests/amd64/fma.vgtest
261}
262
Andrew Geisslereff27472021-10-29 15:35:00 -0500263# avoid stripping some generated binaries otherwise some of the tests will fail
264# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
265INHIBIT_PACKAGE_STRIP_FILES += "\
266 ${PKGD}${PTEST_PATH}/none/tests/tls \
267 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
268 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
269 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
270 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
271 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
272"