Mention that DragonFly BSD requires __BSD_VISIBLE set

Message ID 1303422496-95077-1-git-send-email-martin@martin.st
State Committed
Headers show

Commit Message

Martin Storsjö April 21, 2011, 9:48 p.m.
Setting this should fix the FATE build failure on DragonFly BSD,
since inet_aton only is visible if __BSD_VISIBLE is set.

Alternatively, a line defining __BSD_VISIBLE=1 could be
added at the top of os_support.c. For FreeBSD, similar lines
are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
---
 doc/general.texi |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Ronald Bultje April 21, 2011, 10:30 p.m. | #1
Hi,

On Thu, Apr 21, 2011 at 5:48 PM, Martin Storsjö <martin@martin.st> wrote:
> Setting this should fix the FATE build failure on DragonFly BSD,
> since inet_aton only is visible if __BSD_VISIBLE is set.
>
> Alternatively, a line defining __BSD_VISIBLE=1 could be
> added at the top of os_support.c. For FreeBSD, similar lines
> are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
> ---
>  doc/general.texi |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Can't we detect BSD subtype automatically and set __BSD_VISIBLE=1
directly? Mans/Diego?

Ronald
Diego Biurrun April 22, 2011, 9:32 a.m. | #2
On Thu, Apr 21, 2011 at 06:30:57PM -0400, Ronald S. Bultje wrote:
> 
> On Thu, Apr 21, 2011 at 5:48 PM, Martin Storsjö <martin@martin.st> wrote:
> > Setting this should fix the FATE build failure on DragonFly BSD,
> > since inet_aton only is visible if __BSD_VISIBLE is set.
> >
> > Alternatively, a line defining __BSD_VISIBLE=1 could be
> > added at the top of os_support.c. For FreeBSD, similar lines
> > are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
> > ---
> >  doc/general.texi |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> Can't we detect BSD subtype automatically and set __BSD_VISIBLE=1
> directly? Mans/Diego?

Yes, it could be done in configure.

Diego
Diego Biurrun April 22, 2011, 9:36 a.m. | #3
On Fri, Apr 22, 2011 at 12:48:16AM +0300, Martin Storsjö wrote:
> Setting this should fix the FATE build failure on DragonFly BSD,
> since inet_aton only is visible if __BSD_VISIBLE is set.
> 
> --- a/doc/general.texi
> +++ b/doc/general.texi
> @@ -784,9 +784,9 @@ to configure.
>  
> -@subsubsection FreeBSD
> +@subsubsection FreeBSD, DragonFly BSD
>  
> -FreeBSD will not compile out-of-the-box due to broken system headers.
> +FreeBSD and DragonFly BSD will not compile out-of-the-box due to broken system headers.

  These systems will not compile ...

Let's refactor the sentence and be prepared for next years BSD fork
du jour.  Push with that change please.

Diego
Martin Storsjö April 22, 2011, 9:07 p.m. | #4
On Fri, 22 Apr 2011, Diego Biurrun wrote:

> On Fri, Apr 22, 2011 at 12:48:16AM +0300, Martin Storsjö wrote:
> > Setting this should fix the FATE build failure on DragonFly BSD,
> > since inet_aton only is visible if __BSD_VISIBLE is set.
> > 
> > --- a/doc/general.texi
> > +++ b/doc/general.texi
> > @@ -784,9 +784,9 @@ to configure.
> >  
> > -@subsubsection FreeBSD
> > +@subsubsection FreeBSD, DragonFly BSD
> >  
> > -FreeBSD will not compile out-of-the-box due to broken system headers.
> > +FreeBSD and DragonFly BSD will not compile out-of-the-box due to broken system headers.
> 
>   These systems will not compile ...
> 
> Let's refactor the sentence and be prepared for next years BSD fork
> du jour.  Push with that change please.

Pushed.

// Martin
Mans Rullgard April 22, 2011, 9:49 p.m. | #5
"Ronald S. Bultje" <rsbultje@gmail.com> writes:

