blob: 0c297ad6b938d211e7b54a48c047deec340e9d8f [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 \
22 file://0004-Fix-out-of-tree-builds.patch \
23 file://0005-Modify-vg_test-wrapper-to-support-PTEST-formats.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050024 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 \
32 file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \
33 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 \
41 file://0001-memcheck-vgtests-remove-fullpath-after-flags.patch \
42 file://s390x_vec_op_t.patch \
43 file://0001-none-tests-fdleak_cmsg.stderr.exp-adjust-tmp-paths.patch \
44 file://0001-memcheck-tests-Fix-timerfd-syscall-test.patch \
Andrew Geissler595f6302022-01-24 19:11:47 +000045 file://0001-Implement-linux-rseq-syscall-as-ENOSYS.patch \
46 file://0001-docs-Disable-manual-validation.patch \
Andrew Geisslereff27472021-10-29 15:35:00 -050047 "
48SRC_URI[sha256sum] = "00859aa13a772eddf7822225f4b46ee0d39afbe071d32778da4d99984081f7f5"
49UPSTREAM_CHECK_REGEX = "valgrind-(?P<pver>\d+(\.\d+)+)\.tar"
50
51COMPATIBLE_HOST = '(i.86|x86_64|arm|aarch64|mips|powerpc|powerpc64).*-linux'
52
53# patch 0001-memcheck-vgtests-remove-fullpath-after-flags.patch removes relative path
54# argument. Change expected stderr files accordingly.
55do_patch:append() {
56 bb.build.exec_func('do_sed_paths', d)
57}
58
59do_sed_paths() {
60 sed -i -e 's|tests/||' ${S}/memcheck/tests/badfree3.stderr.exp
61 sed -i -e 's|tests/||' ${S}/memcheck/tests/varinfo5.stderr.exp
62}
63
64# valgrind supports armv7 and above
65COMPATIBLE_HOST:armv4 = 'null'
66COMPATIBLE_HOST:armv5 = 'null'
67COMPATIBLE_HOST:armv6 = 'null'
68
69# valgrind fails with powerpc soft-float
70COMPATIBLE_HOST:powerpc = "${@bb.utils.contains('TARGET_FPU', 'soft', 'null', '.*-linux', d)}"
71
72# X32 isn't supported by valgrind at this time
73COMPATIBLE_HOST:linux-gnux32 = 'null'
74COMPATIBLE_HOST:linux-muslx32 = 'null'
75
76# Disable for some MIPS variants
77COMPATIBLE_HOST:mipsarchr6 = 'null'
78COMPATIBLE_HOST:linux-gnun32 = 'null'
79
80# Disable for powerpc64 with musl
81COMPATIBLE_HOST:libc-musl:powerpc64 = 'null'
82
83# brokenseip is unfortunately required by ptests to pass
84inherit autotools-brokensep ptest multilib_header
85
86EXTRA_OECONF = "--enable-tls --without-mpicc"
87EXTRA_OECONF += "${@['--enable-only32bit','--enable-only64bit'][d.getVar('SITEINFO_BITS') != '32']}"
88
89# valgrind checks host_cpu "armv7*)", so we need to over-ride the autotools.bbclass default --host option
90EXTRA_OECONF:append:arm = " --host=armv7${HOST_VENDOR}-${HOST_OS}"
91
92EXTRA_OEMAKE = "-w"
93
94CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'"
95
96# valgrind likes to control its own optimisation flags. It generally defaults
97# to -O2 but uses -O0 for some specific test apps etc. Passing our own flags
98# (via CFLAGS) means we interfere with that. Only pass DEBUG_FLAGS to it
99# which fixes build path issue in DWARF.
100SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}"
101
102do_configure:prepend () {
103 rm -rf ${S}/config.h
104 sed -i -e 's:$(abs_top_builddir):$(pkglibdir)/ptest:g' ${S}/none/tests/Makefile.am
105 sed -i -e 's:$(top_builddir):$(pkglibdir)/ptest:g' ${S}/memcheck/tests/Makefile.am
106}
107
108do_install:append () {
109 install -m 644 ${B}/default.supp ${D}/${libexecdir}/valgrind/
110 oe_multilib_header valgrind/config.h
111}
112
113VALGRINDARCH ?= "${TARGET_ARCH}"
114VALGRINDARCH:aarch64 = "arm64"
115VALGRINDARCH:x86-64 = "amd64"
116VALGRINDARCH:x86 = "x86"
117VALGRINDARCH:mips = "mips32"
118VALGRINDARCH:mipsel = "mips32"
119VALGRINDARCH:mips64el = "mips64"
120VALGRINDARCH:powerpc = "ppc"
121VALGRINDARCH:powerpc64 = "ppc64"
122VALGRINDARCH:powerpc64le = "ppc64le"
123
124INHIBIT_PACKAGE_STRIP_FILES = "${PKGD}${libexecdir}/valgrind/vgpreload_memcheck-${VALGRINDARCH}-linux.so"
125
126RDEPENDS:${PN} += "perl"
127
128# valgrind needs debug information for ld.so at runtime in order to
129# redirect functions like strlen.
130RRECOMMENDS:${PN} += "${TCLIBC}-dbg"
131
132RDEPENDS:${PN}-ptest += " bash coreutils curl file \
133 gdb libgomp \
134 perl \
135 perl-module-file-basename perl-module-file-glob perl-module-getopt-long \
136 perl-module-overloading perl-module-cwd perl-module-ipc-open3 \
137 perl-module-carp perl-module-symbol \
Andrew Geissler595f6302022-01-24 19:11:47 +0000138 procps sed ${PN}-dbg ${PN}-src ${TCLIBC}-src gcc-runtime-dbg \
139 util-linux-taskset"
Andrew Geisslereff27472021-10-29 15:35:00 -0500140RDEPENDS:${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
159 # source directory.
160 saved_dir=$PWD
161 for parent_dir in ${S} ${B} ; do
162 cd $parent_dir
163
164 subdirs=" \
165 .in_place \
166 cachegrind/tests \
167 callgrind/tests \
168 dhat/tests \
169 drd/tests \
170 gdbserver_tests \
171 helgrind/tests \
172 lackey/tests \
173 massif/tests \
174 memcheck/tests \
175 none/tests \
176 tests \
177 exp-bbv/tests \
178 "
179 # 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
186 # 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}
189 install -D ${WORKDIR}/remove-for-all ${D}${PTEST_PATH}
190 install -D ${WORKDIR}/taskset_nondeterministic_tests ${D}${PTEST_PATH}
191
192 # Add an executable need by none/tests/bigcode
193 mkdir ${D}${PTEST_PATH}/perf
194 cp ${B}/perf/bigcode ${D}${PTEST_PATH}/perf
195
196 # Add an executable needed by memcheck/tests/vcpu_bz2
197 cp ${B}/perf/bz2 ${D}${PTEST_PATH}/perf
198
199 # Make the ptest dir look like the top level valgrind src dir
200 # This is checked by the gdbserver_tests/make_local_links script
201 mkdir ${D}${PTEST_PATH}/coregrind
202 cp ${B}/coregrind/vgdb ${D}${PTEST_PATH}/coregrind
203
204 # Add an executable needed by massif tests
205 cp ${B}/massif/ms_print ${D}${PTEST_PATH}/massif/ms_print
206
207 find ${D}${PTEST_PATH} \
208 \( \
209 -name "Makefile*" \
210 -o -name "*.o" \
211 \) \
212 -exec rm {} \;
213
214 # These files need to be newer so touch them.
215 touch ${D}${PTEST_PATH}/cachegrind/tests/a.c -r ${D}${PTEST_PATH}/cachegrind/tests/cgout-test
216
217 # find *_annotate in ${bindir} for yocto build
218 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann1.vgtest
219 sed -i s:\.\./\.\./cachegrind/cg_annotate:${bindir}/cg_annotate: ${D}${PTEST_PATH}/cachegrind/tests/ann2.vgtest
220
221 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
233 # This test fails on the host as well, using both 3.15 and git master (as of Jan 24 2020)
234 # https://bugs.kde.org/show_bug.cgi?id=402833
235 rm ${D}${PTEST_PATH}/memcheck/tests/overlap.vgtest
236
237 # This is known failure see https://bugs.kde.org/show_bug.cgi?id=435732
238 rm ${D}${PTEST_PATH}/memcheck/tests/leak_cpp_interior.vgtest
239
240 # 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.
242 mkdir -p ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
243 install ${S}/none/tests/tls.c ${D}/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}/${BP}/none/tests/
244}
245
246# avoid stripping some generated binaries otherwise some of the tests will fail
247# run-strip-reloc.sh, run-strip-strmerge.sh and so on will fail
248INHIBIT_PACKAGE_STRIP_FILES += "\
249 ${PKGD}${PTEST_PATH}/none/tests/tls \
250 ${PKGD}${PTEST_PATH}/none/tests/tls.so \
251 ${PKGD}${PTEST_PATH}/none/tests/tls2.so \
252 ${PKGD}${PTEST_PATH}/helgrind/tests/tc09_bad_unlock \
253 ${PKGD}${PTEST_PATH}/memcheck/tests/manuel1 \
254 ${PKGD}${PTEST_PATH}/drd/tests/pth_detached3 \
255"