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