Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20151008165808.GZ8645@brightrain.aerifal.cx>
Date: Thu, 8 Oct 2015 12:58:08 -0400
From: Rich Felker <dalias@...ifal.cx>
To: Denys Vlasenko <vda.linux@...glemail.com>
Cc: Rob Landley <rob@...dley.net>,
	Aboriginal Linux <aboriginal@...ts.landley.net>,
	musl <musl@...ts.openwall.com>
Subject: Re: Re: musl and kernel headers [was Re: system-images 1.4.2:
 od is broken; bzip2 is missing]

On Tue, Oct 06, 2015 at 06:09:15PM +0200, Denys Vlasenko wrote:
> On Tue, Oct 6, 2015 at 3:44 AM, Rich Felker <dalias@...ifal.cx> wrote:
> >> >
> >> >   #include <netinet/in.h>
> >> >   #include <linux/if_bridge.h>
> >> > 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 <linux/ethtool.h>
> >> >   #include <net/ethernet.h>
> >> > 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 <linux/if_bridge.h> after <netinet/in.h>

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

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.