From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8636 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Re: musl and kernel headers [was Re: system-images 1.4.2: od is broken; bzip2 is missing] Date: Thu, 8 Oct 2015 12:58:08 -0400 Message-ID: <20151008165808.GZ8645@brightrain.aerifal.cx> References: <5612925A.4070402@landley.net> <20151006014426.GL8645@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1444323514 19941 80.91.229.3 (8 Oct 2015 16:58:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 8 Oct 2015 16:58:34 +0000 (UTC) Cc: Rob Landley , Aboriginal Linux , musl To: Denys Vlasenko Original-X-From: musl-return-8648-gllmg-musl=m.gmane.org@lists.openwall.com Thu Oct 08 18:58:29 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1ZkEWS-000127-Aw for gllmg-musl@m.gmane.org; Thu, 08 Oct 2015 18:58:28 +0200 Original-Received: (qmail 17762 invoked by uid 550); 8 Oct 2015 16:58:25 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 17732 invoked from network); 8 Oct 2015 16:58:24 -0000 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Xref: news.gmane.org gmane.linux.lib.musl.general:8636 Archived-At: On Tue, Oct 06, 2015 at 06:09:15PM +0200, Denys Vlasenko wrote: > On Tue, Oct 6, 2015 at 3:44 AM, Rich Felker wrote: > >> > > >> > #include > >> > #include > >> > results in: > >> > In file included from /usr/include/linux/if_bridge.h:18, > >> > from networking/brctl.c:67: > >> > /usr/include/linux/in6.h:32: error: redefinition of 'struct in6_addr' > >> > /usr/include/linux/in6.h:49: error: redefinition of 'struct sockaddr_in6' > >> > /usr/include/linux/in6.h:59: error: redefinition of 'struct ipv6_mreq' > >> > > >> > and > >> > > >> > #include > >> > #include > >> > results in: > >> > In file included from /usr/include/net/ethernet.h:10, > >> > from networking/ifplugd.c:41: > >> > /usr/include/netinet/if_ether.h:96: error: redefinition of 'struct ethhdr' > >> > > >> > >> That I leave to Rich. :) > > > > Including kernel headers is just really problematic. These days they > > try to make it work on glibc with a complex dance between glibc's > > headers and the kernel headers. You're likely to have the best luck by > > including the libc headers first. > > brctl.c was including after The problem is linux/libc-compat.h, which should fix this, only works on glibc, by design. See: #ifndef _LIBC_COMPAT_H #define _LIBC_COMPAT_H /* We have included glibc headers... */ #if defined(__GLIBC__) /* Coordinate with glibc netinet/in.h header. */ #if defined(_NETINET_IN_H) If you patch it like this: -#if defined(__GLIBC__) +#if 1 then it should mostly work but it's still all a big hack. I think that's what distros are doing. The problem is that the same header is trying to do two different things: 1. Provide extra linux-kernel-API stuff that's not in the libc/userspace headers. 2. Provide definitions of the standard types and constants for uClibc and klibc, which don't have complete libc headers and rely on the kernel headers for definitions. These two uses really should be separated out into separate headers so that the latter only get included explicitly by uClibc and klibc and otherwise remain completely unused. But that would require coordinated changes/upgrades which are unlikely to happen. :( Rich