blob: 701dbf38332ee2df103bb6cbf735cef04f999a43 [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 \
28 file://0002-context-APIs-are-not-available-on-musl.patch \
29 file://0003-correct-include-directive-path-for-config.h.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050030 file://0001-memcheck-arm64-Define-__THROW-if-not-already-defined.patch \
31 file://0002-memcheck-x86-Define-__THROW-if-not-defined.patch \
32 file://0003-tests-seg_override-Replace-__modify_ldt-with-syscall.patch \
33 file://0001-fix-opcode-not-supported-on-mips32-linux.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050034 file://0001-Make-local-functions-static-to-avoid-assembler-error.patch \
35 file://0001-Return-a-valid-exit_code-from-vg_regtest.patch \
36 file://0001-valgrind-filter_xml_frames-do-not-filter-usr.patch \
37 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
38 file://s390x_vec_op_t.patch \
39 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
40 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
Andrew Geissler595f6302022-01-24 19:11:47 +000041 file://0001-docs-Disable-manual-validation.patch \
Patrick Williamsb9af8752023-01-30 13:28:01 -060042 file://0001-drd-tests-Include-missing-cstdint.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050043 "
Patrick Williams2390b1b2022-11-03 13:47:49 -050044SRC_URI[sha256sum] = "8536c031dbe078d342f121fa881a9ecd205cb5a78e639005ad570011bdb9f3c6"
Andrew Geisslereff27472021-10-29 15:35:00 -050045UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
46
47COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
48
49# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
50# argument. Change expected stderr files accordingly.
51do_patch:append() {
52 bb.build.exec_func('do_sed_paths', d)
53}
54
55do_sed_paths() {
56 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
57 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
58}
59
60# valgrind supports armv7 and above
61COMPATIBLE_HOST:armv4 = 'null'
62COMPATIBLE_HOST:armv5 = 'null'
63COMPATIBLE_HOST:armv6 = 'null'
64
65# valgrind fails with powerpc soft-float
66COMPATIBLE_HOST:powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
67
68# X32 isn't supported by valgrind at this time
69COMPATIBLE_HOST:linux-gnux32 = 'null'
70COMPATIBLE_HOST:linux-muslx32 = 'null'
71
72# Disable for some MIPS variants
73COMPATIBLE_HOST:mipsarchr6 = 'null'
74COMPATIBLE_HOST:linux-gnun32 = 'null'
75
76# Disable for powerpc64 with musl
77COMPATIBLE_HOST:libc-musl:powerpc64 = 'null'
78
79# brokenseip is unfortunately required by ptests to pass
80inherit autotools-brokensep ptest multilib_header
81
82EXTRA_OECONF = "--enable-tls --without-mpicc"
83EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
84
85# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
86EXTRA_OECONF:append:arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
87
88EXTRA_OEMAKE = "-w"
89
90CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
91
92# valgrind likes to control its own optimisation flags. It generally defaults
93# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
94# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
95# which fixes build path issue in DWARF.
96SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
97
98do_configure:prepend () {
99 rm -rf ${S}/config.h
100 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
101 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
102}
103
104do_install:append () {
105 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
106 oe_multilib_header valgrind/config.h
107}
108
109VALGRINDARCH ?= "${TARGET_ARCH}"
110VALGRINDARCH:aarch64 = "arm64"
111VALGRINDARCH:x86-64 = "amd64"
112VALGRINDARCH:x86 = "x86"
113VALGRINDARCH:mips = "mips32"
114VALGRINDARCH:mipsel = "mips32"
115VALGRINDARCH:mips64el = "mips64"
116VALGRINDARCH:powerpc = "ppc"
117VALGRINDARCH:powerpc64 = "ppc64"
118VALGRINDARCH:powerpc64le = "ppc64le"
119
120INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
121
122RDEPENDS:${PN} += "perl"
123
124# valgrind needs debug information for ld.so at runtime in order to
125# redirect functions like strlen.
126RRECOMMENDS:${PN} += "${TCLIBC}-dbg"
127
128RDEPENDS:${PN}-ptest += " bash coreutils curl file \
129 gdb libgomp \
130 perl \
131 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
132 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
133 perl-module-carp perl-module-symbol \
Andrew Geissler595f6302022-01-24 19:11:47 +0000134 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg \
135 util-linux-taskset"
Andrew Geisslereff27472021-10-29 15:35:00 -0500136RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-utils"
137
138# One of the tests contains a bogus interpreter path on purpose.
139# Skip file dependency check
140SKIP_FILEDEPS:${PN}-ptest = '1'
141INSANE_SKIP:${PN}-ptest = "debug-deps"
142
143do_compile_ptest() {
Andrew Geissler615f2f12022-07-15 14:00:58 -0500144 oe_runmake check
Andrew Geisslereff27472021-10-29 15:35:00 -0500145}
146
Patrick Williams03907ee2022-05-01 06:28:52 -0500147
Andrew Geisslereff27472021-10-29 15:35:00 -0500148do_install_ptest() {
149 chmod +x ${B}/tests/vg_regtest
150
151 # The test application binaries are not automatically installed.
152 # Grab them from the build directory.
153 #
154 # The regression tests require scripts and data files that are not
155 # copied to the build directory. They must be copied from the
156 # source directory.
157 saved_dir=$PWD
158 for parent_dir in ${S} ${B} ; do
159 cd $parent_dir
160
161 subdirs=" \
162 .in_place \
163 cachegrind/tests \
164 callgrind/tests \
165 dhat/tests \
166 drd/tests \
167 gdbserver_tests \
168 helgrind/tests \
169 lackey/tests \
170 massif/tests \
171 memcheck/tests \
172 none/tests \
173 tests \
174 exp-bbv/tests \
175 "
176 # Get the vg test scripts, filters, and expected files
177 for dir in $subdirs ; do
178 find $dir | cpio -pvdu ${D}${PTEST_PATH}
179 done
180 cd $saved_dir
181 done
182
183 # The scripts reference config.h so add it to the top ptest dir.
184 cp ${B}/config.h ${D}${PTEST_PATH}
185 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
186 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
187 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
188
189 # Add an executable need by none/tests/bigcode
190 mkdir ${D}${PTEST_PATH}/perf
191 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
192
193 # Add an executable needed by memcheck/tests/vcpu_bz2
194 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
195
196 # Make the ptest dir look like the top level valgrind src dir
197 # This is checked by the gdbserver_tests/make_local_links script
198 mkdir ${D}${PTEST_PATH}/coregrind
199 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
200
201 # Add an executable needed by massif tests
202 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
203
204 find ${D}${PTEST_PATH} \
205 \( \
206 -name "Makefile*" \
207 -o -name "*.o" \
208 \) \
209 -exec rm {} \;
210
211 # These files need to be newer so touch them.
212 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
213
214 # find *_annotate in ${bindir} for yocto build
215 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
216 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
217
218 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
219 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
220
221 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
222 sed -i s:${S}:${PTEST_PATH}:g \
223 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
224
225 # handle multilib
226 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
227 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
228 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
229
230 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
231 # https://bugs.kde.org/show_bug.cgi?id=402833
232 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
233
234 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
235 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
236
Patrick Williams03907ee2022-05-01 06:28:52 -0500237 # https://bugs.kde.org/show_bug.cgi?id=445743
238 rm ${D}${PTEST_PATH}/drd/tests/pth_mutex_signal
239
Andrew Geisslereff27472021-10-29 15:35:00 -0500240 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
241 # via dwarfsrcfiles either, so it needs to be installed manually.
Patrick Williams92b42cb2022-09-03 06:53:57 -0500242 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/none/tests/
243 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/none/tests/
Andrew Geisslereff27472021-10-29 15:35:00 -0500244}
245
Andrew Geissler517393d2023-01-13 08:55:19 -0600246do_install_ptest:append:x86-64 () {
247 # https://bugs.kde.org/show_bug.cgi?id=463456
248 rm ${D}${PTEST_PATH}/memcheck/tests/origin6-fp.vgtest
249 # https://bugs.kde.org/show_bug.cgi?id=463458
250 rm ${D}${PTEST_PATH}/memcheck/tests/vcpu_fnfns.vgtest
251 # https://bugs.kde.org/show_bug.cgi?id=463463
252 rm ${D}${PTEST_PATH}/none/tests/amd64/fma.vgtest
253}
254
Andrew Geisslereff27472021-10-29 15:35:00 -0500255# avoid stripping some generated binaries otherwise some of the tests will fail
256# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
257INHIBIT_PACKAGE_STRIP_FILES += "\
258 ${PKGD}${PTEST_PATH}/none/tests/tls \
259 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
260 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
261 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
262 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
263 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
264"