[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclinux-dev
Subject:    [uClinux-dev] [Patch] busybox - __builtin_expect - compiler
From:       "Friedrich, Lars" <lars.friedrich () wago ! com>
Date:       2004-05-28 8:02:16
Message-ID: 96A7A8B8A8ACBA4DAF7FD558BD32799BF56028 () svex01001
[Download RAW message or body]

This fixes an undefined reference problem when compiling busybox with pivot_root
option and using the gcc from the arm-elf-toolchain (gcc version 2.95.3 20010315 (release)...)
with uClibc from uClinux-dist 20040218. This problem does not occur when using
the uC-libc. This problem might or might not occur with other toolchains using the
same gcc version. This is afaik a known bug for all gcc versions below 2.95.12 though.

The patch is against the libbb.h from the mentioned dist, as it's the only
application where it occured to me. The patch is originally a quick hack from
Russel King, but it works (for me at least).

For reference and tracking:

[...]

arm-elf-gcc  -O2 -fomit-frame-pointer   -Dlinux -D__linux__ -Dunix
-D__uClinux__ -DEMBED -I/home/uboot/Projects/uClinuxBuild/
lib/uClibc/include -I/home/Projects/uClinuxBuild/lib/libm
-I/home/Projects/uClinuxBuild/lib/libcrypt_old -I/home/
Projects/uClinuxBuild -fno-builtin -nostartfiles
-I/home/Projects/uClinuxBuild/linux-2.4.x/include -Wall -Wshadow
 -Os -fstrict-aliasing -fomit-frame-pointer -D_GNU_SOURCE
-DBB_VER='"0.60.5"' -DBB_BT='"2004.05.28-07:31+0000"' -DCONFIG_H='
"config.h"' -DUSE_SYSTEM_PWD_GRP  -Wall -Wshadow -Os -fstrict-aliasing
-fomit-frame-pointer -D_GNU_SOURCE  -DBB_VER='"0.60.5"
' -DBB_BT='"2004.05.28-07:31+0000"' -DCONFIG_H='"config.h"'
-DUSE_SYSTEM_PWD_GRP  -Ilibbb -Ilibbb -c libbb/syscalls.c -o libb
b/syscalls.o
libbb/syscalls.c: In function 'sysfs':
libbb/syscalls.c:43: warning: declaration of 'sys_result' shadows previous
local
libbb/syscalls.c:43: warning: implicit declaration of function
'__builtin_expect'
libbb/syscalls.c: In function 'pivot_root':
libbb/syscalls.c:66: warning: declaration of 'sys_result' shadows previous
local

[...]

arm-elf-gcc  -O2 -fomit-frame-pointer   -Dlinux -D__linux__ -Dunix
-D__uClinux__ -DEMBED -I/home/Projects/uClinuxBuild/lib/uClibc/include
-I/home/Projects/uClinuxBuild/lib/libm
-I/home/Projects/uClinuxBuild/lib/libcrypt_old
-I/home/Projects/uClinuxBuild -fno-builtin -nostartfiles
-I/home/Projects/uClinuxBuild/linux-2.4.x/include -Wl,-elf2flt
/home/Projects/uClinuxBuild/lib/uClibc/lib/crt0.o
/home/Projects/uClinuxBuild/lib/uClibc/lib/crti.o
/home/Projects/uClinuxBuild/lib/uClibc/lib/crtn.o
-L/home/Projects/uClinuxBuild/lib/uClibc/.
-L/home/Projects/uClinuxBuild/lib/uClibc/lib
-L/home/Projects/uClinuxBuild/lib/libm
-L/home/Projects/uClinuxBuild/lib/libnet
-L/home/Projects/uClinuxBuild/lib/libdes
-L/home/Projects/uClinuxBuild/lib/libaes
-L/home/Projects/uClinuxBuild/lib/libpcap
-L/home/Projects/uClinuxBuild/lib/libcrypt_old
-L/home/Projects/uClinuxBuild/lib/libssl
-L/home/Projects/uClinuxBuild/lib/zlib -Wl,-warn-common
-Wl,-warn-common -o busybox chgrp.o chmod.o chown.o chroot.o clear.o cp.o
date.o hostname.o id.o ifconfig.o init.o insmod.o kill.o klogd.o ln.o ls.o
lsmod.o mknod.o modprobe.o more.o mount.o mv.o nfsmount.o ping.o
pivot_root.o rm.o rmdir.o rmmod.o touch.o umount.o  busybox.o usage.o
applets.o  libbb.a  -lc -lm -lc
busybox.elf2flt: In function 'sysfs':
busybox.elf2flt(.text+0xe188): undefined reference to '__builtin_expect'
busybox.elf2flt: In function 'pivot_root':
busybox.elf2flt(.text+0xe1c8): undefined reference to '__builtin_expect'
collect2: ld returned 1 exit status


Please note that the patch does not fix the shadowing warning.

Best regards,
Lars Friedrich


Index: libbb.h
===================================================================
RCS file: /cvsroot/uClinux/user/busybox/libbb/libbb.h,v
retrieving revision 0.9.0.1
diff -c -r0.9.0.1 libbb.h
*** libbb.h	17 May 2004 09:10:57 -0000	0.9.0.1
--- libbb.h	28 May 2004 07:56:03 -0000
***************
*** 37,42 ****
--- 37,46 ----
  
  #include <features.h>
  
+ #if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+ #define __builtin_expect(exp, c) (exp)
+ #endif
+ 
  #if (__GNU_LIBRARY__ < 5) && (!defined __dietlibc__)
  
  #ifndef __UC_LIBC__
_______________________________________________
uClinux-dev mailing list
uClinux-dev@uclinux.org
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by uclinux-dev@uclinux.org
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic