All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] musl: add more kernel headers guards
@ 2018-02-13 12:27 Baruch Siach
  2018-02-13 12:27 ` [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround Baruch Siach
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Baruch Siach @ 2018-02-13 12:27 UTC (permalink / raw)
  To: buildroot

Kernel version 4.15 (not 4.16 as the musl commit log claims) allows
disabling of more parts of the kernel headers definitions. Add upstream
musl patch that defines the relevant macros. This solves issues of
networking related symbols redefinition in kernel headers that cause
headers conflicts. With that in place a subsequent commit will limit the
musl/kernel headers conflict avoidance workaround in Buildroot to kernel
headers older than 4.15. This workaround has been introduced in commit
196932cd91 (toolchain: workaround musl/kernel headers conflict).

Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 ...nal-uapi-guards-for-Linux-kernel-header-f.patch | 69 ++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 package/musl/0002-add-additional-uapi-guards-for-Linux-kernel-header-f.patch

diff --git a/package/musl/0002-add-additional-uapi-guards-for-Linux-kernel-header-f.patch b/package/musl/0002-add-additional-uapi-guards-for-Linux-kernel-header-f.patch
new file mode 100644
index 000000000000..cbfc9b668f91
--- /dev/null
+++ b/package/musl/0002-add-additional-uapi-guards-for-Linux-kernel-header-f.patch
@@ -0,0 +1,69 @@
+From b583c5d3b4cc2c54c68eef5eb7855ecfacee8bfc Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke@hauke-m.de>
+Date: Sat, 6 Jan 2018 23:32:52 +0100
+Subject: [PATCH] add additional uapi guards for Linux kernel header files
+
+With Linux kernel 4.16 it will be possible to guard more parts of the
+Linux header files from a libc. Make use of this in musl to guard all
+the structures and other definitions from the Linux header files which
+are also defined by the header files provided by musl. This will make
+it possible to compile source files which include both the libc
+headers and the kernel userspace headers.
+
+This extends the definitions done in commit 04983f227238 ("make
+netinet/in.h suppress clashing definitions from kernel headers")
+
+Signed-off-by: Baruch Siach <baruch@tkos.co.il>
+---
+Patch status: upstream commit b583c5d3b4cc
+
+ include/net/if.h           | 7 +++++++
+ include/netinet/if_ether.h | 1 +
+ include/sys/xattr.h        | 2 ++
+ 3 files changed, 10 insertions(+)
+
+diff --git a/include/net/if.h b/include/net/if.h
+index 2f2fcc10e484..774cbff0b506 100644
+--- a/include/net/if.h
++++ b/include/net/if.h
+@@ -125,6 +125,13 @@ struct ifconf {
+ #define ifc_req		ifc_ifcu.ifcu_req
+ #define _IOT_ifconf _IOT(_IOTS(struct ifconf),1,0,0,0,0)
+ 
++#define __UAPI_DEF_IF_IFCONF                                    0
++#define __UAPI_DEF_IF_IFMAP                                     0
++#define __UAPI_DEF_IF_IFNAMSIZ                                  0
++#define __UAPI_DEF_IF_IFREQ                                     0
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS                          0
++#define __UAPI_DEF_IF_NET_DEVICE_FLAGS_LOWER_UP_DORMANT_ECHO    0
++
+ #endif
+ 
+ #ifdef __cplusplus
+diff --git a/include/netinet/if_ether.h b/include/netinet/if_ether.h
+index d9a131aa2d1d..97134d75b480 100644
+--- a/include/netinet/if_ether.h
++++ b/include/netinet/if_ether.h
+@@ -133,5 +133,6 @@ do { \
+ 	(enaddr)[5] = ((uint8_t *)ipaddr)[3]; \
+ } while(0)
+ 
++#define __UAPI_DEF_ETHHDR       0
+ 
+ #endif
+diff --git a/include/sys/xattr.h b/include/sys/xattr.h
+index 6479fcc62e5f..eeeaafc44f09 100644
+--- a/include/sys/xattr.h
++++ b/include/sys/xattr.h
+@@ -24,6 +24,8 @@ int removexattr(const char *, const char *);
+ int lremovexattr(const char *, const char *);
+ int fremovexattr(int, const char *);
+ 
++#define __UAPI_DEF_XATTR        0
++
+ #ifdef __cplusplus
+ }
+ #endif
+-- 
+2.15.1
+
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround
  2018-02-13 12:27 [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Baruch Siach
@ 2018-02-13 12:27 ` Baruch Siach
  2018-03-30 19:19   ` Peter Korsgaard
  2018-02-13 12:32 ` [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Thomas Petazzoni
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 7+ messages in thread
From: Baruch Siach @ 2018-02-13 12:27 UTC (permalink / raw)
  To: buildroot

The musl/kernel headers workaround was added in commit 196932cd91
(toolchain: workaround musl/kernel headers conflict) to fix definition
collisions in networking related headers between musl headers and kernel
headers. Kernel headers from version 4.15 and newer do not need this
workaround anymore since kernel commit c0bace798436bc (uapi libc compat:
add fallback for unsupported libcs). The C library does not have to
define the __GLIBC__ macro to make the __UAPI_DEF_* macros effective.

Updated the comment to accordingly.

Tested with the xl2tp package. This package fails to build with older
kernel headers without the workaround (struct in_pktinfo redefinition,
among others). With 4.15 headers, xl2tp builds fine with this patch
applied. That is, no workaround needed.

Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Baruch Siach <baruch@tkos.co.il>
---
 toolchain/toolchain/toolchain.mk | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/toolchain/toolchain/toolchain.mk b/toolchain/toolchain/toolchain.mk
index b55b0c712cb9..179c09edf1ad 100644
--- a/toolchain/toolchain/toolchain.mk
+++ b/toolchain/toolchain/toolchain.mk
@@ -13,18 +13,18 @@ endif
 TOOLCHAIN_ADD_TOOLCHAIN_DEPENDENCY = NO
 
 # Apply a hack that Rick Felker suggested[1] to avoid conflicts between libc
-# headers and kernel headers. This is a temporary measure until musl finds a
-# better solution.
+# headers and kernel headers. This is needed for kernel headers older than
+# 4.15. Kernel headers 4.15 and newer don't require __GLIBC__ to be defined.
 #
 # Augment the original suggestion with __USE_MISC since recent kernels
-# require this glibc internal macro. Also, as musl defines IFF_LOWER_UP,
-# IFF_DORMANT and IFF_ECHO, add another macro to suppress them in the
-# kernel header, and avoid macro/enum conflict.
+# (older than 4.15) require this glibc internal macro. Also, as musl defines
+# IFF_LOWER_UP, IFF_DORMANT and IFF_ECHO, add another macro to suppress
+# them in the kernel header, and avoid macro/enum conflict.
 #
 # Kernel version 3.12 introduced the libc-compat.h header.
 #
 # [1] http://www.openwall.com/lists/musl/2015/10/08/2
-ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12),yy)
+ifeq ($(BR2_TOOLCHAIN_USES_MUSL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12):$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_15),yy:)
 define TOOLCHAIN_MUSL_KERNEL_HEADERS_COMPATIBILITY_HACK
 	$(SED) 's/^#if defined(__GLIBC__)$$/#if 1/' \
 		$(STAGING_DIR)/usr/include/linux/libc-compat.h
