From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6158 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: why is there no __MUSL__ macro? Date: Fri, 12 Sep 2014 11:37:32 -0400 Message-ID: <20140912153732.GQ23797@brightrain.aerifal.cx> References: <541180B9.5070604@posteo.de> <20140911164711.248bf3d7@ncopa-desktop.alpinelinux.org> <5412A23A.6080503@posteo.de> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Trace: ger.gmane.org 1410536401 16626 80.91.229.3 (12 Sep 2014 15:40:01 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Sep 2014 15:40:01 +0000 (UTC) Cc: musl@lists.openwall.com To: =?utf-8?B?SsO2cmc=?= Krause Original-X-From: musl-return-6171-gllmg-musl=m.gmane.org@lists.openwall.com Fri Sep 12 17:39:56 2014 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 1XSSx1-0004j3-1F for gllmg-musl@plane.gmane.org; Fri, 12 Sep 2014 17:39:55 +0200 Original-Received: (qmail 1992 invoked by uid 550); 12 Sep 2014 15:39:54 -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 1981 invoked from network); 12 Sep 2014 15:39:53 -0000 Content-Disposition: inline In-Reply-To: <5412A23A.6080503@posteo.de> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6158 Archived-At: On Fri, Sep 12, 2014 at 09:35:22AM +0200, Jörg Krause wrote: > > On 09/11/2014 04:47 PM, Natanael Copa wrote: > >On Thu, 11 Sep 2014 13:00:09 +0200 > >Jörg Krause wrote: > > > >>Hi, > >> > >>I am trying to add support for the musl toolchain to FFmpeg. > >> > >>FFmpeg needs support for library features defined in POSIX.1-2001 with > >>XSI extension and the standards below. Currently configure probes the > >>host and target libc by checking for defined macros like __GLIBC__ and > >>__UCLIBC__. In case of glibc and uclibc it sets -D_XOPEN_SOURCE=600 > >>properly. > >> > >>After this it checks for some combinations of hardware and the probed > >>libc to set some more compile options, if necessary. > >> > >>I know that musl does not have a macro __MUSL__ and I have read the > >>explanation. However, I don't understand what's meant by "[..] it's a > >>bug to assume a certain implementation has particular properties rather > >>than testing." and how does it affect the way FFmpeg probes for the libc. > >> > >>What could be a solution which supports musl? > >> > >>Many thanks! > >>Jörg > >This is what we do on alpine linux: > >http://git.alpinelinux.org/cgit/aports/tree/main/ffmpeg/fix-defines.patch > > > >--- ffmpeg-1.2.2.orig/libavutil/error.c > >+++ ffmpeg-1.2.2/libavutil/error.c > >@@ -17,6 +17,7 @@ > > */ > > #undef _GNU_SOURCE > >+#define _XOPEN_SOURCE 600 > > #include "avutil.h" > > #include "avstring.h" > > #include "common.h" > > > > Hi Natanal, > > I had a look to alpine already. I submitted this patch to FFmpeg, > but building FFmpeg with my configuration libavutils/error.c is not > the only file which needs a feature test macro. The people of FFmpeg > did not like the idea to have a lot of test macros in there source > so I stopped with this solution and looked for a way to adopt the > musl toolchain to their configure file. It might work to add -D_DEFAULT_SOURCE (note: not available until recent musl git) or -D_BSD_SOURCE to the global CFLAGS. What's happening, I think, is that because -std=c99 or similar is in the CFLAGS, default feature profile is getting suppressed, and _GNU_SOURCE is the only thing bringing back the usual features (in addition to lots of _GNU_SOURCE-only stuff, and strerror_r breakage). Having at least one more feature test macro defined globally would prevent this. Note also that modern glibc supports _DEFAULT_SOURCE, with the same semantics as musl: keeping the default stuff exposed even when a -std=* option would otherwise suppress it. Rich