Bug 3613 - Lack of feature test macros in building config
Summary: Lack of feature test macros in building config
Status: REOPENED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Standard Compliance (show other bugs)
Version: unspecified
Hardware: PC Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-13 16:57 UTC by bugdal
Modified: 2011-09-15 08:36 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Proposed fix for this issue. (346 bytes, patch)
2011-04-13 16:57 UTC, bugdal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description bugdal 2011-04-13 16:57:01 UTC
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.
Comment 1 Dan Fandrich 2011-04-14 23:23:57 UTC
Looks fine to me. The equivalent could also be added to CPPFLAGS in Makefile.flags if needed for target compilation as well.
Comment 2 Denys Vlasenko 2011-04-16 16:21:25 UTC
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.
Comment 3 Denys Vlasenko 2011-09-11 19:10:54 UTC
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?
Comment 4 bugdal 2011-09-12 02:42:51 UTC
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’
Comment 5 Denys Vlasenko 2011-09-15 08:36:04 UTC
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?