> Hi,
>
> On Thu, Apr 21, 2011 at 5:48 PM, Martin Storsjö <martin@martin.st> wrote:
>> Setting this should fix the FATE build failure on DragonFly BSD,
>> since inet_aton only is visible if __BSD_VISIBLE is set.
>>
>> Alternatively, a line defining __BSD_VISIBLE=1 could be
>> added at the top of os_support.c. For FreeBSD, similar lines
>> are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
>> ---
>>  doc/general.texi |    4 ++--
>>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> Can't we detect BSD subtype automatically and set __BSD_VISIBLE=1
> directly? Mans/Diego?

__BSD_VISIBLE should not be set directly, IIRC.  _BSD_SOURCE is the
correct symbol to define.  This can be done with add_cppflags -D_BSD_SOURCE
in the relevant OS sections in configure.
Martin Storsjö April 22, 2011, 9:56 p.m. | #6
On Fri, 22 Apr 2011, Måns Rullgård wrote:

> "Ronald S. Bultje" <rsbultje@gmail.com> writes:
> 
> > Hi,
> >
> > On Thu, Apr 21, 2011 at 5:48 PM, Martin Storsjö <martin@martin.st> wrote:
> >> Setting this should fix the FATE build failure on DragonFly BSD,
> >> since inet_aton only is visible if __BSD_VISIBLE is set.
> >>
> >> Alternatively, a line defining __BSD_VISIBLE=1 could be
> >> added at the top of os_support.c. For FreeBSD, similar lines
> >> are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
> >> ---
> >>  doc/general.texi |    4 ++--
> >>  1 files changed, 2 insertions(+), 2 deletions(-)
> >
> > Can't we detect BSD subtype automatically and set __BSD_VISIBLE=1
> > directly? Mans/Diego?
> 
> __BSD_VISIBLE should not be set directly, IIRC.  _BSD_SOURCE is the
> correct symbol to define.  This can be done with add_cppflags -D_BSD_SOURCE
> in the relevant OS sections in configure.

Yes, the *_VISIBLE macros sound like things that shouldn't be set 
manually. Nevertheless, defining _BSD_SOURCE isn't enough for getting the 
inet_aton prototype on DragonFly at least.

// Martin
Mans Rullgard April 22, 2011, 10:14 p.m. | #7
Martin Storsjö <martin@martin.st> writes:

> On Fri, 22 Apr 2011, Måns Rullgård wrote:
>
>> "Ronald S. Bultje" <rsbultje@gmail.com> writes:
>> 
>> > Hi,
>> >
>> > On Thu, Apr 21, 2011 at 5:48 PM, Martin Storsjö <martin@martin.st> wrote:
>> >> Setting this should fix the FATE build failure on DragonFly BSD,
>> >> since inet_aton only is visible if __BSD_VISIBLE is set.
>> >>
>> >> Alternatively, a line defining __BSD_VISIBLE=1 could be
>> >> added at the top of os_support.c. For FreeBSD, similar lines
>> >> are required in libavdevice/bktr.c and libavdevice/oss_audio.c, too.
>> >> ---
>> >>  doc/general.texi |    4 ++--
>> >>  1 files changed, 2 insertions(+), 2 deletions(-)
>> >
>> > Can't we detect BSD subtype automatically and set __BSD_VISIBLE=1
>> > directly? Mans/Diego?
>> 
>> __BSD_VISIBLE should not be set directly, IIRC.  _BSD_SOURCE is the
>> correct symbol to define.  This can be done with add_cppflags -D_BSD_SOURCE
>> in the relevant OS sections in configure.
>
> Yes, the *_VISIBLE macros sound like things that shouldn't be set 
> manually. Nevertheless, defining _BSD_SOURCE isn't enough for getting the 
> inet_aton prototype on DragonFly at least.

Then find the right thing to define.
Martin Storsjö April 23, 2011, 10:04 a.m. | #8
On Fri, 22 Apr 2011, Måns Rullgård wrote:

> Martin Storsjö <martin@martin.st> writes:
> 
> > On Fri, 22 Apr 2011, Måns Rullgård wrote:
> >
> >> __BSD_VISIBLE should not be set directly, IIRC.  _BSD_SOURCE is the
> >> correct symbol to define.  This can be done with add_cppflags -D_BSD_SOURCE
> >> in the relevant OS sections in configure.
> >
> > Yes, the *_VISIBLE macros sound like things that shouldn't be set 
> > manually. Nevertheless, defining _BSD_SOURCE isn't enough for getting the 
> > inet_aton prototype on DragonFly at least.
> 
> Then find the right thing to define.

