diff options
author | Khem Raj <raj.khem@gmail.com> | 2017-07-10 21:54:22 -0700 |
---|---|---|
committer | Martin Jansa <Martin.Jansa@gmail.com> | 2017-07-14 23:44:33 +0200 |
commit | 15266c135acec3efdd4dfa1b504a266b5efcbf6b (patch) | |
tree | 445fdb48856813fbefb04493a5862c1d27422876 /meta-initramfs | |
parent | 592e9f26cca4944adf4e534af5794680f07d098c (diff) | |
download | meta-openembedded-15266c135acec3efdd4dfa1b504a266b5efcbf6b.tar.gz |
klibc: Fix build with musl
klibc failed to build with armv7+ when using thumb2
it needed to resepct TUNE_CCARGS
Add patches to fix build with musl, to sort out
the linux header maze.
Signed-off-by: Khem Raj <raj.khem@gmail.com>
Cc: Andrea Adami <andrea.adami@gmail.com>
Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-initramfs')
5 files changed, 200 insertions, 11 deletions
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch new file mode 100644 index 000000000..8d1ec69ae --- /dev/null +++ b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch | |||
@@ -0,0 +1,85 @@ | |||
1 | From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 9 Jul 2017 15:17:29 -0700 | ||
4 | Subject: [PATCH] Define in_* structs for non-glibc system libs | ||
5 | |||
6 | These defines and structs are required to be coming from | ||
7 | userspace netinet/in.h, which is being overridden in klibc | ||
8 | however, libc-compat.h from kernel is only written keeping | ||
9 | glibc in mind, and does not provide adequate guards for musl | ||
10 | to infer that these structs should be defined in linux/in.h | ||
11 | |||
12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
13 | --- | ||
14 | usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++ | ||
15 | 1 file changed, 33 insertions(+) | ||
16 | |||
17 | Index: git/usr/include/netinet/in.h | ||
18 | =================================================================== | ||
19 | --- git.orig/usr/include/netinet/in.h | ||
20 | +++ git/usr/include/netinet/in.h | ||
21 | @@ -5,6 +5,42 @@ | ||
22 | #ifndef _NETINET_IN_H | ||
23 | #define _NETINET_IN_H | ||
24 | |||
25 | +#ifndef __GLIBC__ | ||
26 | +#include <linux/libc-compat.h> | ||
27 | + | ||
28 | +#undef __UAPI_DEF_IN_ADDR | ||
29 | +#undef __UAPI_DEF_IN_IPPROTO | ||
30 | +#undef __UAPI_DEF_IN_PKTINFO | ||
31 | +#undef __UAPI_DEF_IP_MREQ | ||
32 | +#undef __UAPI_DEF_SOCKADDR_IN | ||
33 | +#undef __UAPI_DEF_IN_CLASS | ||
34 | +#undef __UAPI_DEF_IN6_ADDR | ||
35 | +#undef __UAPI_DEF_IN6_ADDR_ALT | ||
36 | +#undef __UAPI_DEF_SOCKADDR_IN6 | ||
37 | +#undef __UAPI_DEF_IPV6_MREQ | ||
38 | +#undef __UAPI_DEF_IPPROTO_V6 | ||
39 | +#undef __UAPI_DEF_IPV6_OPTIONS | ||
40 | +#undef __UAPI_DEF_IN6_PKTINFO | ||
41 | +#undef __UAPI_DEF_IP6_MTUINFO | ||
42 | +#undef __UAPI_DEF_IF_IFREQ | ||
43 | + | ||
44 | +#define __UAPI_DEF_IN_ADDR 1 | ||
45 | +#define __UAPI_DEF_IN_IPPROTO 1 | ||
46 | +#define __UAPI_DEF_IN_PKTINFO 1 | ||
47 | +#define __UAPI_DEF_IP_MREQ 1 | ||
48 | +#define __UAPI_DEF_SOCKADDR_IN 1 | ||
49 | +#define __UAPI_DEF_IN_CLASS 1 | ||
50 | +#define __UAPI_DEF_IN6_ADDR 1 | ||
51 | +#define __UAPI_DEF_IN6_ADDR_ALT 1 | ||
52 | +#define __UAPI_DEF_SOCKADDR_IN6 1 | ||
53 | +#define __UAPI_DEF_IPV6_MREQ 1 | ||
54 | +#define __UAPI_DEF_IPPROTO_V6 1 | ||
55 | +#define __UAPI_DEF_IPV6_OPTIONS 1 | ||
56 | +#define __UAPI_DEF_IN6_PKTINFO 1 | ||
57 | +#define __UAPI_DEF_IP6_MTUINFO 1 | ||
58 | +#define __UAPI_DEF_IF_IFREQ 1 | ||
59 | +#endif | ||
60 | + | ||
61 | #include <klibc/extern.h> | ||
62 | #include <stdint.h> | ||
63 | #include <endian.h> /* Must be included *before* <linux/in.h> */ | ||
64 | Index: git/usr/include/net/if.h | ||
65 | =================================================================== | ||
66 | --- git.orig/usr/include/net/if.h | ||
67 | +++ git/usr/include/net/if.h | ||
68 | @@ -1,6 +1,17 @@ | ||
69 | #ifndef _NET_IF_H | ||
70 | #define _NET_IF_H | ||
71 | |||
72 | +#ifndef __GLIBC__ | ||
73 | +#include <linux/libc-compat.h> | ||
74 | +#undef __UAPI_DEF_IF_IFREQ | ||
75 | +#define __UAPI_DEF_IF_IFREQ 1 | ||
76 | +#undef __UAPI_DEF_IF_IFNAMSIZ | ||
77 | +#define __UAPI_DEF_IF_IFNAMSIZ 1 | ||
78 | +#undef __UAPI_DEF_IF_IFMAP | ||
79 | +#define __UAPI_DEF_IF_IFMAP 1 | ||
80 | +#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS | ||
81 | +#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 | ||
82 | +#endif | ||
83 | #include <sys/socket.h> | ||
84 | #include <sys/types.h> | ||
85 | #include <linux/if.h> | ||
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch new file mode 100644 index 000000000..ae8c1f11a --- /dev/null +++ b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch | |||
@@ -0,0 +1,31 @@ | |||
1 | From 2fff607fd0b5550e5072a6fffcbb01c29d5207d2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 9 Jul 2017 13:51:25 -0700 | ||
4 | Subject: [PATCH] dash: Specify format string in fmtstr() | ||
5 | |||
6 | Fixes build with hardening flags | ||
7 | |||
8 | usr/dash/jobs.c:429:3: error: format not a string literal and no format arguments [-Werror=format-security] | ||
9 | col = fmtstr(s, 32, strsignal(st)); | ||
10 | |||
11 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
12 | --- | ||
13 | usr/dash/jobs.c | 2 +- | ||
14 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
15 | |||
16 | diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c | ||
17 | index 009bbfee..299bcacc 100644 | ||
18 | --- a/usr/dash/jobs.c | ||
19 | +++ b/usr/dash/jobs.c | ||
20 | @@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly) | ||
21 | goto out; | ||
22 | #endif | ||
23 | } | ||
24 | - col = fmtstr(s, 32, strsignal(st)); | ||
25 | + col = fmtstr(s, 32, "%s", strsignal(st)); | ||
26 | #ifdef WCOREDUMP | ||
27 | if (WCOREDUMP(status)) { | ||
28 | col += fmtstr(s + col, 16, " (core dumped)"); | ||
29 | -- | ||
30 | 2.13.2 | ||
31 | |||
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch new file mode 100644 index 000000000..1b033acc4 --- /dev/null +++ b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch | |||
@@ -0,0 +1,32 @@ | |||
1 | From ab060a57b41f989665ade20e813bbcb67f91f1f2 Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Sun, 9 Jul 2017 15:56:28 -0700 | ||
4 | Subject: [PATCH] include linux/sysinfo.h directly | ||
5 | |||
6 | This is done to avoid the kernel header linux/kernel.h to use | ||
7 | __GLIBC__ define to decide on if libc implements sysinfo() API | ||
8 | or not. Kernel headers should be independent of such assumptions | ||
9 | but until its done in right place, change the local header | ||
10 | override to avoid this assumption | ||
11 | |||
12 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
13 | --- | ||
14 | usr/include/sys/sysinfo.h | 2 +- | ||
15 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
16 | |||
17 | diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h | ||
18 | index dba68dc6..d145c0b1 100644 | ||
19 | --- a/usr/include/sys/sysinfo.h | ||
20 | +++ b/usr/include/sys/sysinfo.h | ||
21 | @@ -5,7 +5,7 @@ | ||
22 | #ifndef _SYS_SYSINFO_H | ||
23 | #define _SYS_SYSINFO_H | ||
24 | |||
25 | -#include <linux/kernel.h> | ||
26 | +#include <linux/sysinfo.h> | ||
27 | |||
28 | extern int sysinfo(struct sysinfo *info); | ||
29 | |||
30 | -- | ||
31 | 2.13.2 | ||
32 | |||
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch new file mode 100644 index 000000000..9791412e4 --- /dev/null +++ b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch | |||
@@ -0,0 +1,29 @@ | |||
1 | From b4e120f5edf06e6df138b1804a8b5180584cea6b Mon Sep 17 00:00:00 2001 | ||
2 | From: Khem Raj <raj.khem@gmail.com> | ||
3 | Date: Mon, 10 Jul 2017 20:42:50 -0700 | ||
4 | Subject: [PATCH] mkfifo: Implement mkfifo | ||
5 | |||
6 | Signed-off-by: Khem Raj <raj.khem@gmail.com> | ||
7 | --- | ||
8 | usr/utils/mkfifo.c | 5 +++++ | ||
9 | 1 file changed, 5 insertions(+) | ||
10 | |||
11 | diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c | ||
12 | index 5a758b2a..f1f577e6 100644 | ||
13 | --- a/usr/utils/mkfifo.c | ||
14 | +++ b/usr/utils/mkfifo.c | ||
15 | @@ -26,6 +26,11 @@ static int make_fifo(char *dir) | ||
16 | return 0; | ||
17 | } | ||
18 | |||
19 | +int mkfifo (const char *__p, mode_t __m) | ||
20 | +{ | ||
21 | + return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0); | ||
22 | +} | ||
23 | + | ||
24 | int main(int argc, char *argv[]) | ||
25 | { | ||
26 | int c, ret = 0; | ||
27 | -- | ||
28 | 2.13.2 | ||
29 | |||
diff --git a/meta-initramfs/recipes-devtools/klibc/klibc.inc b/meta-initramfs/recipes-devtools/klibc/klibc.inc index e039cb2c1..be59aa443 100644 --- a/meta-initramfs/recipes-devtools/klibc/klibc.inc +++ b/meta-initramfs/recipes-devtools/klibc/klibc.inc | |||
@@ -7,17 +7,23 @@ LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8 | |||
7 | DEPENDS = "linux-libc-headers perl-native" | 7 | DEPENDS = "linux-libc-headers perl-native" |
8 | SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c" | 8 | SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c" |
9 | 9 | ||
10 | SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git" | 10 | SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \ |
11 | SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \ | 11 | ${ARMPATCHES} \ |
12 | file://armv4-fix-v4bx.patch \ | 12 | file://klibc-linux-libc-dev.patch \ |
13 | " | 13 | file://staging.patch \ |
14 | SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \ | 14 | file://klcc-consider-sysroot.patch \ |
15 | file://armv4-fix-v4bx.patch \ | 15 | file://0001-dash-Specify-format-string-in-fmtstr.patch \ |
16 | " | 16 | file://0001-Define-in_-structs-for-non-glibc-system-libs.patch \ |
17 | SRC_URI += "file://klibc-linux-libc-dev.patch \ | 17 | file://0001-include-linux-sysinfo.h-directly.patch \ |
18 | file://staging.patch \ | 18 | file://0001-mkfifo-Implement-mkfifo.patch \ |
19 | file://klcc-consider-sysroot.patch \ | 19 | " |
20 | " | 20 | |
21 | ARMPATCHES ?= "" | ||
22 | |||
23 | ARMPATCHES_arm = "file://klibc-config-eabi.patch \ | ||
24 | file://armv4-fix-v4bx.patch \ | ||
25 | " | ||
26 | |||
21 | 27 | ||
22 | S = "${WORKDIR}/git" | 28 | S = "${WORKDIR}/git" |
23 | 29 | ||
@@ -30,9 +36,12 @@ EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \ | |||
30 | 'INSTALLROOT=${D}' \ | 36 | 'INSTALLROOT=${D}' \ |
31 | 'INSTALLDIR=${libdir}/klibc' \ | 37 | 'INSTALLDIR=${libdir}/klibc' \ |
32 | 'SHLIBDIR=${libdir}' \ | 38 | 'SHLIBDIR=${libdir}' \ |
39 | '${KLIBCTHUMB}' \ | ||
40 | 'KLIBCOPTFLAGS=${TUNE_CCARGS}' \ | ||
33 | " | 41 | " |
34 | 42 | ||
35 | export FIX_ARMV4_EABI_BX = "${FIX_V4BX}" | 43 | export FIX_ARMV4_EABI_BX = "${FIX_V4BX}" |
44 | KLIBCTHUMB = "${@['', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}" | ||
36 | 45 | ||
37 | do_configure () { | 46 | do_configure () { |
38 | ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux | 47 | ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux |
@@ -51,3 +60,6 @@ KLIBC_ARCH_x86-64 = "x86_64" | |||
51 | KLIBC_ARCH_powerpc = "ppc" | 60 | KLIBC_ARCH_powerpc = "ppc" |
52 | KLIBC_ARCH_powerpc64 = "ppc64" | 61 | KLIBC_ARCH_powerpc64 = "ppc64" |
53 | THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})" | 62 | THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})" |
63 | |||
64 | SECURITY_CFLAGS = "-fno-PIE -no-pie" | ||
65 | SECURITY_LDFLAGS = "-no-pie" | ||