[Toybox] _GNU_SOURCE definition problem
Georgi Chorbadzhiyski
gf at unixsol.org
Wed Mar 7 07:44:35 PST 2012
I'm compiling toybox'es allyesconfig with musl libc and the compilation
do not succeed because of this.
Compile toybox...
toys/id.c: In function ‘id_main’:
toys/id.c:136:2: warning: implicit declaration of function ‘getgrouplist’ [-Wimplicit-function-declaration]
toys/id.c:63:8: warning: variable ‘gid’ set but not used [-Wunused-but-set-variable]
toys/ls.c: In function ‘do_ls’:
toys/ls.c:170:17: warning: implicit declaration of function ‘major’ [-Wimplicit-function-declaration]
toys/ls.c:170:17: warning: implicit declaration of function ‘minor’ [-Wimplicit-function-declaration]
toys/mke2fs.c: In function ‘mke2fs_main’:
toys/mke2fs.c:444:35: warning: variable ‘dtiblk’ set but not used [-Wunused-but-set-variable]
toys/netcat.c: In function ‘netcat_main’:
toys/netcat.c:125:4: warning: passing argument 2 of ‘bind’ from incompatible pointer type [enabled by default]
/usr/local/musl/include/sys/socket.h:236:5: note: expected ‘const struct sockaddr *’ but argument is of type ‘struct sockaddr_in *’
toys/netcat.c:146:5: warning: passing argument 2 of ‘getsockname’ from incompatible pointer type [enabled by default]
/usr/local/musl/include/sys/socket.h:241:5: note: expected ‘struct sockaddr *’ but argument is of type ‘struct sockaddr_in *’
/tmp/ccJRWNtS.o: In function `do_ls':
ls.c:(.text.do_ls+0x3e2): undefined reference to `minor'
ls.c:(.text.do_ls+0x3f7): undefined reference to `major'
collect2: ld returned 1 exit status
make: *** [toybox] Error 1
In order for these functions to exist _GNU_SOURCE must be defined.
It is defined in lib/portability.h but since it is included in
toys.h and toys.h is included after system headers, the definitions
do not exist.
Two possible fixes:
1. Define _GNU_SOURCE above system headers in id.c and ls.c
2. Move #include "toys.h" above system headers.
Both are ugly, help!
Anyway, with 1 from above and the two patches that I've already posted
I can successfully build allyesconfig with musl 0.8.6 on 32 bit x86
machine.
--
Georgi Chorbadzhiyski
http://georgi.unixsol.org/
More information about the Toybox
mailing list