-- 
2.15.1

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 1/2] musl: add more kernel headers guards
  2018-02-13 12:27 [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Baruch Siach
  2018-02-13 12:27 ` [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround Baruch Siach
@ 2018-02-13 12:32 ` Thomas Petazzoni
  2018-02-13 12:47   ` Baruch Siach
  2018-02-14 21:02 ` Thomas Petazzoni
  2018-03-30 19:19 ` Peter Korsgaard
  3 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2018-02-13 12:32 UTC (permalink / raw)
  To: buildroot

Hello Baruch,

On Tue, 13 Feb 2018 14:27:49 +0200, Baruch Siach wrote:
> Kernel version 4.15 (not 4.16 as the musl commit log claims) allows
> disabling of more parts of the kernel headers definitions. Add upstream
> musl patch that defines the relevant macros. This solves issues of
> networking related symbols redefinition in kernel headers that cause
> headers conflicts. With that in place a subsequent commit will limit the
> musl/kernel headers conflict avoidance workaround in Buildroot to kernel
> headers older than 4.15. This workaround has been introduced in commit
> 196932cd91 (toolchain: workaround musl/kernel headers conflict).
> 
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Thanks for those patches, it's great to see that you continue to
follow this header conflict issue. You didn't specify explicitly if you
intend them for master or next. At this point, I don't see a reason to
need them for master, so it's probably material for next. Do you agree ?

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
http://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 1/2] musl: add more kernel headers guards
  2018-02-13 12:32 ` [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Thomas Petazzoni
@ 2018-02-13 12:47   ` Baruch Siach
  0 siblings, 0 replies; 7+ messages in thread
From: Baruch Siach @ 2018-02-13 12:47 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

On Tue, Feb 13, 2018 at 01:32:30PM +0100, Thomas Petazzoni wrote:
> On Tue, 13 Feb 2018 14:27:49 +0200, Baruch Siach wrote:
> > Kernel version 4.15 (not 4.16 as the musl commit log claims) allows
> > disabling of more parts of the kernel headers definitions. Add upstream
> > musl patch that defines the relevant macros. This solves issues of
> > networking related symbols redefinition in kernel headers that cause
> > headers conflicts. With that in place a subsequent commit will limit the
> > musl/kernel headers conflict avoidance workaround in Buildroot to kernel
> > headers older than 4.15. This workaround has been introduced in commit
> > 196932cd91 (toolchain: workaround musl/kernel headers conflict).
> > 
> > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> > Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> 
> Thanks for those patches, it's great to see that you continue to
> follow this header conflict issue. You didn't specify explicitly if you
> intend them for master or next. At this point, I don't see a reason to
> need them for master, so it's probably material for next. Do you agree ?

Of course. Sorry. I didn't say that explicitly because I thought it obviously 
belongs to next. These patches would better see lots of autobuilders testing. 
Until the musl toolchains get rebuilt, only internal musl toolchain builds 
will actually test this code.

By the way, you should probably update the email address in your DEVELOPERS 
entry.

baruch

-- 
     http://baruch.siach.name/blog/                  ~. .~   Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
   - baruch at tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 1/2] musl: add more kernel headers guards
  2018-02-13 12:27 [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Baruch Siach
  2018-02-13 12:27 ` [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround Baruch Siach
  2018-02-13 12:32 ` [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Thomas Petazzoni
@ 2018-02-14 21:02 ` Thomas Petazzoni
  2018-03-30 19:19 ` Peter Korsgaard
  3 siblings, 0 replies; 7+ messages in thread
From: Thomas Petazzoni @ 2018-02-14 21:02 UTC (permalink / raw)
  To: buildroot

Hello,

On Tue, 13 Feb 2018 14:27:49 +0200, Baruch Siach wrote:
> Kernel version 4.15 (not 4.16 as the musl commit log claims) allows
> disabling of more parts of the kernel headers definitions. Add upstream
> musl patch that defines the relevant macros. This solves issues of
> networking related symbols redefinition in kernel headers that cause
> headers conflicts. With that in place a subsequent commit will limit the
> musl/kernel headers conflict avoidance workaround in Buildroot to kernel
> headers older than 4.15. This workaround has been introduced in commit
> 196932cd91 (toolchain: workaround musl/kernel headers conflict).
> 
> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
> Signed-off-by: Baruch Siach <baruch@tkos.co.il>
> ---
>  ...nal-uapi-guards-for-Linux-kernel-header-f.patch | 69 ++++++++++++++++++++++
>  1 file changed, 69 insertions(+)
>  create mode 100644 package/musl/0002-add-additional-uapi-guards-for-Linux-kernel-header-f.patch

Both applied to next. Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin (formerly Free Electrons)
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 1/2] musl: add more kernel headers guards
  2018-02-13 12:27 [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Baruch Siach
                   ` (2 preceding siblings ...)
  2018-02-14 21:02 ` Thomas Petazzoni
@ 2018-03-30 19:19 ` Peter Korsgaard
  3 siblings, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2018-03-30 19:19 UTC (permalink / raw)
  To: buildroot

>>>>> "Baruch" == Baruch Siach <baruch@tkos.co.il> writes:

 > Kernel version 4.15 (not 4.16 as the musl commit log claims) allows
 > disabling of more parts of the kernel headers definitions. Add upstream
 > musl patch that defines the relevant macros. This solves issues of
 > networking related symbols redefinition in kernel headers that cause
 > headers conflicts. With that in place a subsequent commit will limit the
 > musl/kernel headers conflict avoidance workaround in Buildroot to kernel
 > headers older than 4.15. This workaround has been introduced in commit
 > 196932cd91 (toolchain: workaround musl/kernel headers conflict).

 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 > Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Committed to 2018.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround
  2018-02-13 12:27 ` [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround Baruch Siach
@ 2018-03-30 19:19   ` Peter Korsgaard
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Korsgaard @ 2018-03-30 19:19 UTC (permalink / raw)
  To: buildroot

>>>>> "Baruch" == Baruch Siach <baruch@tkos.co.il> writes:

 > The musl/kernel headers workaround was added in commit 196932cd91
 > (toolchain: workaround musl/kernel headers conflict) to fix definition
 > collisions in networking related headers between musl headers and kernel
 > headers. Kernel headers from version 4.15 and newer do not need this
 > workaround anymore since kernel commit c0bace798436bc (uapi libc compat:
 > add fallback for unsupported libcs). The C library does not have to
 > define the __GLIBC__ macro to make the __UAPI_DEF_* macros effective.

 > Updated the comment to accordingly.

 > Tested with the xl2tp package. This package fails to build with older
 > kernel headers without the workaround (struct in_pktinfo redefinition,
 > among others). With 4.15 headers, xl2tp builds fine with this patch
 > applied. That is, no workaround needed.

 > Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
 > Signed-off-by: Baruch Siach <baruch@tkos.co.il>

Committed to 2018.02.x, thanks.

-- 
Bye, Peter Korsgaard

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-03-30 19:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 12:27 [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Baruch Siach
2018-02-13 12:27 ` [Buildroot] [PATCH 2/2] toolchain: limit musl/kernel headers conflict workaround Baruch Siach
2018-03-30 19:19   ` Peter Korsgaard
2018-02-13 12:32 ` [Buildroot] [PATCH 1/2] musl: add more kernel headers guards Thomas Petazzoni
2018-02-13 12:47   ` Baruch Siach
2018-02-14 21:02 ` Thomas Petazzoni
2018-03-30 19:19 ` Peter Korsgaard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.