From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/8641 Path: news.gmane.org!not-for-mail From: Denys Vlasenko 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: Fri, 9 Oct 2015 21:11:08 +0200 Message-ID: References: <5612925A.4070402@landley.net> <20151006014426.GL8645@brightrain.aerifal.cx> <20151008165808.GZ8645@brightrain.aerifal.cx> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1444417906 7758 80.91.229.3 (9 Oct 2015 19:11:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 9 Oct 2015 19:11:46 +0000 (UTC) Cc: Rob Landley , Aboriginal Linux , musl To: Rich Felker Original-X-From: musl-return-8653-gllmg-musl=m.gmane.org@lists.openwall.com Fri Oct 09 21:11:45 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 1Zkd4x-0004tG-CX for gllmg-musl@m.gmane.org; Fri, 09 Oct 2015 21:11:43 +0200 Original-Received: (qmail 28465 invoked by uid 550); 9 Oct 2015 19:11:40 -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 28441 invoked from network); 9 Oct 2015 19:11:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=yCPmMqUEhjMTGcsIt/0BAo+M5KombFS5Fh1NoLhGuuY=; b=joYnKbQ2gwmhYK8krqgHUi8rvAYpbFgY8WejNXUsRKi1YKU2sKc3M31BZGgerMd9v/ DfFYSdZbgz4muOTZmCk1rD7j8y0OobuHySLRBtJ73CRfSDjfM94Sn7wCTXW8IRFeeUYi rDGiZFkiVoeeM0SvIJL46LRMZJtR6mH9HxEGHEpn2bYwdzwrQdyDgqzI3SN4SAIlYlIG mUA6+7eTOeBJwPjx7Wi5/EM4y3vR9MfVi+UG4/CWfb9JYzf5Jy9kinVRc8anf9cYP3el XbByllOPCG2DJpEDi62Ws6LucgrEE/poTtrJdETpTUN4ZTBo83EQUL0AT+GtQkqJ7Pgx mmVQ== X-Received: by 10.140.202.210 with SMTP id x201mr18276276qha.0.1444417888011; Fri, 09 Oct 2015 12:11:28 -0700 (PDT) In-Reply-To: <20151008165808.GZ8645@brightrain.aerifal.cx> Xref: news.gmane.org gmane.linux.lib.musl.general:8641 Archived-At: On Thu, Oct 8, 2015 at 6:58 PM, Rich Felker wrote: >> > 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. :( Looking at kernel's libc-compat.h, it looks like you can get away with using __UAPI_DEF_foo's like this? #if defined(__UAPI_DEF_SOCKADDR_IN) && __UAPI_DEF_SOCKADDR_IN == 1 /* kernel already defined the struct, do nothing */ #else struct sockaddr_in { ... }; #undef __UAPI_DEF_SOCKADDR_IN /* tell kernel to not define the struct */ #define __UAPI_DEF_SOCKADDR_IN 0 #endif