blob: 6fc2f3686874e18bcf9d53d53e97f0a0b34cb973 [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"
5LICENSE = "GPLv2 & GPLv2+ & BSD-3-Clause"
6LIC_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 \
22 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 \
33 file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \
34 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 \
42 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
43 file://s390x_vec_op_t.patch \
44 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
45 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
46 "
47SRC_URI[sha256sum] = "00859aa13a772eddf7822225f4b46ee0d39afbe071d32778da4d99984081f7f5"
48UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
49
50COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
51
52# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
53# argument. Change expected stderr files accordingly.
54do_patch:append() {
55 bb.build.exec_func('do_sed_paths', d)
56}
57
58do_sed_paths() {
59 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
60 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
61}
62
63# valgrind supports armv7 and above
64COMPATIBLE_HOST:armv4 = 'null'
65COMPATIBLE_HOST:armv5 = 'null'
66COMPATIBLE_HOST:armv6 = 'null'
67
68# valgrind fails with powerpc soft-float
69COMPATIBLE_HOST:powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
70
71# X32 isn't supported by valgrind at this time
72COMPATIBLE_HOST:linux-gnux32 = 'null'
73COMPATIBLE_HOST:linux-muslx32 = 'null'
74
75# Disable for some MIPS variants
76COMPATIBLE_HOST:mipsarchr6 = 'null'
77COMPATIBLE_HOST:linux-gnun32 = 'null'
78
79# Disable for powerpc64 with musl
80COMPATIBLE_HOST:libc-musl:powerpc64 = 'null'
81
82# brokenseip is unfortunately required by ptests to pass
83inherit autotools-brokensep ptest multilib_header
84
85EXTRA_OECONF = "--enable-tls --without-mpicc"
86EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
87
88# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
89EXTRA_OECONF:append:arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
90
91EXTRA_OEMAKE = "-w"
92
93CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
94
95# valgrind likes to control its own optimisation flags. It generally defaults
96# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
97# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
98# which fixes build path issue in DWARF.
99SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
100
101do_configure:prepend () {
102 rm -rf ${S}/config.h
103 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
104 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
105}
106
107do_install:append () {
108 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
109 oe_multilib_header valgrind/config.h
110}
111
112VALGRINDARCH ?= "${TARGET_ARCH}"
113VALGRINDARCH:aarch64 = "arm64"
114VALGRINDARCH:x86-64 = "amd64"
115VALGRINDARCH:x86 = "x86"
116VALGRINDARCH:mips = "mips32"
117VALGRINDARCH:mipsel = "mips32"
118VALGRINDARCH:mips64el = "mips64"
119VALGRINDARCH:powerpc = "ppc"
120VALGRINDARCH:powerpc64 = "ppc64"
121VALGRINDARCH:powerpc64le = "ppc64le"
122
123INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
124
125RDEPENDS:${PN} += "perl"
126
127# 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 \
132 gdb libgomp \
133 perl \
134 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
135 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
136 perl-module-carp perl-module-symbol \
137 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg"
138RDEPENDS:${PN}-ptest:append:libc-glibc = " glibc-utils"
139
140# One of the tests contains a bogus interpreter path on purpose.
141# Skip file dependency check
142SKIP_FILEDEPS:${PN}-ptest = '1'
143INSANE_SKIP:${PN}-ptest = "debug-deps"
144
145do_compile_ptest() {
146 oe_runmake check
147}
148
149do_install_ptest() {
150 chmod +x ${B}/tests/vg_regtest
151
152 # The test application binaries are not automatically installed.
153 # Grab them from the build directory.
154 #
155 # The regression tests require scripts and data files that are not
156 # copied to the build directory. They must be copied from the
157 # source directory.
158 saved_dir=$PWD
159 for parent_dir in ${S} ${B} ; do
160 cd $parent_dir
161
162 subdirs=" \
163 .in_place \
164 cachegrind/tests \
165 callgrind/tests \
166 dhat/tests \
167 drd/tests \
168 gdbserver_tests \
169 helgrind/tests \
170 lackey/tests \
171 massif/tests \
172 memcheck/tests \
173 none/tests \
174 tests \
175 exp-bbv/tests \
176 "
177 # Get the vg test scripts, filters, and expected files
178 for dir in $subdirs ; do
179 find $dir | cpio -pvdu ${D}${PTEST_PATH}
180 done
181 cd $saved_dir
182 done
183
184 # The scripts reference config.h so add it to the top ptest dir.
185 cp ${B}/config.h ${D}${PTEST_PATH}
186 install -D ${WORKDIR}/remove-for-aarch64 ${D}${PTEST_PATH}
187 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
188 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
189
190 # Add an executable need by none/tests/bigcode
191 mkdir ${D}${PTEST_PATH}/perf
192 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
193
194 # Add an executable needed by memcheck/tests/vcpu_bz2
195 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
196
197 # Make the ptest dir look like the top level valgrind src dir
198 # This is checked by the gdbserver_tests/make_local_links script
199 mkdir ${D}${PTEST_PATH}/coregrind
200 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
201
202 # Add an executable needed by massif tests
203 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
204
205 find ${D}${PTEST_PATH} \
206 \( \
207 -name "Makefile*" \
208 -o -name "*.o" \
209 \) \
210 -exec rm {} \;
211
212 # These files need to be newer so touch them.
213 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
214
215 # find *_annotate in ${bindir} for yocto build
216 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
217 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
218
219 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann1.vgtest
220 sed -i s:\.\./\.\./callgrind/callgrind_annotate:${bindir}/callgrind_annotate: ${D}${PTEST_PATH}/callgrind/tests/ann2.vgtest
221
222 # point the expanded @abs_top_builddir@ of the host to PTEST_PATH
223 sed -i s:${S}:${PTEST_PATH}:g \
224 ${D}${PTEST_PATH}/memcheck/tests/linux/debuginfod-check.vgtest
225
226 # handle multilib
227 sed -i s:@libdir@:${libdir}:g ${D}${PTEST_PATH}/run-ptest
228 sed -i s:@libexecdir@:${libexecdir}:g ${D}${PTEST_PATH}/run-ptest
229 sed -i s:@bindir@:${bindir}:g ${D}${PTEST_PATH}/run-ptest
230
231 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
232 # https://bugs.kde.org/show_bug.cgi?id=402833
233 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
234
235 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
236 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
237
238 # As the binary isn't stripped or debug-splitted, the source file isn't fetched
239 # via dwarfsrcfiles either, so it needs to be installed manually.
240 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
241 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
242}
243
244# avoid stripping some generated binaries otherwise some of the tests will fail
245# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
246INHIBIT_PACKAGE_STRIP_FILES += "\
247 ${PKGD}${PTEST_PATH}/none/tests/tls \
248 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
249 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
250 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
251 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
252 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
253"