As far as I can see, there's nothing else you can define to make it work, 
except undefining _POSIX_C_SOURCE. Here's the relevant parts of 
sys/cdefs.h 
(http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=sys/sys/cdefs.h):

#ifdef _POSIX_C_SOURCE
/* ...
 * Checking exact version of _POSIX_C_SOURCE, never setting __BSD_VISIBLE 
 */
#else
/* ...
 * If a program mistakenly defines _ANSI_SOURCE and some other macro such 
as
 * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
 * environment (and in fact we will never get here).
 */
#ifdef _ANSI_SOURCE             /* Hide almost everything. */
#define __POSIX_VISIBLE         0
#define __XSI_VISIBLE           0
#define __BSD_VISIBLE           0
#define __ISO_C_VISIBLE         1990
#elif defined(_C99_SOURCE)      /* Localism to specify strict C99 env. */
#define __POSIX_VISIBLE         0
#define __XSI_VISIBLE           0
#define __BSD_VISIBLE           0
#define __ISO_C_VISIBLE         1999
#else                           /* Default environment: show everything. 
*/
#define __POSIX_VISIBLE         200112
#define __XSI_VISIBLE           600
#define __BSD_VISIBLE           1
#define __ISO_C_VISIBLE         1999
#endif

#endif

This is the only place __BSD_VISIBLE is set under /usr/include as far as I 
can see, and as long as _POSIX_C_SOURCE is defined, it will never be 
defined. And __BSD_VISIBLE is required for inet_aton to be visible: 
http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=include/arpa/inet.h

Didn't perform the same check for FreeBSD yet, though...

// Martin
Diego Biurrun April 23, 2011, 10:26 a.m. | #9
On Sat, Apr 23, 2011 at 01:04:49PM +0300, Martin Storsjö wrote:
> 
> As far as I can see, there's nothing else you can define to make it work, 
> except undefining _POSIX_C_SOURCE. Here's the relevant parts of 
> sys/cdefs.h 
> (http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=sys/sys/cdefs.h):
> 
> #ifdef _POSIX_C_SOURCE
> /* ...
>  * Checking exact version of _POSIX_C_SOURCE, never setting __BSD_VISIBLE 
>  */
> #else
> /* ...
>  * If a program mistakenly defines _ANSI_SOURCE and some other macro such 
> as
>  * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
>  * environment (and in fact we will never get here).
>  */
> #ifdef _ANSI_SOURCE             /* Hide almost everything. */
> #define __POSIX_VISIBLE         0
> #define __XSI_VISIBLE           0
> #define __BSD_VISIBLE           0
> #define __ISO_C_VISIBLE         1990
> #elif defined(_C99_SOURCE)      /* Localism to specify strict C99 env. */
> #define __POSIX_VISIBLE         0
> #define __XSI_VISIBLE           0
> #define __BSD_VISIBLE           0
> #define __ISO_C_VISIBLE         1999
> #else                           /* Default environment: show everything. 
> */
> #define __POSIX_VISIBLE         200112
> #define __XSI_VISIBLE           600
> #define __BSD_VISIBLE           1
> #define __ISO_C_VISIBLE         1999
> #endif
> 
> #endif
> 
> This is the only place __BSD_VISIBLE is set under /usr/include as far as I 
> can see, and as long as _POSIX_C_SOURCE is defined, it will never be 
> defined. And __BSD_VISIBLE is required for inet_aton to be visible: 
> http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=include/arpa/inet.h

It looks like another case of broken system headers to me...

> Didn't perform the same check for FreeBSD yet, though...

The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
extra CFLAGS to configure:

http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824

I think the DragonFlay box should do the same.

