diff options
Diffstat (limited to 'import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers')
5 files changed, 267 insertions, 0 deletions
diff --git a/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc new file mode 100644 index 000000000..2ba6ed51d --- /dev/null +++ b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers.inc @@ -0,0 +1,78 @@ +SUMMARY = "Sanitized set of kernel headers for the C library's use" +SECTION = "devel" +LICENSE = "GPLv2" + +######################################################################### +#### PLEASE READ +######################################################################### +# +# You're probably looking here thinking you need to create some new copy +# of linux-libc-headers since you have your own custom kernel. To put +# this simply, you DO NOT. +# +# Why? These headers are used to build the libc. If you customise the +# headers you are customising the libc and the libc becomes machine +# specific. Most people do not add custom libc extensions to the kernel +# and have a machine specific libc. +# +# But you have some kernel headers you need for some driver? That is fine +# but get them from STAGING_KERNEL_DIR where the kernel installs itself. +# This will make the package using them machine specific but this is much +# better than having a machine specific C library. This does mean your +# recipe needs a DEPENDS += "virtual/kernel" but again, that is fine and +# makes total sense. +# +# There can also be a case where your kernel extremely old and you want +# an older libc ABI for that old kernel. The headers installed by this +# recipe should still be a standard mainline kernel, not your own custom +# one. +# +# -- RP + +LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7" + +python __anonymous () { + major = d.getVar("PV",True).split('.')[0] + if major == "3": + d.setVar("HEADER_FETCH_VER", "3.0") + elif major == "4": + d.setVar("HEADER_FETCH_VER", "4.x") + else: + d.setVar("HEADER_FETCH_VER", "2.6") +} + +inherit kernel-arch + +KORG_ARCHIVE_COMPRESSION ?= "xz" + +SRC_URI = "${KERNELORG_MIRROR}/linux/kernel/v${HEADER_FETCH_VER}/linux-${PV}.tar.${KORG_ARCHIVE_COMPRESSION}" + +S = "${WORKDIR}/linux-${PV}" + +# For the kernel, we don't want the '-e MAKEFLAGS=' in EXTRA_OEMAKE. +EXTRA_OEMAKE = "" + +do_configure() { + oe_runmake allnoconfig +} + +do_compile () { +} + +do_install() { + oe_runmake headers_install INSTALL_HDR_PATH=${D}${exec_prefix} + # Kernel should not be exporting this header + rm -f ${D}${exec_prefix}/include/scsi/scsi.h + + # The ..install.cmd conflicts between various configure runs + find ${D}${includedir} -name ..install.cmd | xargs rm -f +} + +BBCLASSEXTEND = "nativesdk" + +#DEPENDS = "cross-linkage" +RDEPENDS_${PN}-dev = "" +RRECOMMENDS_${PN}-dbg = "${PN}-dev (= ${EXTENDPKGV})" + +INHIBIT_DEFAULT_DEPS = "1" +DEPENDS += "unifdef-native" diff --git a/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch new file mode 100644 index 000000000..6ad479863 --- /dev/null +++ b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch @@ -0,0 +1,89 @@ +From 2872f5d8bcef84e62b15b37ba4ffeccfb6402dad Mon Sep 17 00:00:00 2001 +From: rofl0r <retnyg@gmx.net> +Date: Wed, 22 Jan 2014 00:48:28 +0100 +Subject: [PATCH 1/3] libc-compat.h: fix some issues arising from in6.h + +namely redefinition of some structs provided by netinet/in.h. +--- +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Submitted + + include/uapi/linux/libc-compat.h | 25 ++++++++----------------- + 1 file changed, 8 insertions(+), 17 deletions(-) + +Index: linux-4.4/include/uapi/linux/libc-compat.h +=================================================================== +--- linux-4.4.orig/include/uapi/linux/libc-compat.h ++++ linux-4.4/include/uapi/linux/libc-compat.h +@@ -48,13 +48,12 @@ + #ifndef _UAPI_LIBC_COMPAT_H + #define _UAPI_LIBC_COMPAT_H + +-/* We have included glibc headers... */ +-#if defined(__GLIBC__) ++#ifndef __KERNEL__ /* we're used from userspace */ + +-/* Coordinate with glibc netinet/in.h header. */ ++/* Coordinate with libc netinet/in.h header. */ + #if defined(_NETINET_IN_H) + +-/* GLIBC headers included first so don't define anything ++/* LIBC headers included first so don't define anything + * that would already be defined. */ + #define __UAPI_DEF_IN_ADDR 0 + #define __UAPI_DEF_IN_IPPROTO 0 +@@ -64,15 +63,7 @@ + #define __UAPI_DEF_IN_CLASS 0 + + #define __UAPI_DEF_IN6_ADDR 0 +-/* The exception is the in6_addr macros which must be defined +- * if the glibc code didn't define them. This guard matches +- * the guard in glibc/inet/netinet/in.h which defines the +- * additional in6_addr macros e.g. s6_addr16, and s6_addr32. */ +-#if defined(__USE_MISC) || defined (__USE_GNU) + #define __UAPI_DEF_IN6_ADDR_ALT 0 +-#else +-#define __UAPI_DEF_IN6_ADDR_ALT 1 +-#endif + #define __UAPI_DEF_SOCKADDR_IN6 0 + #define __UAPI_DEF_IPV6_MREQ 0 + #define __UAPI_DEF_IPPROTO_V6 0 +@@ -80,10 +71,10 @@ + #define __UAPI_DEF_IN6_PKTINFO 0 + #define __UAPI_DEF_IP6_MTUINFO 0 + +-#else ++#else /* defined(_NETINET_IN_H) */ + + /* Linux headers included first, and we must define everything +- * we need. The expectation is that glibc will check the ++ * we need. The expectation is that libc will check the + * __UAPI_DEF_* defines and adjust appropriately. */ + #define __UAPI_DEF_IN_ADDR 1 + #define __UAPI_DEF_IN_IPPROTO 1 +@@ -93,7 +84,7 @@ + #define __UAPI_DEF_IN_CLASS 1 + + #define __UAPI_DEF_IN6_ADDR 1 +-/* We unconditionally define the in6_addr macros and glibc must ++/* We unconditionally define the in6_addr macros and libc must + * coordinate. */ + #define __UAPI_DEF_IN6_ADDR_ALT 1 + #define __UAPI_DEF_SOCKADDR_IN6 1 +@@ -115,7 +106,7 @@ + /* If we did not see any headers from any supported C libraries, + * or we are being included in the kernel, then define everything + * that we need. */ +-#else /* !defined(__GLIBC__) */ ++#else /* __KERNEL__ */ + + /* Definitions for in.h */ + #define __UAPI_DEF_IN_ADDR 1 +@@ -138,6 +129,6 @@ + /* Definitions for xattr.h */ + #define __UAPI_DEF_XATTR 1 + +-#endif /* __GLIBC__ */ ++#endif /* __KERNEL__ */ + + #endif /* _UAPI_LIBC_COMPAT_H */ diff --git a/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0002-libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0002-libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch new file mode 100644 index 000000000..c61709374 --- /dev/null +++ b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0002-libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch @@ -0,0 +1,59 @@ +From 75ba4a547282f91d653872a4bba5f5eae234ea6c Mon Sep 17 00:00:00 2001 +From: rofl0r <retnyg@gmx.net> +Date: Wed, 22 Jan 2014 00:57:48 +0100 +Subject: [PATCH 2/3] libc-compat.h: prevent redefinition of struct ethhdr + +--- +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Submitted + + include/uapi/linux/if_ether.h | 4 +++- + include/uapi/linux/libc-compat.h | 6 ++++++ + 2 files changed, 9 insertions(+), 1 deletion(-) + +diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h +index aa63ed0..e94da57 100644 +--- a/include/uapi/linux/if_ether.h ++++ b/include/uapi/linux/if_ether.h +@@ -22,6 +22,7 @@ + #define _UAPI_LINUX_IF_ETHER_H + + #include <linux/types.h> ++#include <linux/libc-compat.h> + + /* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble +@@ -134,11 +135,12 @@ + * This is an Ethernet frame header. + */ + ++#if __UAPI_DEF_ETHHDR + struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + __be16 h_proto; /* packet type ID field */ + } __attribute__((packed)); +- ++#endif + + #endif /* _UAPI_LINUX_IF_ETHER_H */ +diff --git a/include/uapi/linux/libc-compat.h b/include/uapi/linux/libc-compat.h +index afe15c2..7d0c78a 100644 +--- a/include/uapi/linux/libc-compat.h ++++ b/include/uapi/linux/libc-compat.h +@@ -50,6 +50,12 @@ + + #ifndef __KERNEL__ /* we're used from userspace */ + ++#ifdef _NETINET_IF_ETHER_H /* musl */ ++#define __UAPI_DEF_ETHHDR 0 ++#else /* glibc uses __NETINET_IF_ETHER_H, and includes the kernel header. */ ++#define __UAPI_DEF_ETHHDR 1 ++#endif ++ + /* Coordinate with libc netinet/in.h header. */ + #if defined(_NETINET_IN_H) + +-- +2.6.4 + diff --git a/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch new file mode 100644 index 000000000..6d9e8d864 --- /dev/null +++ b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers/0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch @@ -0,0 +1,32 @@ +From 8e69b663d6ddef132041a1186f081fdd74d4a31d Mon Sep 17 00:00:00 2001 +From: rofl0r <retnyg@gmx.net> +Date: Mon, 20 Jan 2014 21:31:34 +0100 +Subject: [PATCH 3/3] remove inclusion of sysinfo.h in kernel.h + +the declaration of struct sysinfo clashes with userspace. +it's not quite clear why that header was included from kernel.h, +as none of its functionality is needed. +--- +Signed-off-by: Khem Raj <raj.khem@gmail.com> +Upstream-Status: Submitted + + include/uapi/linux/kernel.h | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/include/uapi/linux/kernel.h b/include/uapi/linux/kernel.h +index 321e399..e8ff821 100644 +--- a/include/uapi/linux/kernel.h ++++ b/include/uapi/linux/kernel.h +@@ -1,7 +1,9 @@ + #ifndef _UAPI_LINUX_KERNEL_H + #define _UAPI_LINUX_KERNEL_H + ++#ifdef __GLIBC__ + #include <linux/sysinfo.h> ++#endif + + /* + * 'kernel.h' contains some often-used function prototypes etc +-- +2.6.4 + diff --git a/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.4.bb b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.4.bb new file mode 100644 index 000000000..3763dc0d3 --- /dev/null +++ b/import-layers/yocto-poky/meta/recipes-kernel/linux-libc-headers/linux-libc-headers_4.4.bb @@ -0,0 +1,9 @@ +require linux-libc-headers.inc + +SRC_URI_append_libc-musl = "\ + file://0001-libc-compat.h-fix-some-issues-arising-from-in6.h.patch \ + file://0002-libc-compat.h-prevent-redefinition-of-struct-ethhdr.patch \ + file://0003-remove-inclusion-of-sysinfo.h-in-kernel.h.patch \ + " +SRC_URI[md5sum] = "9a78fa2eb6c68ca5a40ed5af08142599" +SRC_URI[sha256sum] = "401d7c8fef594999a460d10c72c5a94e9c2e1022f16795ec51746b0d165418b2" |