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

Anthony G. Basile basile at freeharbor.net
Thu Jun 22 14:33:31 CEST 2017

On 6/21/17 4:11 PM, Waldemar Brodkorb wrote:
> 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

I just did a grep of glibc master/HEAD and it looks like __FAVOR_BSD has
been removed.  If we remove __FAVOR_BSD from uclibc, will buildroot
stuff build fine?  You can test by just removing those lines from
features.h and forcing undef __FAVOR_BSD.  If it works, I can produce a

Anthony G. Basile, Ph.D.
Gentoo Linux Developer [Hardened]
E-Mail    : basile at freeharbor.net
GnuPG FP  : 1FED FAD9 D82C 52A5 3BAB  DC79 9384 FA6E F52D 4BBA
GnuPG ID  : F52D4BBA

More information about the devel mailing list