Diego
Luca Barbato April 23, 2011, 12:21 p.m. | #10
On 4/23/11 12:26 PM, Diego Biurrun wrote:
> On Sat, Apr 23, 2011 at 01:04:49PM +0300, Martin Storsjö wrote:
>>
>> As far as I can see, there's nothing else you can define to make it work,
>> except undefining _POSIX_C_SOURCE. Here's the relevant parts of
>> sys/cdefs.h
>> (http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=sys/sys/cdefs.h):
>>
>> #ifdef _POSIX_C_SOURCE
>> /* ...
>>   * Checking exact version of _POSIX_C_SOURCE, never setting __BSD_VISIBLE
>>   */
>> #else
>> /* ...
>>   * If a program mistakenly defines _ANSI_SOURCE and some other macro such
>> as
>>   * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
>>   * environment (and in fact we will never get here).
>>   */
>> #ifdef _ANSI_SOURCE             /* Hide almost everything. */
>> #define __POSIX_VISIBLE         0
>> #define __XSI_VISIBLE           0
>> #define __BSD_VISIBLE           0
>> #define __ISO_C_VISIBLE         1990
>> #elif defined(_C99_SOURCE)      /* Localism to specify strict C99 env. */
>> #define __POSIX_VISIBLE         0
>> #define __XSI_VISIBLE           0
>> #define __BSD_VISIBLE           0
>> #define __ISO_C_VISIBLE         1999
>> #else                           /* Default environment: show everything.
>> */
>> #define __POSIX_VISIBLE         200112
>> #define __XSI_VISIBLE           600
>> #define __BSD_VISIBLE           1
>> #define __ISO_C_VISIBLE         1999
>> #endif
>>
>> #endif
>>
>> This is the only place __BSD_VISIBLE is set under /usr/include as far as I
>> can see, and as long as _POSIX_C_SOURCE is defined, it will never be
>> defined. And __BSD_VISIBLE is required for inet_aton to be visible:
>> http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=include/arpa/inet.h
>
> It looks like another case of broken system headers to me...
>
>> Didn't perform the same check for FreeBSD yet, though...
>
> The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
> extra CFLAGS to configure:
>
> http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
>
> I think the DragonFlay box should do the same.

I think we should report the problem there, possibly it will be fixed.

lu
Mans Rullgard April 23, 2011, 3:29 p.m. | #11
Diego Biurrun <diego@biurrun.de> writes:

> On Sat, Apr 23, 2011 at 01:04:49PM +0300, Martin Storsjö wrote:
>> 
>> As far as I can see, there's nothing else you can define to make it work, 
>> except undefining _POSIX_C_SOURCE. Here's the relevant parts of 
>> sys/cdefs.h 
>> (http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=sys/sys/cdefs.h):
>> 
>> #ifdef _POSIX_C_SOURCE
>> /* ...
>>  * Checking exact version of _POSIX_C_SOURCE, never setting __BSD_VISIBLE 
>>  */
>> #else
>> /* ...
>>  * If a program mistakenly defines _ANSI_SOURCE and some other macro such 
>> as
>>  * _POSIX_C_SOURCE, we will assume that it wants the broader compilation
>>  * environment (and in fact we will never get here).
>>  */
>> #ifdef _ANSI_SOURCE             /* Hide almost everything. */
>> #define __POSIX_VISIBLE         0
>> #define __XSI_VISIBLE           0
>> #define __BSD_VISIBLE           0
>> #define __ISO_C_VISIBLE         1990
>> #elif defined(_C99_SOURCE)      /* Localism to specify strict C99 env. */
>> #define __POSIX_VISIBLE         0
>> #define __XSI_VISIBLE           0
>> #define __BSD_VISIBLE           0
>> #define __ISO_C_VISIBLE         1999
>> #else                           /* Default environment: show everything. 
>> */
>> #define __POSIX_VISIBLE         200112
>> #define __XSI_VISIBLE           600
>> #define __BSD_VISIBLE           1
>> #define __ISO_C_VISIBLE         1999
>> #endif
>> 
>> #endif
>> 
>> This is the only place __BSD_VISIBLE is set under /usr/include as far as I 
>> can see, and as long as _POSIX_C_SOURCE is defined, it will never be 
>> defined. And __BSD_VISIBLE is required for inet_aton to be visible: 
>> http://gitweb.dragonflybsd.org/dragonfly.git/blob?f=include/arpa/inet.h
>
> It looks like another case of broken system headers to me...
>
>> Didn't perform the same check for FreeBSD yet, though...
>
> The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
> extra CFLAGS to configure:
>
> http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
>
> I think the DragonFlay box should do the same.

That is also wrong then.  We should fix both.
Diego Biurrun April 23, 2011, 3:51 p.m. | #12
On Sat, Apr 23, 2011 at 04:29:36PM +0100, Måns Rullgård wrote:
> Diego Biurrun <diego@biurrun.de> writes:
> >
> > The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
> > extra CFLAGS to configure:
> >
> > http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
> >
> > I think the DragonFlay box should do the same.
> 
> That is also wrong then.  We should fix both.

