[Toybox] [PATCH] Clean warnings generated by scripts/genconfig.sh

Georgi Chorbadzhiyski gf at unixsol.org
Mon Feb 27 22:21:24 PST 2012


/Rob sorry about the double email, forgot to hit Reply-all/

On 2/28/12 8:08 AM, Rob Landley wrote:
> On 02/27/2012 06:45 PM, Georgi Chorbadzhiyski wrote:
>> The attached patch prevents warnings related to clone flags. According
>> to clone(2) _GNU_SOURCE must be defined before including<sched.h>.
>
> Yeah, Michael Kerrisk is wrong on that one.  (That's the "big hammer"
> that switches on everything glibc can do. All we _actually_ need here is
> __USE_MISC.)
>
>> After the patch the following warnings disappear:
>>
>>    <stdin>:2:11: error: 'CLONE_NEWNS' undeclared here (not in a function)
>>    <stdin>:2:23: error: 'CLONE_NEWUTS' undeclared here (not in a function)
>>    <stdin>:2:36: error: 'CLONE_NEWIPC' undeclared here (not in a function)
>>    <stdin>:2:49: error: 'CLONE_NEWNET' undeclared here (not in a function)
>
> A) This project has nothing to do with gnu anything.  I'd rather
> #declare the constants in the header than have to say that. Especially
> since these constants are Linux clone flags that come out of
> linux/sched.h, so the FSF was not remotely involved, and if some idiot
> decided you need to define ALL_HAIL_RICHARD_STALLMAN in order to get
> linux/sched.h included from bits.h they're _insane_.  (Yeah, a bit of a
> sore spot with me. :)
>
> 2) An error isn't the same as a warning, and those are _errors_. The
> compile failed, which it didn't for me.  What's your test environment
> for building this? It worked fine for me without #defining anything special.
>
> My /usr/include/bits/sched.h has it guarded by __USE_MISC which
> features.h #defines in a lot of ways, and I seem to be getting it via
> this path:
>
> /* If none of the ANSI/POSIX macros are defined, use POSIX.1 and POSIX.2
>     (and IEEE Std 1003.1b-1993 unless _XOPEN_SOURCE is defined).  */
>
> At a guess, your compiler flags are feeding it "-ansi" or "-pedantic" or
> some such, and forcing it to the old C89 standard from 23 years ago?
> Again from /usr/include/features.h:
>
>     The `-ansi' switch to the GNU C compiler defines __STRICT_ANSI__.
>     If none of these are defined, the default is to have _SVID_SOURCE,
>     _BSD_SOURCE, and _POSIX_SOURCE set to one and _POSIX_C_SOURCE set to
>     200112L.  If more than one of these are defined, they accumulate.
>     For example __STRICT_ANSI__, _POSIX_SOURCE and _POSIX_C_SOURCE
>     together give you ISO C, 1003.1, and 1003.2, but nothing else.
>
> If so, that's probably the fundamental problem I should address,
> possibly by setting -c99 in the default CFLAGS maybe?
>
> III) I could also change the test to #include<linux/sched.h>  instead.
> Or #define _POSIX_C_SOURCE 200809L to get posix2008 which is what we're
> using. There's a bunch of better ways to fix this: Toybox is a Linux
> project, not a GNU project.

The build environment is slackware-current with gcc 4.6.2, glibc
2.14.1 and kernel-headers-3.2.2. The interesting thing is that the build
do not fail it just prints the above mentioned errors about CLONE_xxx
flags but toybox is built. The following patch works as well:

diff -r 763d581badae scripts/genconfig.sh
--- a/scripts/genconfig.sh      Sun Feb 26 22:04:37 2012 -0600
+++ b/scripts/genconfig.sh      Tue Feb 28 08:17:23 2012 +0200
@@ -14,7 +14,7 @@

    echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
    $CC -c -xc -o /dev/null - << EOF
-    #include <sched.h>
+    #include <linux/sched.h>
      int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
  EOF
    [ $? -eq 0 ] && DEFAULT=y || DEFAULT=n

-- 
Georgi Chorbadzhiyski
http://georgi.unixsol.org/

 1330410084.0


More information about the Toybox mailing list