[Toybox] _GNU_SOURCE definition problem
Georgi Chorbadzhiyski
gf at unixsol.org
Thu Mar 8 22:42:58 PST 2012
On 3/9/12 4:15 AM, Rob Landley wrote:
> On 03/08/2012 07:04 AM, Georgi Chorbadzhiyski wrote:
>> Around 03/08/2012 02:59 PM, Rob Landley scribbled:
>>> I applied the cleanups I was talking about to the repository at the same
>>> time I sent the above message. Did my cleanups (based on posix) do what
>>> you needed?
>>
>> Not really.
>
> Ok, let me start by saying "feature test requirements" are bollocks and
> musl should not pull this crap.
>
> That said, it's doing it wrong:
>
>> gf at gf:~/git/toybox$ make CC=musl-gcc
>> scripts/make.sh
>> Extract configuration information from toys/*.c files...
>> Generate headers from toys/*.c...
>> Extract help text from Config.in.
>> Make generated/config.h from .config.
>> Compile toybox...
>> lib/lib.c: In function ‘find_in_path’:
>> lib/lib.c:393:3: warning: implicit declaration of function ‘index’ [-Wimplicit-function-declaration]
>> lib/lib.c:393:23: warning: incompatible implicit declaration of built-in function ‘index’ [enabled by default]
>
> That one I can replace since it's just a gratuitous rename, but the _BSD
> define should provide it.
>
>> lib/lib.c: In function ‘sig_to_num’:
>> lib/lib.c:877:3: warning: implicit declaration of function ‘strncasecmp’ [-Wimplicit-function-declaration]
>> lib/lib.c:881:3: warning: implicit declaration of function ‘strcasecmp’ [-Wimplicit-function-declaration]
>
> This is posix 2008, musl is broken.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/strncasecmp.html
>
>> toys/chroot.c: In function ‘chroot_main’:
>> toys/chroot.c:25:2: warning: implicit declaration of function ‘chroot’ [-Wimplicit-function-declaration]
>
> This is a linux system call, musl is broken.
>
>> toys/env.c: In function ‘env_main’:
>> toys/env.c:31:5: warning: implicit declaration of function ‘clearenv’ [-Wimplicit-function-declaration]
>
> _SVID_SOURCE or _BSD_SOURCE should give us this according ot the man
> page, I #defined both.
>
> http://www.kernel.org/doc/man-pages/online/pages/man3/clearenv.3.html
>
> musl is broken.
>
>> toys/hostname.c: In function ‘hostname_main’:
>> toys/hostname.c:26:13: warning: implicit declaration of function ‘sethostname’ [-Wimplicit-function-declaration]
>
> The man page says _BSD_SOURCE should give us this, musl is broken.
>
>> toys/id.c: In function ‘id_main’:
>> toys/id.c:133:2: warning: implicit declaration of function ‘getgrouplist’ [-Wimplicit-function-declaration]
>
> Posix-2008 defines getgroups() as the portable way to do this, so I
> should change the code.
>
>> toys/id.c:60:8: warning: variable ‘gid’ set but not used [-Wunused-but-set-variable]
>> toys/ls.c: In function ‘do_ls’:
>> toys/ls.c:162:17: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration]
>> toys/ls.c:162:17: warning: implicit declaration of function ‘minor’ [-Wimplicit-function-declaration]
>
> The man page says the guard for this is _BSD_SOURCE, musl is broken.
>
>> toys/mdev.c: In function ‘make_device’:
>> toys/mdev.c:98:9: warning: implicit declaration of function ‘strndupa’ [-Wimplicit-function-declaration]
>> toys/mdev.c:98:23: warning: initialization makes pointer from integer without a cast [enabled by default]
>
> I forgot to check in the "default n" tweak for this command until I
> merge your pending patch.
>
>> toys/mdev.c:128:10: warning: passing argument 1 of ‘getpwnam’ makes pointer from integer without a cast [enabled by default]
>> /usr/local/musl/include/pwd.h:34:16: note: expected ‘const char *’ but argument is of type ‘int’
>> toys/mdev.c:137:10: warning: passing argument 1 of ‘getgrnam’ makes pointer from integer without a cast [enabled by default]
>> /usr/local/musl/include/grp.h:22:16: note: expected ‘const char *’ but argument is of type ‘int’
>
> Fallout from strndupa(), unknown return type.
>
>> toys/mdev.c:168:2: warning: implicit declaration of function ‘makedev’ [-Wimplicit-function-declaration]
>
> It's _BSD_SOURCE, musl is broken.
>
>> toys/mke2fs.c: In function ‘mke2fs_main’:
>> toys/mke2fs.c:444:35: warning: variable ‘dtiblk’ set but not used [-Wunused-but-set-variable]
>> toys/mknod.c: In function ‘mknod_main’:
>> toys/mknod.c:48:2: warning: implicit declaration of function ‘makedev’ [-Wimplicit-function-declaration]
>
> And again...
>
>> toys/mkswap.c: In function ‘mkswap_main’:
>> toys/mkswap.c:24:2: warning: implicit declaration of function ‘getpagesize’ [-Wimplicit-function-declaration]
>
> Huh, apparently removed from posix 2008, now it's gratuitously
> sysconf(_SC_PAGE_SIZE). Ok...
>
>> toys/nice.c: In function ‘nice_main’:
>> toys/nice.c:38:2: warning: implicit declaration of function ‘getpriority’ [-Wimplicit-function-declaration]
>> toys/nice.c:38:18: error: ‘PRIO_PROCESS’ undeclared (first use in this function)
>> toys/nice.c:38:18: note: each undeclared identifier is reported only once for each function it appears in
>
> That's still in posix 2008:
>
> http://pubs.opengroup.org/onlinepubs/9699919799/functions/getpriority.html
>
> But now it wants sys/resource.h. *shrug* Ok...
>
>> toys/oneit.c: In function ‘oneit_main’:
>> toys/oneit.c:55:3: warning: implicit declaration of function ‘vfork’ [-Wimplicit-function-declaration]
>> toys/setsid.c: In function ‘setsid_main’:
>> toys/setsid.c:27:3: warning: implicit declaration of function ‘vfork’ [-Wimplicit-function-declaration]
>
> Sigh. Those crazy standards idiots removed vfork from posix-2008, which
> is a bug.
>
> http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xsh_chap03.html
>
> I wrote up a big long explanation once upon a time for the busybox FAQ:
>
> http://busybox.net/FAQ.html#tips_vfork
>
> But more to the point, _BSD_SOURCE should provide it according to the
> man page, so musl is broken.
>
>> toys/sleep.c: In function ‘sleep_main’:
>> toys/sleep.c:52:3: warning: implicit declaration of function ‘usleep’ [-Wimplicit-function-declaration]
>
> Posix really wants to move everything to nanosleep? Really?
>
> Sigh. Ok...
>
>> toys/sort.c: In function ‘sort_main’:
>> toys/sort.c:362:21: warning: implicit declaration of function ‘index’ [-Wimplicit-function-declaration]
>> toys/sort.c:362:29: warning: incompatible implicit declaration of built-in function ‘index’ [enabled by default]
>
> Second verse, same as the first...
>
>> toys/toysh.c: In function ‘run_pipeline’:
>> toys/toysh.c:304:3: warning: implicit declaration of function ‘vfork’ [-Wimplicit-function-declaration]
>
> And again...
>
>> toys/which.c: In function ‘which_in_path’:
>> toys/which.c:33:2: warning: implicit declaration of function ‘index’ [-Wimplicit-function-declaration]
>> toys/which.c:33:6: warning: incompatible implicit declaration of built-in function ‘index’ [enabled by default]
>
> And again.
>
> Just checked in fixes for some of it, the rest honestly seems to be musl
> bugs...
I'll submit patches to musl. In their README they recommend defining _GNU_SOURCE
to get "the kitchen sink" since they probably know that their handling of different
defines is not optimal. Oh, well time to patch musl (for the record
make CC="musl-gcc -D_GNU_SOURCE" compiles (minus the support index and strndupa)).
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
More information about the Toybox
mailing list