Fix how?  By trolling the FreeBSD box at LinuxTag?  We've tried that
for a long time, there's never the right person available..

In the meantime I think we can live with that (documented) workaround
and at least make sure that the FATE box is not red anymore.

Diego
Mans Rullgard April 24, 2011, 8:56 a.m. | #13
Diego Biurrun <diego@biurrun.de> writes:

> On Sat, Apr 23, 2011 at 04:29:36PM +0100, Måns Rullgård wrote:
>> Diego Biurrun <diego@biurrun.de> writes:
>> >
>> > The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
>> > extra CFLAGS to configure:
>> >
>> > http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
>> >
>> > I think the DragonFlay box should do the same.
>> 
>> That is also wrong then.  We should fix both.
>
> Fix how?

By passing correct flags that work.  That might mean dropping
_POSIX_C_SOURCE for BSD.
Sean McGovern April 24, 2011, 2:31 p.m. | #14
2011/4/24 Måns Rullgård <mans@mansr.com>

> Diego Biurrun <diego@biurrun.de> writes:
>
> > On Sat, Apr 23, 2011 at 04:29:36PM +0100, Måns Rullgård wrote:
> >> Diego Biurrun <diego@biurrun.de> writes:
> >> >
> >> > The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
> >> > extra CFLAGS to configure:
> >> >
> >> > http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
> >> >
> >> > I think the DragonFlay box should do the same.
> >>
> >> That is also wrong then.  We should fix both.
> >
> > Fix how?
>
> By passing correct flags that work.  That might mean dropping
> _POSIX_C_SOURCE for BSD.
>
> --
> Måns Rullgård
> mans@mansr.com
> _______________________________________________
> libav-devel mailing list
> libav-devel@libav.org
> https://lists.libav.org/mailman/listinfo/libav-devel
>


Can you convert the inet_aton() calls to inet_pton()? Would that remove the
need for these defines?

-- Sean
Sean McGovern April 24, 2011, 3:39 p.m. | #15
Nevermind, apparently I didn't read down far enough and inet_pton() is
in that same _BSD_VISIBLE #ifdef.

-- Sean

On 4/24/11, Sean McGovern <gseanmcg@gmail.com> wrote:
> 2011/4/24 Måns Rullgård <mans@mansr.com>
>
>> Diego Biurrun <diego@biurrun.de> writes:
>>
>> > On Sat, Apr 23, 2011 at 04:29:36PM +0100, Måns Rullgård wrote:
>> >> Diego Biurrun <diego@biurrun.de> writes:
>> >> >
>> >> > The FreeBSD FATE box passes '-D__BSD_VISIBLE -D__XSI_VISIBLE=600' as
>> >> > extra CFLAGS to configure:
>> >> >
>> >> > http://fate.libav.org/x86_32-freebsd-gcc-4.4/20110423101824
>> >> >
>> >> > I think the DragonFlay box should do the same.
>> >>
>> >> That is also wrong then.  We should fix both.
>> >
>> > Fix how?
>>
>> By passing correct flags that work.  That might mean dropping
>> _POSIX_C_SOURCE for BSD.
>>
>> --
>> Måns Rullgård
>> mans@mansr.com
>> _______________________________________________
>> libav-devel mailing list
>> libav-devel@libav.org
>> https://lists.libav.org/mailman/listinfo/libav-devel
>>
>
>
> Can you convert the inet_aton() calls to inet_pton()? Would that remove the
> need for these defines?
>
> -- Sean
>

Patch

diff --git a/doc/general.texi b/doc/general.texi
index 423402c..5c354ba 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -784,9 +784,9 @@  to configure.
 BSD make will not build Libav, you need to install and use GNU Make
 (@file{gmake}).
 
-@subsubsection FreeBSD
+@subsubsection FreeBSD, DragonFly BSD
 
-FreeBSD will not compile out-of-the-box due to broken system headers.
+FreeBSD and DragonFly BSD will not compile out-of-the-box due to broken system headers.
 Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work
 around the problem. This may have unexpected sideeffects, so use it at
 your own risk. If you care about FreeBSD, please make an attempt at