libdbus-c++: Add -pthread to linker flags
PATCH 1/3 libdbus-c++: Add -pthread to linker flags
It uses symbols from libpthread e.g. pthread_mutexattr_init and pthread_mutexattr_settype but does not link with pthreads, gold is strict about it and calls out with an error
../src/.libs/libdbus-c++-1.so: error: undefined reference to 'pthread_mutexattr_init' ../src/.libs/libdbus-c++-1.so: error: undefined reference to 'pthread_mutexattr_settype'
Therefore correct the linker cmdline
--- meta-oe/recipes-core/dbus/libdbus-c++_0.9.0.bb | 1 + 1 file changed, 1 insertion(+)
meta-oe/recipes-core/dbus/libdbus-c++_0.9.0.bb +1 -0
@@ -21,6 +21,7 @@ SRC_URI[sha256sum] = "bc11ac297b3cb010be904c72789695543ee3fdf3d75cdc8225fd371385 inherit autotools pkgconfig EXTRA_OECONF = "--disable-ecore --disable-examples --disable-tests" +LDFLAGS += "-pthread" PACKAGE_BEFORE_PN = "${PN}-tools"
Signature · 1 line
2.13.2
PATCH v2 2/3 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.
--- ...ine-in_-structs-for-non-glibc-system-libs.patch | 85 ++++++++++++++++++++++ ...0001-dash-Specify-format-string-in-fmtstr.patch | 31 ++++++++ .../0001-include-linux-sysinfo.h-directly.patch | 32 ++++++++ .../klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch | 29 ++++++++ meta-initramfs/recipes-devtools/klibc/klibc.inc | 34 ++++++--- 5 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch new file +85 -0
@@ -0,0 +1,85 @@ +From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:17:29 -0700 +Subject: [PATCH] Define in_* structs for non-glibc system libs + +These defines and structs are required to be coming from +userspace netinet/in.h, which is being overridden in klibc +however, libc-compat.h from kernel is only written keeping +glibc in mind, and does not provide adequate guards for musl +to infer that these structs should be defined in linux/in.h + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +Index: git/usr/include/netinet/in.h +=================================================================== +--- git.orig/usr/include/netinet/in.h ++++ git/usr/include/netinet/in.h +@@ -5,6 +5,42 @@ + #ifndef _NETINET_IN_H + #define _NETINET_IN_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++ ++#undef __UAPI_DEF_IN_ADDR ++#undef __UAPI_DEF_IN_IPPROTO ++#undef __UAPI_DEF_IN_PKTINFO ++#undef __UAPI_DEF_IP_MREQ ++#undef __UAPI_DEF_SOCKADDR_IN ++#undef __UAPI_DEF_IN_CLASS ++#undef __UAPI_DEF_IN6_ADDR ++#undef __UAPI_DEF_IN6_ADDR_ALT ++#undef __UAPI_DEF_SOCKADDR_IN6 ++#undef __UAPI_DEF_IPV6_MREQ ++#undef __UAPI_DEF_IPPROTO_V6 ++#undef __UAPI_DEF_IPV6_OPTIONS ++#undef __UAPI_DEF_IN6_PKTINFO ++#undef __UAPI_DEF_IP6_MTUINFO ++#undef __UAPI_DEF_IF_IFREQ ++ ++#define __UAPI_DEF_IN_ADDR 1 ++#define __UAPI_DEF_IN_IPPROTO 1 ++#define __UAPI_DEF_IN_PKTINFO 1 ++#define __UAPI_DEF_IP_MREQ 1 ++#define __UAPI_DEF_SOCKADDR_IN 1 ++#define __UAPI_DEF_IN_CLASS 1 ++#define __UAPI_DEF_IN6_ADDR 1 ++#define __UAPI_DEF_IN6_ADDR_ALT 1 ++#define __UAPI_DEF_SOCKADDR_IN6 1 ++#define __UAPI_DEF_IPV6_MREQ 1 ++#define __UAPI_DEF_IPPROTO_V6 1 ++#define __UAPI_DEF_IPV6_OPTIONS 1 ++#define __UAPI_DEF_IN6_PKTINFO 1 ++#define __UAPI_DEF_IP6_MTUINFO 1 ++#define __UAPI_DEF_IF_IFREQ 1 ++#endif ++ + #include <klibc/extern.h> + #include <stdint.h> + #include <endian.h> /* Must be included *before* <linux/in.h> */ +Index: git/usr/include/net/if.h +=================================================================== +--- git.orig/usr/include/net/if.h ++++ git/usr/include/net/if.h +@@ -1,6 +1,17 @@ + #ifndef _NET_IF_H + #define _NET_IF_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++#undef __UAPI_DEF_IF_IFREQ ++#define __UAPI_DEF_IF_IFREQ 1 ++#undef __UAPI_DEF_IF_IFNAMSIZ ++#define __UAPI_DEF_IF_IFNAMSIZ 1 ++#undef __UAPI_DEF_IF_IFMAP ++#define __UAPI_DEF_IF_IFMAP 1 ++#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS ++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 ++#endif + #include <sys/socket.h> + #include <sys/types.h> + #include <linux/if.h>
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch new file +31 -0
@@ -0,0 +1,31 @@ +From 2fff607fd0b5550e5072a6fffcbb01c29d5207d2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 13:51:25 -0700 +Subject: [PATCH] dash: Specify format string in fmtstr() + +Fixes build with hardening flags + +usr/dash/jobs.c:429:3: error: format not a string literal and no format arguments [-Werror=format-security] + col = fmtstr(s, 32, strsignal(st)); + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/dash/jobs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c +index 009bbfee..299bcacc 100644 +--- a/usr/dash/jobs.c ++++ b/usr/dash/jobs.c +@@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly) + goto out; + #endif + } +- col = fmtstr(s, 32, strsignal(st)); ++ col = fmtstr(s, 32, "%s", strsignal(st)); + #ifdef WCOREDUMP + if (WCOREDUMP(status)) { + col += fmtstr(s + col, 16, " (core dumped)"); +-- +2.13.2 +
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch new file +32 -0
@@ -0,0 +1,32 @@ +From ab060a57b41f989665ade20e813bbcb67f91f1f2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:56:28 -0700 +Subject: [PATCH] include linux/sysinfo.h directly + +This is done to avoid the kernel header linux/kernel.h to use +__GLIBC__ define to decide on if libc implements sysinfo() API +or not. Kernel headers should be independent of such assumptions +but until its done in right place, change the local header +override to avoid this assumption + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/sys/sysinfo.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h +index dba68dc6..d145c0b1 100644 +--- a/usr/include/sys/sysinfo.h ++++ b/usr/include/sys/sysinfo.h +@@ -5,7 +5,7 @@ + #ifndef _SYS_SYSINFO_H + #define _SYS_SYSINFO_H + +-#include <linux/kernel.h> ++#include <linux/sysinfo.h> + + extern int sysinfo(struct sysinfo *info); + +-- +2.13.2 +
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch new file +29 -0
@@ -0,0 +1,29 @@ +From b4e120f5edf06e6df138b1804a8b5180584cea6b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 10 Jul 2017 20:42:50 -0700 +Subject: [PATCH] mkfifo: Implement mkfifo + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/utils/mkfifo.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c +index 5a758b2a..f1f577e6 100644 +--- a/usr/utils/mkfifo.c ++++ b/usr/utils/mkfifo.c +@@ -26,6 +26,11 @@ static int make_fifo(char *dir) + return 0; + } + ++int mkfifo (const char *__p, mode_t __m) ++{ ++ return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0); ++} ++ + int main(int argc, char *argv[]) + { + int c, ret = 0; +-- +2.13.2 +
meta-initramfs/recipes-devtools/klibc/klibc.inc +23 -11
@@ -7,17 +7,23 @@ LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8 DEPENDS = "linux-libc-headers perl-native" SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c" -SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git" -SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI += "file://klibc-linux-libc-dev.patch \ - file://staging.patch \ - file://klcc-consider-sysroot.patch \ - " +SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \ + ${ARMPATCHES} \ + file://klibc-linux-libc-dev.patch \ + file://staging.patch \ + file://klcc-consider-sysroot.patch \ + file://0001-dash-Specify-format-string-in-fmtstr.patch \ + file://0001-Define-in_-structs-for-non-glibc-system-libs.patch \ + file://0001-include-linux-sysinfo.h-directly.patch \ + file://0001-mkfifo-Implement-mkfifo.patch \ +" + +ARMPATCHES ?= "" + +ARMPATCHES_arm = "file://klibc-config-eabi.patch \ + file://armv4-fix-v4bx.patch \ + " + S = "${WORKDIR}/git"
@@ -30,9 +36,12 @@ EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \ 'INSTALLROOT=${D}' \ 'INSTALLDIR=${libdir}/klibc' \ 'SHLIBDIR=${libdir}' \ + '${KLIBCTHUMB}' \ + 'KLIBCOPTFLAGS=${TUNE_CCARGS}' \ " export FIX_ARMV4_EABI_BX = "${FIX_V4BX}" +KLIBCTHUMB = "${@['', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET') == 'thumb')]}" do_configure () { ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linux
@@ -51,3 +60,6 @@ KLIBC_ARCH_x86-64 = "x86_64" KLIBC_ARCH_powerpc = "ppc" KLIBC_ARCH_powerpc64 = "ppc64" THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})" + +SECURITY_CFLAGS = "-fno-PIE -no-pie" +SECURITY_LDFLAGS = "-no-pie"
Signature · 1 line
2.13.2
Re: [meta-initramfs][PATCH V2 2/3] klibc: Fix build with musl
Seems to break the build for qemuarm:
http://errors.yoctoproject.org/Errors/Details/147256/
http://errors.yoctoproject.org/Errors/Details/147257/
Also there is small typo in commit message "resepct"
Quoted 313 lines · Khem Raj
klibc failed to build with armv7+ when using thumb2 it needed to resepct
TUNE_CCARGSAdd patches to fix build with musl, to sort out the linux header maze.
Signed-off-by Khem Raj <[email protected]>Cc Andrea Adami <[email protected]>--- ...ine-in_-structs-for-non-glibc-system-libs.patch | 85 ++++++++++++++++++++++ ...0001-dash-Specify-format-string-in-fmtstr.patch | 31 ++++++++ .../0001-include-linux-sysinfo.h-directly.patch | 32 ++++++++ .../klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch | 29 ++++++++ meta-initramfs/recipes-devtools/klibc/klibc.inc | 34 ++++++--- 5 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ 0001-Define-in_-structs-for-non-glibc-system-libs.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ 0001-dash-Specify-format-string-in-fmtstr.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ 0001-include-linux-sysinfo.h-directly.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch
(quoted diff) +0
-00001-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..8d1ec69aemeta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +0
-00001-Define-in_-structs-for-non-glibc-system-libs.patch
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +63
-0@@ -0,0 +1,85 @@ +From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:17:29 -0700 +Subject: [PATCH] Define in_* structs for non-glibc system libs + +These defines and structs are required to be coming from +userspace netinet/in.h, which is being overridden in klibc +however, libc-compat.h from kernel is only written keeping +glibc in mind, and does not provide adequate guards for musl +to infer that these structs should be defined in linux/in.h + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +Index: git/usr/include/netinet/in.h +=================================================================== +--- git.orig/usr/include/netinet/in.h ++++ git/usr/include/netinet/in.h +@@ -5,6 +5,42 @@ + #ifndef _NETINET_IN_H + #define _NETINET_IN_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++ ++#undef __UAPI_DEF_IN_ADDR ++#undef __UAPI_DEF_IN_IPPROTO ++#undef __UAPI_DEF_IN_PKTINFO ++#undef __UAPI_DEF_IP_MREQ ++#undef __UAPI_DEF_SOCKADDR_IN ++#undef __UAPI_DEF_IN_CLASS ++#undef __UAPI_DEF_IN6_ADDR ++#undef __UAPI_DEF_IN6_ADDR_ALT ++#undef __UAPI_DEF_SOCKADDR_IN6 ++#undef __UAPI_DEF_IPV6_MREQ ++#undef __UAPI_DEF_IPPROTO_V6 ++#undef __UAPI_DEF_IPV6_OPTIONS ++#undef __UAPI_DEF_IN6_PKTINFO ++#undef __UAPI_DEF_IP6_MTUINFO ++#undef __UAPI_DEF_IF_IFREQ ++ ++#define __UAPI_DEF_IN_ADDR 1 ++#define __UAPI_DEF_IN_IPPROTO 1 ++#define __UAPI_DEF_IN_PKTINFO 1 ++#define __UAPI_DEF_IP_MREQ 1 ++#define __UAPI_DEF_SOCKADDR_IN 1 ++#define __UAPI_DEF_IN_CLASS 1 ++#define __UAPI_DEF_IN6_ADDR 1 ++#define __UAPI_DEF_IN6_ADDR_ALT 1 ++#define __UAPI_DEF_SOCKADDR_IN6 1 ++#define __UAPI_DEF_IPV6_MREQ 1 ++#define __UAPI_DEF_IPPROTO_V6 1 ++#define __UAPI_DEF_IPV6_OPTIONS 1 ++#define __UAPI_DEF_IN6_PKTINFO 1 ++#define __UAPI_DEF_IP6_MTUINFO 1 ++#define __UAPI_DEF_IF_IFREQ 1 ++#endif ++ + #include <klibc/extern.h> + #include <stdint.h> + #include <endian.h> /* Must be included *before* <linux/in.h>*/
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +22
-0+Index: git/usr/include/net/if.h +=================================================================== +--- git.orig/usr/include/net/if.h ++++ git/usr/include/net/if.h +@@ -1,6 +1,17 @@ + #ifndef _NET_IF_H + #define _NET_IF_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++#undef __UAPI_DEF_IF_IFREQ ++#define __UAPI_DEF_IF_IFREQ 1 ++#undef __UAPI_DEF_IF_IFNAMSIZ ++#define __UAPI_DEF_IF_IFNAMSIZ 1 ++#undef __UAPI_DEF_IF_IFMAP ++#define __UAPI_DEF_IF_IFMAP 1 ++#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS ++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 ++#endif + #include <sys/socket.h> + #include <sys/types.h> + #include <linux/if.h>(quoted diff) +0
-00001-dash-Specify-format-string-in-fmtstr.patch b/meta-initramfs/recipes-
devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patchnew file mode 100644
index 000000000..ae8c1f11ameta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +0
-00001-dash-Specify-format-string-in-fmtstr.patch
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +8
-0@@ -0,0 +1,31 @@ +From 2fff607fd0b5550e5072a6fffcbb01c29d5207d2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 13:51:25 -0700 +Subject: [PATCH] dash: Specify format string in fmtstr() + +Fixes build with hardening flags + +usr/dash/jobs.c:429:3: error: format not a string literal and no formatarguments [-Werror=format-security]
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +23
-0+ col = fmtstr(s, 32, strsignal(st)); + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/dash/jobs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c +index 009bbfee..299bcacc 100644 +--- a/usr/dash/jobs.c ++++ b/usr/dash/jobs.c +@@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly) + goto out; + #endif + } +- col = fmtstr(s, 32, strsignal(st)); ++ col = fmtstr(s, 32, "%s", strsignal(st)); + #ifdef WCOREDUMP + if (WCOREDUMP(status)) { + col += fmtstr(s + col, 16, " (core dumped)"); +-- +2.13.2 +(quoted diff) +0
-00001-include-linux-sysinfo.h-directly.patch b/meta-initramfs/recipes-
devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patchnew file mode 100644
index 000000000..1b033acc4meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +0
-00001-include-linux-sysinfo.h-directly.patch
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +32
-0@@ -0,0 +1,32 @@ +From ab060a57b41f989665ade20e813bbcb67f91f1f2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:56:28 -0700 +Subject: [PATCH] include linux/sysinfo.h directly + +This is done to avoid the kernel header linux/kernel.h to use +__GLIBC__ define to decide on if libc implements sysinfo() API +or not. Kernel headers should be independent of such assumptions +but until its done in right place, change the local header +override to avoid this assumption + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/sys/sysinfo.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h +index dba68dc6..d145c0b1 100644 +--- a/usr/include/sys/sysinfo.h ++++ b/usr/include/sys/sysinfo.h +@@ -5,7 +5,7 @@ + #ifndef _SYS_SYSINFO_H + #define _SYS_SYSINFO_H + +-#include <linux/kernel.h> ++#include <linux/sysinfo.h> + + extern int sysinfo(struct sysinfo *info); + +-- +2.13.2 +(quoted diff) +0
-00001-mkfifo-Implement-mkfifo.patch b/meta-initramfs/recipes-
devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patchnew file mode 100644
index 000000000..9791412e4meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +0
-00001-mkfifo-Implement-mkfifo.patch
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/ new file +29
-0@@ -0,0 +1,29 @@ +From b4e120f5edf06e6df138b1804a8b5180584cea6b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 10 Jul 2017 20:42:50 -0700 +Subject: [PATCH] mkfifo: Implement mkfifo + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/utils/mkfifo.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c +index 5a758b2a..f1f577e6 100644 +--- a/usr/utils/mkfifo.c ++++ b/usr/utils/mkfifo.c +@@ -26,6 +26,11 @@ static int make_fifo(char *dir) + return 0; + } + ++int mkfifo (const char *__p, mode_t __m) ++{ ++ return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0); ++} ++ + int main(int argc, char *argv[]) + { + int c, ret = 0; +-- +2.13.2 +meta-initramfs/recipes-devtools/klibc/klibc.inc +0
-0@@ -7,17 +7,23 @@ LIC_FILES_CHKSUM = "file://usr/klibc/LICENSE;md5=
d75181f10e998c21eb147f6d2e43ce8
DEPENDS = "linux-libc-headers perl-native" SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c"meta-initramfs/recipes-devtools/klibc/klibc.inc +7
-11-SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git" -SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI += "file://klibc-linux-libc-dev.patch \ - file://staging.patch \ - file://klcc-consider-sysroot.patch \ - " +SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \ + ${ARMPATCHES} \ + file://klibc-linux-libc-dev.patch \ + file://staging.patch \ + file://klcc-consider-sysroot.patch \ + file://0001-dash-Specify-format-string-in-fmtstr.patch \ + file://0001-Define-in_-structs-for-non-glibc-system-libs.patch\
meta-initramfs/recipes-devtools/klibc/klibc.inc +13
-0+ file://0001-include-linux-sysinfo.h-directly.patch \ + file://0001-mkfifo-Implement-mkfifo.patch \ +" + +ARMPATCHES ?= "" + +ARMPATCHES_arm = "file://klibc-config-eabi.patch \ + file://armv4-fix-v4bx.patch \ + " + S = "${WORKDIR}/git"@@ -30,9 +36,12 @@ EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \ 'INSTALLROOT=${D}' \ 'INSTALLDIR=${libdir}/klibc' \ 'SHLIBDIR=${libdir}' \ + '${KLIBCTHUMB}' \ + 'KLIBCOPTFLAGS=${TUNE_CCARGS}' \ " export FIX_ARMV4_EABI_BX = "${FIX_V4BX}" +KLIBCTHUMB = "${@['', 'CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET')== 'thumb')]}"
do_configure () { ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linuxmeta-initramfs/recipes-devtools/klibc/klibc.inc +3
-1@@ -51,3 +60,6 @@ KLIBC_ARCH_x86-64 = "x86_64" KLIBC_ARCH_powerpc = "ppc" KLIBC_ARCH_powerpc64 = "ppc64" THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})" + +SECURITY_CFLAGS = "-fno-PIE -no-pie" +SECURITY_LDFLAGS = "-no-pie" --2.13.2
--
_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
Re: [meta-initramfs][PATCH V2 2/3] klibc: Fix build with musl
Quoted 4 lines · Martin Jansa
Seems to break the build for qemuarm:
http://errors.yoctoproject.org/Errors/Details/147256/
http://errors.yoctoproject.org/Errors/Details/147257/
seems its digging gold again :)
Quoted 1 line
Also there is small typo in commit message "resepct"
good find
Quoted 316 lines · Khem Raj
Quoted 312 lines
klibc failed to build with armv7+ when using thumb2 it needed to resepct
TUNE_CCARGSAdd patches to fix build with musl, to sort out the linux header maze.
Signed-off-by Khem Raj <[email protected]>Cc Andrea Adami <[email protected]>--- ...ine-in_-structs-for-non-glibc-system-libs.patch | 85 ++++++++++++++++++++++ ...0001-dash-Specify-format-string-in-fmtstr.patch | 31 ++++++++ .../0001-include-linux-sysinfo.h-directly.patch | 32 ++++++++ .../klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch | 29 ++++++++ meta-initramfs/recipes-devtools/klibc/klibc.inc | 34 ++++++--- 5 files changed, 200 insertions(+), 11 deletions(-) create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch create mode 100644 meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch create mode 100644
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patchdiff --git
a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patchb/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patchnew 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.patchmeta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch new file +63
-0@@ -0,0 +1,85 @@ +From f414dea1316a48aba3e8e293201ebd51652d3ef4 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:17:29 -0700 +Subject: [PATCH] Define in_* structs for non-glibc system libs + +These defines and structs are required to be coming from +userspace netinet/in.h, which is being overridden in klibc +however, libc-compat.h from kernel is only written keeping +glibc in mind, and does not provide adequate guards for musl +to infer that these structs should be defined in linux/in.h + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/netinet/in.h | 33 +++++++++++++++++++++++++++++++++ + 1 file changed, 33 insertions(+) + +Index: git/usr/include/netinet/in.h +=================================================================== +--- git.orig/usr/include/netinet/in.h ++++ git/usr/include/netinet/in.h +@@ -5,6 +5,42 @@ + #ifndef _NETINET_IN_H + #define _NETINET_IN_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++ ++#undef __UAPI_DEF_IN_ADDR ++#undef __UAPI_DEF_IN_IPPROTO ++#undef __UAPI_DEF_IN_PKTINFO ++#undef __UAPI_DEF_IP_MREQ ++#undef __UAPI_DEF_SOCKADDR_IN ++#undef __UAPI_DEF_IN_CLASS ++#undef __UAPI_DEF_IN6_ADDR ++#undef __UAPI_DEF_IN6_ADDR_ALT ++#undef __UAPI_DEF_SOCKADDR_IN6 ++#undef __UAPI_DEF_IPV6_MREQ ++#undef __UAPI_DEF_IPPROTO_V6 ++#undef __UAPI_DEF_IPV6_OPTIONS ++#undef __UAPI_DEF_IN6_PKTINFO ++#undef __UAPI_DEF_IP6_MTUINFO ++#undef __UAPI_DEF_IF_IFREQ ++ ++#define __UAPI_DEF_IN_ADDR 1 ++#define __UAPI_DEF_IN_IPPROTO 1 ++#define __UAPI_DEF_IN_PKTINFO 1 ++#define __UAPI_DEF_IP_MREQ 1 ++#define __UAPI_DEF_SOCKADDR_IN 1 ++#define __UAPI_DEF_IN_CLASS 1 ++#define __UAPI_DEF_IN6_ADDR 1 ++#define __UAPI_DEF_IN6_ADDR_ALT 1 ++#define __UAPI_DEF_SOCKADDR_IN6 1 ++#define __UAPI_DEF_IPV6_MREQ 1 ++#define __UAPI_DEF_IPPROTO_V6 1 ++#define __UAPI_DEF_IPV6_OPTIONS 1 ++#define __UAPI_DEF_IN6_PKTINFO 1 ++#define __UAPI_DEF_IP6_MTUINFO 1 ++#define __UAPI_DEF_IF_IFREQ 1 ++#endif ++ + #include <klibc/extern.h> + #include <stdint.h> + #include <endian.h> /* Must be included *before* <linux/in.h>*/
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-Define-in_-structs-for-non-glibc-system-libs.patch new file +22
-0+Index: git/usr/include/net/if.h +=================================================================== +--- git.orig/usr/include/net/if.h ++++ git/usr/include/net/if.h +@@ -1,6 +1,17 @@ + #ifndef _NET_IF_H + #define _NET_IF_H + ++#ifndef __GLIBC__ ++#include <linux/libc-compat.h> ++#undef __UAPI_DEF_IF_IFREQ ++#define __UAPI_DEF_IF_IFREQ 1 ++#undef __UAPI_DEF_IF_IFNAMSIZ ++#define __UAPI_DEF_IF_IFNAMSIZ 1 ++#undef __UAPI_DEF_IF_IFMAP ++#define __UAPI_DEF_IF_IFMAP 1 ++#undef __UAPI_DEF_IF_NET_DEVICE_FLAGS ++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS 1 ++#endif + #include <sys/socket.h> + #include <sys/types.h> + #include <linux/if.h>diff --git
a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patchb/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patchnew 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.patchmeta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch new file +8
-0@@ -0,0 +1,31 @@ +From 2fff607fd0b5550e5072a6fffcbb01c29d5207d2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 13:51:25 -0700 +Subject: [PATCH] dash: Specify format string in fmtstr() + +Fixes build with hardening flags + +usr/dash/jobs.c:429:3: error: format not a string literal and no formatarguments [-Werror=format-security]
meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-dash-Specify-format-string-in-fmtstr.patch new file +23
-0+ col = fmtstr(s, 32, strsignal(st)); + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/dash/jobs.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/dash/jobs.c b/usr/dash/jobs.c +index 009bbfee..299bcacc 100644 +--- a/usr/dash/jobs.c ++++ b/usr/dash/jobs.c +@@ -426,7 +426,7 @@ sprint_status(char *s, int status, int sigonly) + goto out; + #endif + } +- col = fmtstr(s, 32, strsignal(st)); ++ col = fmtstr(s, 32, "%s", strsignal(st)); + #ifdef WCOREDUMP + if (WCOREDUMP(status)) { + col += fmtstr(s + col, 16, " (core dumped)"); +-- +2.13.2 +diff --git
a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patchb/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patchnew file mode 100644
index 000000000..1b033acc4
---/dev/null
+++b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patchmeta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-include-linux-sysinfo.h-directly.patch new file +32
-0@@ -0,0 +1,32 @@ +From ab060a57b41f989665ade20e813bbcb67f91f1f2 Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Sun, 9 Jul 2017 15:56:28 -0700 +Subject: [PATCH] include linux/sysinfo.h directly + +This is done to avoid the kernel header linux/kernel.h to use +__GLIBC__ define to decide on if libc implements sysinfo() API +or not. Kernel headers should be independent of such assumptions +but until its done in right place, change the local header +override to avoid this assumption + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/include/sys/sysinfo.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/usr/include/sys/sysinfo.h b/usr/include/sys/sysinfo.h +index dba68dc6..d145c0b1 100644 +--- a/usr/include/sys/sysinfo.h ++++ b/usr/include/sys/sysinfo.h +@@ -5,7 +5,7 @@ + #ifndef _SYS_SYSINFO_H + #define _SYS_SYSINFO_H + +-#include <linux/kernel.h> ++#include <linux/sysinfo.h> + + extern int sysinfo(struct sysinfo *info); + +-- +2.13.2 +diff --git
a/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patchb/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patchnew file mode 100644
index 000000000..9791412e4
---/dev/null
+++b/meta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patchmeta-initramfs/recipes-devtools/klibc/klibc-2.0.4/0001-mkfifo-Implement-mkfifo.patch new file +29
-0@@ -0,0 +1,29 @@ +From b4e120f5edf06e6df138b1804a8b5180584cea6b Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Mon, 10 Jul 2017 20:42:50 -0700 +Subject: [PATCH] mkfifo: Implement mkfifo + +Signed-off-by: Khem Raj <[email protected]> +--- + usr/utils/mkfifo.c | 5 +++++ + 1 file changed, 5 insertions(+) + +diff --git a/usr/utils/mkfifo.c b/usr/utils/mkfifo.c +index 5a758b2a..f1f577e6 100644 +--- a/usr/utils/mkfifo.c ++++ b/usr/utils/mkfifo.c +@@ -26,6 +26,11 @@ static int make_fifo(char *dir) + return 0; + } + ++int mkfifo (const char *__p, mode_t __m) ++{ ++ return mknod(__p, (__m & ~S_IFMT) | S_IFIFO, (dev_t) 0); ++} ++ + int main(int argc, char *argv[]) + { + int c, ret = 0; +-- +2.13.2 +meta-initramfs/recipes-devtools/klibc/klibc.inc +0
-0@@ -7,17 +7,23 @@ LIC_FILES_CHKSUM ="file://usr/klibc/LICENSE;md5=d75181f10e998c21eb147f6d2e43ce8
DEPENDS = "linux-libc-headers perl-native"
SRCREV = "4d19974d7020488f63651244e1f9f51727c3f66c"meta-initramfs/recipes-devtools/klibc/klibc.inc +7
-11-SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git" -SRC_URI_append_linux-gnueabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI_append_linux-uclibceabi = " file://klibc-config-eabi.patch \ - file://armv4-fix-v4bx.patch \ - " -SRC_URI += "file://klibc-linux-libc-dev.patch \ - file://staging.patch \ - file://klcc-consider-sysroot.patch \ - " +SRC_URI = "git://git.kernel.org/pub/scm/libs/klibc/klibc.git \ + ${ARMPATCHES} \ + file://klibc-linux-libc-dev.patch \ + file://staging.patch \ + file://klcc-consider-sysroot.patch \ + file://0001-dash-Specify-format-string-in-fmtstr.patch \ + file://0001-Define-in_-structs-for-non-glibc-system-libs.patch\
meta-initramfs/recipes-devtools/klibc/klibc.inc +13
-0+ file://0001-include-linux-sysinfo.h-directly.patch \ + file://0001-mkfifo-Implement-mkfifo.patch \ +" + +ARMPATCHES ?= "" + +ARMPATCHES_arm = "file://klibc-config-eabi.patch \ + file://armv4-fix-v4bx.patch \ + " + S = "${WORKDIR}/git"@@ -30,9 +36,12 @@ EXTRA_OEMAKE = "'KLIBCARCH=${KLIBC_ARCH}' \ 'INSTALLROOT=${D}' \ 'INSTALLDIR=${libdir}/klibc' \ 'SHLIBDIR=${libdir}' \ + '${KLIBCTHUMB}' \ + 'KLIBCOPTFLAGS=${TUNE_CCARGS}' \ " export FIX_ARMV4_EABI_BX = "${FIX_V4BX}" +KLIBCTHUMB = "${@['','
CONFIG_KLIBC_THUMB=y'][(d.getVar('ARM_INSTRUCTION_SET')== 'thumb')]}"do_configure () { ln -sf "${STAGING_DIR_TARGET}${exec_prefix}" linuxmeta-initramfs/recipes-devtools/klibc/klibc.inc +3
-1@@ -51,3 +60,6 @@ KLIBC_ARCH_x86-64 = "x86_64" KLIBC_ARCH_powerpc = "ppc" KLIBC_ARCH_powerpc64 = "ppc64" THIS_LIBKLIBC = "libklibc (= ${PV}-${PR})" + +SECURITY_CFLAGS = "-fno-PIE -no-pie" +SECURITY_LDFLAGS = "-no-pie" --2.13.2
--
_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-devel
PATCH 3/3 ubi-utils-klibc: Pass TUNE_CCARGS into CFLAGS
In reply to Khem RajThis is needed for hard float ABI selection options
--- meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb | 1 + 1 file changed, 1 insertion(+)
meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.1.bb +1 -0
@@ -21,6 +21,7 @@ SRC_URI = "git://git.infradead.org/mtd-utils.git;tag=b7455d847ab4f9eeeb6a729efc3 S = "${WORKDIR}/git/" EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" +CFLAGS += "${TUNE_CCARGS}" do_install () {
Signature · 1 line
2.13.2