diff options
author | Khem Raj <raj.khem@gmail.com> | 2017-06-12 07:59:05 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-13 10:46:34 +0100 |
commit | 98a967d10d11dd3d086604c822385a71b21031f9 (patch) | |
tree | 2f81f250edf796c854d1ed7de8a967d58ed86410 /meta | |
parent | 93ddbfd17ddcfb94d3dda9d68dab1e58ea618860 (diff) | |
download | poky-98a967d10d11dd3d086604c822385a71b21031f9.tar.gz |
valgrind: Fix ptest build with musl
musl unearthed a problem when building out of tree, config.h was being
used from $(srcdir) instead of generated config.h in $(builddir)
this assumed functions e.g. mallinfo() and more which are not in musl
as a result tests broke.
Also add fixes to build remaining tests when building on musl
pass -fno-pie as it cant use PIE especially in ptests/x86_64
(From OE-Core rev: 8ab1828f073b5eab606161681a5f260cc0e77bf1)
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
8 files changed, 275 insertions, 0 deletions
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch b/meta/recipes-devtools/valgrind/valgrind/0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch new file mode 100644 index 0000000000..27366153f7 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From 64ad2744acfb4fa40b1c114633a053f87125a203 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 00:46:39 -0700 | ||
4 | Subject: [PATCH 1/6] sigqueue: Rename _sifields to __si_fields on musl | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | memcheck/tests/linux/sigqueue.c | 5 +++++ | ||
11 | 1 file changed, 5 insertions(+) | ||
12 | |||
13 | diff --git a/memcheck/tests/linux/sigqueue.c b/memcheck/tests/linux/sigqueue.c | ||
14 | index d18bd72..acb7cba 100644 | ||
15 | --- a/memcheck/tests/linux/sigqueue.c | ||
16 | +++ b/memcheck/tests/linux/sigqueue.c | ||
17 | @@ -8,6 +8,11 @@ | ||
18 | #include <syscall.h> | ||
19 | #include <unistd.h> | ||
20 | |||
21 | +/* musl libc defines siginfo_t __si_fields instead of _sifields */ | ||
22 | +#if defined(__linux__) && !defined(__GLIBC__) | ||
23 | +#define _sifields __si_fields | ||
24 | +#endif | ||
25 | + | ||
26 | int main(int argc, char **argv) | ||
27 | { | ||
28 | siginfo_t *si; | ||
29 | -- | ||
30 | 2.13.1 | ||
31 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch b/meta/recipes-devtools/valgrind/valgrind/0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch new file mode 100644 index 0000000000..185b8f9e60 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch | |||
@@ -0,0 +1,39 @@ | |||
1 | From de692e359801a1f0488c76267e4f904dd2efe754 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 00:39:07 -0700 | ||
4 | Subject: [PATCH] str_tester.c: Limit rawmemchr() test to glibc | ||
5 | |||
6 | rawmemchr() is a GNU extention therefore mark it so | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | Upstream-Status: Pending | ||
11 | |||
12 | memcheck/tests/str_tester.c | 4 ++-- | ||
13 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
14 | |||
15 | diff --git a/memcheck/tests/str_tester.c b/memcheck/tests/str_tester.c | ||
16 | index 9f7790a..47e4b4a 100644 | ||
17 | --- a/memcheck/tests/str_tester.c | ||
18 | +++ b/memcheck/tests/str_tester.c | ||
19 | @@ -504,7 +504,7 @@ test_strchrnul (void) | ||
20 | #endif | ||
21 | |||
22 | // DDD: better done by testing for the function. | ||
23 | -#if !defined(__APPLE__) && !defined(__sun) | ||
24 | +#if !defined(__APPLE__) && !defined(__sun) && defined(__GLIBC__) | ||
25 | static void | ||
26 | test_rawmemchr (void) | ||
27 | { | ||
28 | @@ -1442,7 +1442,7 @@ main (void) | ||
29 | test_strchrnul (); | ||
30 | # endif | ||
31 | |||
32 | -# if !defined(__APPLE__) && !defined(__sun) | ||
33 | +# if !defined(__APPLE__) && !defined(__sun) && defined(__GLIBC__) | ||
34 | /* rawmemchr. */ | ||
35 | test_rawmemchr (); | ||
36 | # endif | ||
37 | -- | ||
38 | 2.13.1 | ||
39 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0002-context-APIs-are-not-available-on-musl.patch b/meta/recipes-devtools/valgrind/valgrind/0002-context-APIs-are-not-available-on-musl.patch new file mode 100644 index 0000000000..3f9f33b487 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0002-context-APIs-are-not-available-on-musl.patch | |||
@@ -0,0 +1,49 @@ | |||
1 | From 862b807076d57f2f58ed9d572ddac8bb402774a2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 01:01:10 -0700 | ||
4 | Subject: [PATCH 2/6] context APIs are not available on musl | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | memcheck/tests/linux/stack_changes.c | 7 ++++++- | ||
11 | 1 file changed, 6 insertions(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/memcheck/tests/linux/stack_changes.c b/memcheck/tests/linux/stack_changes.c | ||
14 | index a978fc2..ffb49c6 100644 | ||
15 | --- a/memcheck/tests/linux/stack_changes.c | ||
16 | +++ b/memcheck/tests/linux/stack_changes.c | ||
17 | @@ -10,6 +10,7 @@ | ||
18 | // This test is checking the libc context calls (setcontext, etc.) and | ||
19 | // checks that Valgrind notices their stack changes properly. | ||
20 | |||
21 | +#ifdef __GLIBC__ | ||
22 | typedef struct ucontext mycontext; | ||
23 | |||
24 | mycontext ctx1, ctx2, oldc; | ||
25 | @@ -51,9 +52,11 @@ int init_context(mycontext *uc) | ||
26 | |||
27 | return ret; | ||
28 | } | ||
29 | +#endif | ||
30 | |||
31 | int main(int argc, char **argv) | ||
32 | { | ||
33 | +#ifdef __GLIBC__ | ||
34 | int c1 = init_context(&ctx1); | ||
35 | int c2 = init_context(&ctx2); | ||
36 | |||
37 | @@ -66,6 +69,8 @@ int main(int argc, char **argv) | ||
38 | //free(ctx1.uc_stack.ss_sp); | ||
39 | VALGRIND_STACK_DEREGISTER(c2); | ||
40 | //free(ctx2.uc_stack.ss_sp); | ||
41 | - | ||
42 | +#else | ||
43 | + printf("libc context call APIs e.g. getcontext() are deprecated by posix\n"); | ||
44 | +#endif | ||
45 | return 0; | ||
46 | } | ||
47 | -- | ||
48 | 2.13.1 | ||
49 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0003-correct-include-directive-path-for-config.h.patch b/meta/recipes-devtools/valgrind/valgrind/0003-correct-include-directive-path-for-config.h.patch new file mode 100644 index 0000000000..c2965c40df --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0003-correct-include-directive-path-for-config.h.patch | |||
@@ -0,0 +1,45 @@ | |||
1 | From ecbdea7bd8b08205f1bc3f6b72d4b4a80f313fcb Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 01:03:17 -0700 | ||
4 | Subject: [PATCH 3/6] correct include directive path for config.h | ||
5 | |||
6 | when building out of source tree, it can not find | ||
7 | the generated config.h otherwise | ||
8 | |||
9 | Upstream-Status: Pending | ||
10 | |||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
12 | --- | ||
13 | memcheck/tests/linux/syscalls-2007.c | 2 +- | ||
14 | memcheck/tests/linux/syslog-syscall.c | 2 +- | ||
15 | 2 files changed, 2 insertions(+), 2 deletions(-) | ||
16 | |||
17 | diff --git a/memcheck/tests/linux/syscalls-2007.c b/memcheck/tests/linux/syscalls-2007.c | ||
18 | index b61c6d5..cc3fd62 100644 | ||
19 | --- a/memcheck/tests/linux/syscalls-2007.c | ||
20 | +++ b/memcheck/tests/linux/syscalls-2007.c | ||
21 | @@ -10,7 +10,7 @@ | ||
22 | |||
23 | #define _GNU_SOURCE | ||
24 | |||
25 | -#include "../../config.h" | ||
26 | +#include "config.h" | ||
27 | #include <fcntl.h> | ||
28 | #include <signal.h> | ||
29 | #include <stdint.h> | ||
30 | diff --git a/memcheck/tests/linux/syslog-syscall.c b/memcheck/tests/linux/syslog-syscall.c | ||
31 | index 1143722..21e758b 100644 | ||
32 | --- a/memcheck/tests/linux/syslog-syscall.c | ||
33 | +++ b/memcheck/tests/linux/syslog-syscall.c | ||
34 | @@ -6,7 +6,7 @@ | ||
35 | * klogctl(). | ||
36 | */ | ||
37 | |||
38 | -#include "../../config.h" | ||
39 | +#include "config.h" | ||
40 | #include <stdio.h> | ||
41 | #if defined(HAVE_SYS_KLOG_H) | ||
42 | #include <sys/klog.h> | ||
43 | -- | ||
44 | 2.13.1 | ||
45 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0004-pth_atfork1.c-Define-error-API-for-musl.patch b/meta/recipes-devtools/valgrind/valgrind/0004-pth_atfork1.c-Define-error-API-for-musl.patch new file mode 100644 index 0000000000..1cb7062545 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0004-pth_atfork1.c-Define-error-API-for-musl.patch | |||
@@ -0,0 +1,37 @@ | |||
1 | From fb77fef4f866dac7bcc6d1ae025da60564869f84 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 01:06:11 -0700 | ||
4 | Subject: [PATCH 4/6] pth_atfork1.c: Define error() API for musl | ||
5 | |||
6 | Upstream-Status: Pending | ||
7 | |||
8 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
9 | --- | ||
10 | none/tests/pth_atfork1.c | 4 ++-- | ||
11 | 1 file changed, 2 insertions(+), 2 deletions(-) | ||
12 | |||
13 | diff --git a/none/tests/pth_atfork1.c b/none/tests/pth_atfork1.c | ||
14 | index 34201ef..b7f5f2d 100644 | ||
15 | --- a/none/tests/pth_atfork1.c | ||
16 | +++ b/none/tests/pth_atfork1.c | ||
17 | @@ -18,7 +18,7 @@ | ||
18 | Boston, MA 02111-1307, USA. */ | ||
19 | |||
20 | #include <errno.h> | ||
21 | -#if !defined(__APPLE__) && !defined(__sun) | ||
22 | +#if !defined(__APPLE__) && !defined(__sun) && defined(__GLIBC__) | ||
23 | # include <error.h> | ||
24 | #endif | ||
25 | #include <stdlib.h> | ||
26 | @@ -27,7 +27,7 @@ | ||
27 | #include <sys/wait.h> | ||
28 | #include <stdio.h> | ||
29 | |||
30 | -#if defined(__APPLE__) || defined(__sun) | ||
31 | +#if defined(__APPLE__) || defined(__sun) || (defined(__linux__) && !defined(__GLIBC__)) | ||
32 | #include <string.h> /* strerror */ | ||
33 | static void error (int status, int errnum, char* msg) | ||
34 | { | ||
35 | -- | ||
36 | 2.13.1 | ||
37 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch b/meta/recipes-devtools/valgrind/valgrind/0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch new file mode 100644 index 0000000000..6176640e42 --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch | |||
@@ -0,0 +1,30 @@ | |||
1 | From b4b9f072c22f96844e02cb9d68f7ff2408680817 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 01:07:59 -0700 | ||
4 | Subject: [PATCH 5/6] tc20_verifywrap.c: Fake __GLIBC_PREREQ with musl | ||
5 | |||
6 | similar to sun | ||
7 | |||
8 | Upstream-Status: Pending | ||
9 | |||
10 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
11 | --- | ||
12 | helgrind/tests/tc20_verifywrap.c | 2 +- | ||
13 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
14 | |||
15 | diff --git a/helgrind/tests/tc20_verifywrap.c b/helgrind/tests/tc20_verifywrap.c | ||
16 | index c110000..a311a49 100644 | ||
17 | --- a/helgrind/tests/tc20_verifywrap.c | ||
18 | +++ b/helgrind/tests/tc20_verifywrap.c | ||
19 | @@ -20,7 +20,7 @@ | ||
20 | |||
21 | #if !defined(__APPLE__) | ||
22 | |||
23 | -#if defined(__sun__) | ||
24 | +#if defined(__sun__) || (defined(__linux__) && !defined(__GLIBC__)) | ||
25 | /* Fake __GLIBC_PREREQ on Solaris. Pretend glibc >= 2.4. */ | ||
26 | # define __GLIBC_PREREQ | ||
27 | #else | ||
28 | -- | ||
29 | 2.13.1 | ||
30 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind/0006-pth_detached3.c-Dereference-pthread_t-before-adding-.patch b/meta/recipes-devtools/valgrind/valgrind/0006-pth_detached3.c-Dereference-pthread_t-before-adding-.patch new file mode 100644 index 0000000000..05886c743d --- /dev/null +++ b/meta/recipes-devtools/valgrind/valgrind/0006-pth_detached3.c-Dereference-pthread_t-before-adding-.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From a6547fc17c120dbd95b852f50b0c4bdee4fedb9a Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sat, 10 Jun 2017 01:20:32 -0700 | ||
4 | Subject: [PATCH 6/6] pth_detached3.c: Dereference pthread_t before adding | ||
5 | offset to it | ||
6 | |||
7 | Fixes | ||
8 | error: invalid use of undefined type 'struct __pthread' | ||
9 | |||
10 | Upstream-Status: Pending | ||
11 | |||
12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
13 | --- | ||
14 | drd/tests/pth_detached3.c | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/drd/tests/pth_detached3.c b/drd/tests/pth_detached3.c | ||
18 | index c02eef1..35d43a6 100644 | ||
19 | --- a/drd/tests/pth_detached3.c | ||
20 | +++ b/drd/tests/pth_detached3.c | ||
21 | @@ -21,7 +21,7 @@ int main(int argc, char** argv) | ||
22 | pthread_detach(thread); | ||
23 | |||
24 | /* Invoke pthread_detach() with an invalid thread ID. */ | ||
25 | - pthread_detach(thread + 8); | ||
26 | + pthread_detach((pthread_t*)(&thread + 8)); | ||
27 | |||
28 | fprintf(stderr, "Finished.\n"); | ||
29 | |||
30 | -- | ||
31 | 2.13.1 | ||
32 | |||
diff --git a/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb b/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb index d5a8dda487..d7b6d77000 100644 --- a/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb +++ b/meta/recipes-devtools/valgrind/valgrind_3.12.0.bb | |||
@@ -24,6 +24,13 @@ SRC_URI = "http://www.valgrind.org/downloads/valgrind-${PV}.tar.bz2 \ | |||
24 | file://avoid-neon-for-targets-which-don-t-support-it.patch \ | 24 | file://avoid-neon-for-targets-which-don-t-support-it.patch \ |
25 | file://valgrind-make-ld-XXX.so-strlen-intercept-optional.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 \ | 26 | file://0001-makefiles-Drop-setting-mcpu-to-cortex-a8-on-arm-arch.patch \ |
27 | file://0001-str_tester.c-Limit-rawmemchr-test-to-glibc.patch \ | ||
28 | file://0001-sigqueue-Rename-_sifields-to-__si_fields-on-musl.patch \ | ||
29 | file://0002-context-APIs-are-not-available-on-musl.patch \ | ||
30 | file://0003-correct-include-directive-path-for-config.h.patch \ | ||
31 | file://0004-pth_atfork1.c-Define-error-API-for-musl.patch \ | ||
32 | file://0005-tc20_verifywrap.c-Fake-__GLIBC_PREREQ-with-musl.patch \ | ||
33 | file://0006-pth_detached3.c-Dereference-pthread_t-before-adding-.patch \ | ||
27 | " | 34 | " |
28 | SRC_URI_append_libc-musl = "\ | 35 | SRC_URI_append_libc-musl = "\ |
29 | file://0001-fix-build-for-musl-targets.patch \ | 36 | file://0001-fix-build-for-musl-targets.patch \ |
@@ -67,6 +74,7 @@ CACHED_CONFIGUREVARS += "ac_cv_path_PERL='/usr/bin/env perl'" | |||
67 | SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}" | 74 | SELECTED_OPTIMIZATION = "${DEBUG_FLAGS}" |
68 | 75 | ||
69 | CFLAGS_append_libc-uclibc = " -D__UCLIBC__ " | 76 | CFLAGS_append_libc-uclibc = " -D__UCLIBC__ " |
77 | CFLAGS += "-no-pie" | ||
70 | 78 | ||
71 | def get_mcpu(d): | 79 | def get_mcpu(d): |
72 | for arg in (d.getVar('TUNE_CCARGS') or '').split(): | 80 | for arg in (d.getVar('TUNE_CCARGS') or '').split(): |
@@ -76,6 +84,10 @@ def get_mcpu(d): | |||
76 | continue | 84 | continue |
77 | return "" | 85 | return "" |
78 | 86 | ||
87 | do_configure_prepend () { | ||
88 | rm -rf ${S}/config.h | ||
89 | } | ||
90 | |||
79 | do_install_append () { | 91 | do_install_append () { |
80 | install -m 644 ${B}/default.supp ${D}/${libdir}/valgrind/ | 92 | install -m 644 ${B}/default.supp ${D}/${libdir}/valgrind/ |
81 | } | 93 | } |