[Toybox] [PATCH] Clean warnings generated by scripts/genconfig.sh
Georgi Chorbadzhiyski
gf at unixsol.org
Mon Feb 27 23:16:24 PST 2012
On 2/28/12 8:42 AM, Rob Landley wrote:
> On 02/28/2012 12:20 AM, Georgi Chorbadzhiyski wrote:
>> 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:
>
> The warnings are actually from the feature test probe in
> scripts/genconfig.sh that generated the TOYBOX_CONTAINER config symbol
> to indicate whether or not the build environment supports containers:
>
> http://lxc.sourceforge.net/index.php/about/kernel-namespaces/
>
> Then CONFIG_UNSHARE depends on that, so the unshare command drops out if
> the build environment doesn't support it. (The goal is "make defconfig"
> should always compile.)
>
> The test should be piping its output to NULL, but 3.2 kernel headers
> have all the stuff so the test _should_ succeed...
>
>> 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
>
> Works for me, but I would like to figure out why your build environment
> wasn't already getting it. _USE_BSD should enable it __USE_MISC, and
> you should get _USE_BSD by default unless your command line said -ansi.
Hmm, no -ansi here. Just the standard CFLAGS=-Wall -Wundef -Wno-char-subscripts -funsigned-char
and CC=cc (as set by configure).
Looking at include/sched.h which includes include/bits/sched.h it seems
that these are glibc provided headers (2.14.1). In include/bits/sched.h the
clone flag definitions are guarded by #ifdef __USE_GNU so looks like glibc
mess. Including linux/sched.h definitely looks like a correct solution.
I have another problem with scripts/genconfig.sh when trying to cross
compile toybox. See bellow:
gf at gf:~/toys/toybox$ CROSS=sh4-linux- CC=gcc make
scripts/make.sh
Extract configuration information from toys/*.c files...
scripts/genconfig.sh: line 16: sh4-linux-sh4-linux-gcc: command not found
Generate headers from toys/*.h...
Extract help text from Config.in.
Make generated/config.h from .config.
Compile toybox...
It looks like genconfig.sh should not source configure because this defines
CC again, causing it to contain sh4-linux-sh4-linux-gcc in my case. Removing
"source configure" line fixes this particular problem but it breaks
CROSS=sh4-linux- CC=gcc make defconfig
Fun.
It looks like configure should not do CC="${CROSS_COMPILE}${CC}" unconditionally.
Isn't it better to use ${CROSS_COMPILE}${CC} instead in the scripts instead of
redefining CC. Something like this:
diff -r 763d581badae configure
--- a/configure Sun Feb 26 22:04:37 2012 -0600
+++ b/configure Tue Feb 28 09:15:14 2012 +0200
@@ -9,6 +9,5 @@
CFLAGS="$CFLAGS -funsigned-char"
[ -z "$OPTIMIZE" ] && OPTIMIZE="-Os -ffunction-sections -fdata-sections -Wl,--gc-sections"
[ -z "$CC" ] && CC="cc"
-CC="${CROSS_COMPILE}${CC}"
[ -z "$STRIP" ] && STRIP="${CROSS_COMPILE}strip"
[ -z "$HOSTCC" ] && HOSTCC=gcc
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 09:15:14 2012 +0200
@@ -13,7 +13,7 @@
# Probe for container support on target
echo -e "# container support\nconfig TOYBOX_CONTAINER\n\tbool" || return 1
- $CC -c -xc -o /dev/null - << EOF
+ ${CROSS_COMPILE}${CC} -c -xc -o /dev/null - << EOF
#include <sched.h>
int x=CLONE_NEWNS|CLONE_NEWUTS|CLONE_NEWIPC|CLONE_NEWNET;
EOF
diff -r 763d581badae scripts/make.sh
--- a/scripts/make.sh Sun Feb 26 22:04:37 2012 -0600
+++ b/scripts/make.sh Tue Feb 28 09:15:14 2012 +0200
@@ -102,7 +102,7 @@
"$@"
}
-do_loudly $CC $CFLAGS -I . -o toybox_unstripped $OPTIMIZE main.c lib/*.c \
+do_loudly ${CROSS_COMPILE}${CC} $CFLAGS -I . -o toybox_unstripped $OPTIMIZE main.c lib/*.c \
$TOYFILES -Wl,--as-needed,-lutil,--no-as-needed || exit 1
do_loudly $STRIP toybox_unstripped -o toybox || exit 1
# gcc 4.4's strip command is buggy, and doesn't set the executable bit on
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
1330413384.0
More information about the Toybox
mailing list