Created attachment 3205 [details] Proposed fix for this issue. This report concerns my attempts to get BusyBox building out-of-the-box with musl (http://www.etalabs.net/musl/). The BusyBox config system makes use of interfaces that are not available to a conforming program unless _POSIX_C_SOURCE or _XOPEN_SOURCE is defined, leading to errors like (during "make menuconfig"): scripts/kconfig/mconf.c:454:19: error: storage size of ‘sa’ isn’t known scripts/kconfig/mconf.c:455:2: error: ‘sigset_t’ undeclared (first use in this function) Adding -D_XOPEN_SOURCE=700 -D_GNU_SOURCE to HOSTCFLAGS in the main Makefile fixes the issue. Note that unlike CFLAGS, where feature test macros can easily be added interactively in menuconfig or by editing the .config file, the HOSTCFLAGS must be specified on the "make" command line or the build process can't even get to the point of configuration. Ideally I'd like to see the same added to the target CFLAGS.
Looks fine to me. The equivalent could also be added to CPPFLAGS in Makefile.flags if needed for target compilation as well.
I proposing adding #define FOO only to the files which need those, with appropriate comments why this particular define is needed. Regarding this: scripts/kconfig/mconf.c:454:19: error: storage size of ‘sa’ isn’t known scripts/kconfig/mconf.c:455:2: error: ‘sigset_t’ undeclared (first use in this function) It is generated from struct sigaction sa; sigset_t sset, osset; I'm surprised that #include <signal.h> is not enough for that.
I still dislike the idea of blanket adding of stuff to HOSTFLAGS. Please, musl people, reopen this and tell me what #includes and/or #defines are needed to suppress the warnings you see, and to which file(s) they need to be added?
As of current git, the only problems at "make menuconfig" time are the following. I'm not sure where it's expecting alloca to get declared; we have <alloca.h> available. The rest seem to be from missing _XOPEN_SOURCE (strdup) or _POSIX_C_SOURCE (popen/pclose). It presently "works" on 32-bit even with the problems; don't know about 64-bit. There are also some new link-time errors for busybox itself but they belong in a separate report. HOSTCC scripts/basic/fixdep scripts/basic/fixdep.c: In function ‘use_config’: scripts/basic/fixdep.c:206:2: warning: implicit declaration of function ‘alloca’ scripts/basic/fixdep.c:206:12: warning: incompatible implicit declaration of built-in function ‘alloca’ scripts/basic/fixdep.c: In function ‘parse_dep_file’: scripts/basic/fixdep.c:318:12: warning: incompatible implicit declaration of built-in function ‘alloca’ HOSTCC scripts/basic/split-include scripts/basic/split-include.c: In function ‘main’: scripts/basic/split-include.c:192:5: warning: implicit declaration of function ‘popen’ scripts/basic/split-include.c:192:13: warning: assignment makes pointer from integer without a cast scripts/basic/split-include.c:223:5: warning: implicit declaration of function ‘pclose’ HOSTCC scripts/basic/docproc scripts/basic/docproc.c: In function ‘exec_kernel_doc’: scripts/basic/docproc.c:94:4: warning: implicit declaration of function ‘alloca’ scripts/basic/docproc.c:94:20: warning: incompatible implicit declaration of built-in function ‘alloca’ scripts/basic/docproc.c: In function ‘add_new_symbol’: scripts/basic/docproc.c:130:2: warning: implicit declaration of function ‘strdup’ scripts/basic/docproc.c:130:43: warning: incompatible implicit declaration of built-in function ‘strdup’ scripts/basic/docproc.c: In function ‘add_new_file’: scripts/basic/docproc.c:136:39: warning: incompatible implicit declaration of built-in function ‘strdup’ scripts/basic/docproc.c: In function ‘find_export_symbols’: scripts/basic/docproc.c:173:25: warning: incompatible implicit declaration of built-in function ‘alloca’
You meant to say: Please apply the following patch to suppress 'warning: implicit declaration of function ‘alloca’' when bbox is built against musl. Tested. --- busybox.1/scripts/basic/docproc.c +++ busybox.2/scripts/basic/docproc.c @@ -39,6 +39,7 @@ #include <limits.h> #include <sys/types.h> #include <sys/wait.h> +#include <alloca.h> /* exitstatus is used to keep track of any failing calls to kernel-doc, * but execution continues. */ --- busybox.1/scripts/basic/fixdep.c +++ busybox.2/scripts/basic/fixdep.c @@ -113,6 +113,7 @@ #include <limits.h> #include <ctype.h> #include <arpa/inet.h> +#include <alloca.h> /* bbox: not needed #define INT_CONF ntohl(0x434f4e46) I will apply the above patch to git right now. Do you have similar patch which fixes strdup/popen/pclose warnings?