[Toybox] _GNU_SOURCE definition problem
Georgi Chorbadzhiyski
gf at unixsol.org
Fri Mar 9 18:25:22 PST 2012
On 3/10/12 4:14 AM, Rob Landley wrote:
> On 03/09/2012 04:39 PM, Georgi Chorbadzhiyski wrote:
>> On 3/9/12 7:47 PM, Rob Landley wrote:
>>> On 03/09/2012 08:14 AM, Georgi Chorbadzhiyski wrote:
>>>> Removing _GNU_SOURCE breaks toys/unshare compilation.
>>>
>>> Building under what?
>>>
>>> In /usr/include/features.h:
>>>
>>> #if defined _BSD_SOURCE || defined _SVID_SOURCE
>>> # define __USE_MISC 1
>>> #endif
>>>
>>> sched.h includes bits/sched.h, and in /usr/include/bits/sched.h the
>>> CLONE_NEW* defines are all in #ifdef __USE_MISC
>>>
>>> So... works for me? (Just did a test build...)
>>
>> From /usr/include/bits/sched.h [1] on my desktop (glibc-2.14.1,
>> slack-current)
>>
>> #ifdef __USE_GNU
>
> That's the double underscore macro, that's #defined internally by
> /usr/incldue/features.h in response to some other macro.
>
>> ...
>> # define CLONE_NEWUTS 0x04000000 /* New utsname group. */
>> # define CLONE_NEWIPC 0x08000000 /* New ipcs. */
>> # define CLONE_NEWUSER 0x10000000 /* New user namespace. */
>> # define CLONE_NEWPID 0x20000000 /* New pid namespace. */
>> # define CLONE_NEWNET 0x40000000 /* New network namespace. */
>> # define CLONE_IO 0x80000000 /* Clone I/O context. */
>> ...
>
> I can #include linux/sched.h directly if this is really a problem.
> That's the more correct thing to do since this is a recently added linux
> kernel feature, and has nothing to do with gnu anything.
>
>> #endif
>>
>> ...
>>
>> #ifdef __USE_GNU
>> /* Clone current process. */
>> extern int clone (int (*__fn) (void *__arg), void *__child_stack,
>> int __flags, void *__arg, ...) __THROW;
>
> Hang on, you don't get _clone_ unless you say _USE_GNU? I get it if I
> don't specify _any_ feature test macro.
>
> Something is very broken here.
>
>> Resulting in:
>>
>> toys/unshare.c: In function ‘unshare_main’:
>> toys/unshare.c:32:20: error: ‘CLONE_NEWNS’ undeclared (first use in this
>> function)
>> toys/unshare.c:32:20: note: each undeclared identifier is reported only
>> once for each function it appears in
>> toys/unshare.c:32:33: error: ‘CLONE_NEWUTS’ undeclared (first use in
>> this function)
>> toys/unshare.c:32:47: error: ‘CLONE_NEWIPC’ undeclared (first use in
>> this function)
>> toys/unshare.c:32:61: error: ‘CLONE_NEWNET’ undeclared (first use in
>> this function)
>> toys/unshare.c:40:2: warning: implicit declaration of function ‘unshare’
>> [-Wimplicit-function-declaration]
>> make: *** [toybox] Error 1
>>
>> glibc insists that this Linux only functionality is behind __USE_GNU
>> which is declared in features.h if _GNU_SOURCE is declared [2].
>
> glibc 2.11.1 here does not, sounds like a recent regression.
>
> But sure, I can #include linux/sched.h to get this.
Adding #include <linux/sched.h> gets me the flag definitions but
unshare() is still only available "guarded" by _GNU_SOURCE. Damn.
toys/unshare.c: In function ‘unshare_main’:
toys/unshare.c:42:2: warning: implicit declaration of function ‘unshare’ [-Wimplicit-function-declaration]
make: *** [toybox] Error 1
gf at gf:~/git/toybox$ cd /usr/include
gf at gf:/usr/include$ grep -rw unshare *
bits/sched.h:extern int unshare (int __flags) __THROW;
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
1331346322.0
More information about the Toybox
mailing list