From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/664 Path: news.gmane.org!not-for-mail From: Isaac Dunham Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH 0/4] Fix function definitions. Date: Fri, 16 Mar 2012 12:05:42 -0700 Message-ID: <20120316120542.82a478fe.idunham@lavabit.com> References: <1331280854-9080-1-git-send-email-gf@unixsol.org> <4F59BD70.9020105@unixsol.org> <20120309083358.GA184@brightrain.aerifal.cx> <4F59CA50.5060407@unixsol.org> <4F5A1D89.9090304@landley.net> <20120309163853.GF184@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 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1331924756 16720 80.91.229.3 (16 Mar 2012 19:05:56 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 16 Mar 2012 19:05:56 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-665-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 16 20:05:56 2012 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1S8cTL-0002QZ-Nf for gllmg-musl@plane.gmane.org; Fri, 16 Mar 2012 20:05:55 +0100 Original-Received: (qmail 12116 invoked by uid 550); 16 Mar 2012 19:05:55 -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 12108 invoked from network); 16 Mar 2012 19:05:54 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=lavabit; d=lavabit.com; b=YrSIpZq0aDLxzCGH4+qtoRl1QN1sVlhfxuSIOTlJMpfuyK5pvWFFdSmZ9ZbqtLMq001i1CwvMMffQYbpHyXPQRZ1/BnyVDoRA3uo1nvXFBOSteGARzU+5WqTLTQCJWttbT3HopgkQRkYkn7XWVA7ITOIsak6Mzxx0DEd8NLCPzg=; h=Date:From:To:Subject:Message-Id:In-Reply-To:References:X-Mailer:Mime-Version:Content-Type:Content-Transfer-Encoding; In-Reply-To: <20120309163853.GF184@brightrain.aerifal.cx> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Xref: news.gmane.org gmane.linux.lib.musl.general:664 Archived-At: On Fri, 9 Mar 2012 11:38:53 -0500 Rich Felker wrote: > On Fri, Mar 09, 2012 at 09:11:05AM -0600, Rob Landley wrote: > > Why are you doing feature test macros at _all_ in a 2012 Linux libc? If > > you don't #define any of them (which most code doesn't), you get (from > > /usr/lib/features.h): > > features.h is part of glibc, and not a part I like, for several > reasons: > > 1. Each additional nested header increases base compile time > significantly, and makes a big difference for small translation units > that only includes one header themselves, due to extra path search, > open, read, parse, close, etc. > > 2. The way glibc does features.h, with _xxx_SOURCE macros as the input > and __USE_xxx macros as the output, obfuscates in the actual headers > which macros are necessary or sufficient to get the desired interface > declared. > > 3. Others I'm forgetting at the moment.. :-) > > Relying on that is not portable, and musl does not do it. On > Linux/glibc you get the kitchen sink when you define nothing. On most > other unices, you get an intentionally-broken legacy environment > that's not conformant to modern standards. > > All projects should explicitly define the feature test macros they > want. This also assists you in profiling the portability of your code > (switching out _GNU_SOURCE and you see exactly what extensions you're > using). Thankfully for ones that fail to do this, you can just add the > appropriate -D's to CPPFLAGS. Strikes me that just because you don't #include in every other header doesn't require making it a NOP. I don't think features.h is in the reserved namespace. So why not have #define _KITCHEN_SINK_SOURCE in there, and let whoever wants that go #include ? Just because it converts macros internally, or GNU includes it, doesn't mean you have to include it or handle macros same way to ship it in a semi-compatible state. IF a programmer #include's features.h themselves, they asked for the kitchen sink; ignoring that is wrong. > Anyway, the reason I've not focused on adding _BSD_SOURCE is mainly > lack of necessity. I don't think I've encountered a single package > that was defining _BSD_SOURCE and failed to build because of things it > expected to get from _BSD_SOURCE. If there are major packages that > could be made easier to build by adding it, I'd be a lot more > interested in doing so. > > > I don't care about granularity, I just want my code to work. But I > > refuse to #define _ALL_HAIL_RICHARD_STALLMAN as a condition of using > > standard Linux functions. > > > > I will not say _GNU_SOURCE when implementing a project that has nothing > > whatsoever to do with the FSF's GNU project, and acts to replace large > > chunks of its' userspace. .. > > >> I think there's a good (nontrivial) discussion to be had about whether > > >> it's worthwhile to have the _BSD_SOURCE and _SVID_SOURCE feature test > > >> macros supported in musl. > > > > Given that the "nothing is #defined" behavior gives you most of this > > anyway on both glibc and uClibc, why musl is bothering with it at _all_ > > is kinda inexplicable to me. > > Because unlike uClibc, musl does not just copy all the mess from > glibc. I'd like to see at least _BSD_SOURCE available, provided that 1. It actually is a BSD-ish API, with similar scope to NetBSD or glibc's _BSD_SOURCE 2. It isn't autodefined when using standard headers. > > ... And it means that Musl can't build code that not just > > glibc and uClibc can build out of the box, but BSD can too. (chroot() > > was _not_ invented by the gnu/dammit project.) > > It's not my intent to imply that any of these features were invented > by the GNU project. Rather, _GNU_SOURCE is simply the only existing > feature test macro for "kitchen sink" that exists on Linux systems. .. The ONLY existing macro? _BSD_SOURCE is an existing macro, and while it isn't the FULL kitchen sink, it's a lot closer. (and apparently close enough for toybox?) Also, you seem to be arguing that if it's automatically defined, then it's not standards compliant, and assume that if the standards say we can't do that, there's no reason to implement it at all. Here's my proposal: Would it work to implement _BSD_SOURCE and leave features.h lying around (read: implemented, but NOT included in any system headers) with this content: #warn "features.h is not portable- use -D_BSD_SOURCE" #if ((!defined _POSIX_C_SOURCE || _XOPEN_SOURCE || _BSD_SOURCE || _GNU_SOURCE || __STRICT_ANSI__ || _POSIX_SOURCE )) #define _BSD_SOURCE #define _POSIX_C_SOURCE 200809L #endif -- Isaac Dunham