[BusyBox] uClinux and busybox compilation error: toolchain's problem?

Rob Landley rob at landley.net
Thu Dec 9 21:23:02 UTC 2004


On Thursday 09 December 2004 03:15 pm, Shawn wrote:
> Hi,

> arm-uclinux-gcc -Ibusybox-1.00/include -Ibusybox-1.00/include
> -Ibusybox-1.00/libbb -Wall -Wstrict-prototypes -Wshadow -Os
> -fstrict-aliasing -fomit-frame-pointer-D_GNU_SOURCE -DNDEBUG     -c -o
> busybox-1.00/libbb/loop.o /u/xjin/code/busybox-1.00/libbb/loop.c
> busybox-1.00/libbb/loop.c:52: error: parse error before
> "__kernel_old_dev_t" busybox-1.00/libbb/loop.c:52: warning: no semicolon at
> end of struct or union busybox-1.00/libbb/loop.c:54: error: parse error
> before "lo_rdevice" busybox-1.00/libbb/loop.c:54: warning: type defaults to
> `int' in
> declaration of `lo_rdevice'

I got permission to check in this patch to busybox, but CVS went "boing" when 
I tried.  Eric fixed it, I'll try again shortly.
.
The problem is that libbb.h includes <sys/stat.h>, which includes 
<bits/types.h>, which is the only place that includes <bits/kernel_types.h>

kernel_types.h is an evil disgusting hack that's only in uclibc, and according 
to Eric is there because the correct header, <bits/posix_types.h> is broken 
on certain architectures.

The gross brokenness is right at the start of kernel_types.h:

> /* Note that we use the exact same include guard #define names
>  * as asm/posix_types.h.  This will avoid gratuitous conflicts
>  * with the posix_types.h kernel header, and will ensure that
>  * our private content, and not the kernel header, will win.
>  *  -Erik
>  */
> #ifndef __ARCH_I386_POSIX_TYPES_H
> #define __ARCH_I386_POSIX_TYPES_H

So if you include both kernel_types.h and posix_types.h, the second one 
becomes a NOP.  And that's what's causing the break, kernel_types.h doesn't 
always define everything that posix_types.h does (depending on version and 
architecture, the CVS version defines __kernel_old_dev, on INtel anyway.  
0.9.26 didn't.  Diff the two files to see what else kernel_types doesn't 
define that posix_types does on your architecture...)

The correct course of action would probably be to fix posix_types.h and zap 
kernel_types.h, since having two header files in the tree with different 
contents but the same #include guard is just asking for trouble.  (I dunno, 
look at the GNU headers and see what they did.)  But that's Eric's call, and 
the problem he patched around only exists on architectures I don't have to 
test with, and is apparently exacerbated by maintining compatability with 
2.4, 2.2, and 2.0 kernel headers...

Anyway, the fix is to move the #include of posix_types.h up to the top of the 
file so it wins over kernel_types.h.  Here's the patch to do that, which I'll 
now check into CVS:

--- busybox-old/libbb/loop.c	2004-08-16 04:36:28.000000000 -0400
+++ busybox/libbb/loop.c	2004-12-04 23:45:58.000000000 -0500
@@ -19,6 +19,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  */
 
+#include <asm/posix_types.h>
 #include <stdio.h>
 #include <errno.h>
 #include <fcntl.h>
@@ -30,7 +31,6 @@
 /* Grumble...  The 2.6.x kernel breaks asm/posix_types.h
  * so we get to try and cope as best we can... */
 #include <linux/version.h>
-#include <asm/posix_types.h>
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 #define __bb_kernel_dev_t   __kernel_old_dev_t


Rob



More information about the busybox mailing list