[uclibc-ng-devel] [PATCH] include/features.h: add _DEFAULT_SOURCE macro

Waldemar Brodkorb wbx at uclibc-ng.org
Wed Jun 21 22:11:02 CEST 2017


Hi,
Thomas Petazzoni wrote,

> Hello,
> 
> On Wed, 31 May 2017 23:41:26 +0000, Anthony G. Basile wrote:
> > From: "Anthony G. Basile" <blueness at gentoo.org>
> > 
> > man feature_test_macros(7) specifies that _BSD_SOURCE and _SVID_SOURCE have
> > been deprecated in favor of _DEFAULT_SOURCE since libc 2.20.  Specifying
> > either of the former is now equivalent to specifying just the latter.  We add
> > this macro to conform to this standard, but do not add the compiler warning
> > to maintain full backwards compatibility with earlier version of glibc and
> > uclibc.
> > 
> > Signed-off-by: Anthony G. Basile <blueness at gentoo.org>
> 
> This patch breaks the build of the "knock" package in Buildroot:
> 
>   http://autobuild.buildroot.net/results/908/90863b5adb769a346acd3dc4bbe8d5fa497a0581/build-end.log
> 
> src/knockd.c:1296:37: error: 'struct tcphdr' has no member named 'th_flags'
> 
> The tcphdr structure is defined in uClibc in two different ways,
> depending on whether _FAVOR_BSD is defined or not. If _FAVOR_BSD is
> defined, then the structure does have this th_flags member, otherwise
> not.
> 
> _FAVOR_BSD is defined as follows:
> 
> #if defined _BSD_SOURCE && \
>     !(defined _POSIX_SOURCE || defined _POSIX_C_SOURCE || \
>       defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED || \
>       defined _GNU_SOURCE || defined _SVID_SOURCE)
> # define __FAVOR_BSD	1
> #endif
> 
> When being built, the program passes both -D_BSD_SOURCE and
> -D_DEFAULT_SOURCE. However, this patch has the effect that defining
> _DEFAULT_SOURCE defines _SVID_SOURCE, which has the side effect of no
> longer defining _FAVOR_BSD.
> 
> The definition of _DEFAULT_SOURCE is that it is equivalent to defining
> _BSD_SOURCE and _SVID_SOURCE. However, it turns out that in the context
> of uClibc, defining _SVID_SOURCE prevents __FAVOR_BSD from being
> defined.
> 
> Where is the bug? In what the knock build system is doing, or in uClibc?

As it seems to compile fine for glibc based toolchain, it is a
regression in uClibc-ng.

best regards
 Waldemar


More information about the devel mailing list