Bug 1021

Summary: libgcc doesn't install crt*.o into target sato-sdk image
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Dexuan Cui <dexuan.cui>
Component: devtools / tool chainAssignee: Nitin Kamble <nitin.a.kamble>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: High CC: liang.li2, liangliang.wang, meta.mr.watcher, meta.watcher, sgw, yi.zhao
Version: unspecified   
Target Milestone: 1.1 M1   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Dexuan Cui 2011-05-03 06:11:42 UTC
Using recent poky master, I got a ld error "can't find crtbegin.o" when I build a simple c program in sato-sdk target.

I checked a recent image:
wget http://autobuilder.yoctoproject.org/nightly/20110429-1/machines/qemu/qemu86/core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2

tar -jtf core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2
 | grep crtbegin.o returns nothing.


But 
wget http://autobuilder.yoctoproject.org/nightly/20110402-1/machines/qemu/qemu86/poky-image-sato-sdk-qemux86-20110403065104.rootfs.tar.bz2

tar -jtf core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2
 | grep crtbegin.o
returns
./usr/lib/i586-poky-linux/4.5.1/crtbegin.o.

So looks this bug crept into poky master after Apr 2 somehow.
Comment 1 Dexuan Cui 2011-05-03 20:48:46 UTC
(In reply to comment #0)
> Using recent poky master, I got a ld error "can't find crtbegin.o" when I build
> a simple c program in sato-sdk target.
> I checked a recent image:
> wget
> http://autobuilder.yoctoproject.org/nightly/20110429-1/machines/qemu/qemu86/core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2
> tar -jtf core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2
>  | grep crtbegin.o returns nothing.
> But 
> wget
> http://autobuilder.yoctoproject.org/nightly/20110402-1/machines/qemu/qemu86/poky-image-sato-sdk-qemux86-20110403065104.rootfs.tar.bz2
> tar -jtf core-image-sato-sdk-qemux86-20110428214821.rootfs.tar.bz2
Sorry for the typo -- I meant "tar -jtf poky-image-sato-sdk-qemux86-20110403065104.rootfs.tar.bz2..." here.

>  | grep crtbegin.o
> returns
> ./usr/lib/i586-poky-linux/4.5.1/crtbegin.o.
> So looks this bug crept into poky master after Apr 2 somehow.

The recent good one seems:
 http://autobuilder.yoctoproject.org/nightly/20110423-1/machines/qemu/qemumips/core-image-sato-sdk-qemumips-20110423220931.rootfs.tar.bz2
Comment 2 Liang Wang 2011-05-09 01:57:00 UTC
This issue also occurs on the latest nightly build 20110506-4 for qemuarm-sato-sdk, mpc8315e-sato-sdk and routerstationpro-sato-sdk.

build http://autobuilder.yoctoproject.org/nightly/20110506-4
git commit 856a5e496b7ddd814f6a94552d02074f0ab30842


tar jtf core-image-sato-sdk-routerstationpro-20110507194330.rootfs.tar.bz2 | grep crtbegin.o  returns nothing.
Comment 3 liang li 2011-05-09 03:27:33 UTC
the error also happend on mpc8315e-rdb sato-sdk images from nightly build 20110506-4:
http://autobuilder.pokylinux.org/nightly/20110506-4/machines/mpc8315e-rdb/ppc/

When use gcc and g++ to compile c program ,the errors below:
root@mpc8315e-rdb:~# g++ test.c -o test -lm
/usr/lib/gcc/powerpc-poky-linux/4.5.1/../../../../powerpc-poky-linux/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/lib/gcc/powerpc-poky-linux/4.5.1/../../../../powerpc-poky-linux/bin/ld: cannot find libgcc.a
collect2: ld returned 1 exit status
use command "gcc test.c -o test -lm" ,got the similiar result.
 
Compare the rootfs of 20110412-1 and 20110506-4:
crtbegin.o and libgcc.a exist in "/usr/lib/powerpc-poky-linux/4.5.1" dir of 20110412-1 rootfs, but all not exist in 20110506-4 rootfs,and "/usr/lib/powerpc-poky-linux" dir doesn't exist.
Comment 4 Nitin Kamble 2011-05-09 08:42:54 UTC
so the issue came up in the 20110423 - 20110506 time frame, right ?
Comment 5 liang li 2011-05-09 18:33:40 UTC
the both file crtbegin.o and libgcc.a exists in mpc8315e-rdb rootfs images from nightly build 20110423-1:
http://autobuilder.pokylinux.org/nightly/20110423-1/machines/mpc8315e-rdb/ppc/
Comment 6 liang li 2011-05-09 21:06:55 UTC
(In reply to comment #3)
> the error also happend on mpc8315e-rdb sato-sdk images from nightly build
> 20110506-4:
> http://autobuilder.pokylinux.org/nightly/20110506-4/machines/mpc8315e-rdb/ppc/
> 
> When use gcc and g++ to compile c program ,the errors below:
> root@mpc8315e-rdb:~# g++ test.c -o test -lm
> /usr/lib/gcc/powerpc-poky-linux/4.5.1/../../../../powerpc-poky-linux/bin/ld:
> cannot find crtbegin.o: No such file or directory
> /usr/lib/gcc/powerpc-poky-linux/4.5.1/../../../../powerpc-poky-linux/bin/ld:
> cannot find libgcc.a
> collect2: ld returned 1 exit status
> use command "gcc test.c -o test -lm" ,got the similiar result.
> 
> Compare the rootfs of 20110412-1 and 20110506-4:
> crtbegin.o and libgcc.a exist in "/usr/lib/powerpc-poky-linux/4.5.1" dir of
> 20110412-1 rootfs, but all not exist in 20110506-4 rootfs,and
> "/usr/lib/powerpc-poky-linux" dir doesn't exist.

the similiar error also happened when compile a C program using gcc and g++  from toolchain image from nightly build 20110506-4:
http://autobuilder.pokylinux.org/nightly/20110506-4/toolchain/x86_64/poky-eglibc-x86_64-powerpc-toolchain-gmae-1.0+snapshot-20110508.tar.bz2
errors below:
1. source /opt/poky/1.0+snapshot/environment-setup-ppc603e-poky-linux
2. ${CC} test.c -o testc -lm -static
/opt/poky/1.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/libexec/ppc603e-poky-linux/gcc/powerpc-poky-linux/4.6.0/ld: cannot find crtbeginT.o: No such file or directory
/opt/poky/1.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/libexec/ppc603e-poky-linux/gcc/powerpc-poky-linux/4.6.0/ld: cannot find -lgcc
/opt/poky/1.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/libexec/ppc603e-poky-linux/gcc/powerpc-poky-linux/4.6.0/ld: cannot find -lgcc_eh
collect2: ld returned 1 exit status
3. the same error when run "${CXX} test.cpp -o testcpp -lm -static". 

test env: 
ubuntu 10.10 x86_64 
kernel : 2.6.35-28-generic
Comment 7 Nitin Kamble 2011-05-10 18:31:27 UTC
The crt*.o files are installed by libgcc-dev rpm. Is that installed in the failing case ? if yes what files are installed by the libgcc-dev?
Comment 8 liang li 2011-05-10 18:48:13 UTC
On mpc8315e-rdb, only libgcc-s-dev-4.6.0-r0.ppc603e was found :
root@mpc8315e-rdb:~# rpm -qa | grep libgcc
libgcc1-4.6.0-r0.ppc603e
libgcc-s-dev-4.6.0-r0.ppc603e
--------------
Files installed by libgcc-s-dev-4.6.0-r0.ppc603e:
root@mpc8315e-rdb:~# rpm -ql libgcc-s-dev-4.6.0-r0
/lib
/lib/libgcc_s.so
Comment 9 Nitin Kamble 2011-05-10 18:49:33 UTC
thanks liang li, clearly the libgcc-dev package is missing the crt*.o files.
Comment 10 Nitin Kamble 2011-05-10 18:52:32 UTC
Also it is getting mixed with gcc 4.6.0 
# rpm -qa | grep gcc
libgcc1-4.6.0-r0.i586
perl-module-extutils-cbuilder-platform-windows-gcc-5.12.3-r0.i586
gcc-4.5.1-r4.i586
libgcc-s-dev-4.6.0-r0.i586
gcc-symlinks-4.5.1-r4.i586

It should not be using 4.6.0 version of gcc.
Comment 11 Nitin Kamble 2011-05-10 18:57:04 UTC
I think I have fix for the bug:
diff --git a/meta/conf/distro/include/poky-default.inc b/meta/conf/distro/includ
index 91985b3..0003865 100644
--- a/meta/conf/distro/include/poky-default.inc
+++ b/meta/conf/distro/include/poky-default.inc
@@ -35,6 +35,8 @@ PREFERRED_VERSION_gcc-crosssdk-intermediate ?= "${SDKGCCVERSIO
 PREFERRED_VERSION_gcc-cross-canadian ?= "${GCCVERSION}"
 PREFERRED_VERSION_gcc-runtime ?= "${GCCVERSION}"
 PREFERRED_VERSION_gcc-runtime-nativesdk ?= "${SDKGCCVERSION}"
+PREFERRED_VERSION_libgcc ?= "${GCCVERSION}"
+PREFERRED_VERSION_libgcc-nativesdk ?= "${SDKGCCVERSION}"
 PREFERRED_VERSION_binutils ?= "${BINUVERSION}"
 PREFERRED_VERSION_binutils-cross ?= "${BINUVERSION}"
 PREFERRED_VERSION_binutils-crosssdk ?= "${BINUVERSION}"
Comment 13 Dexuan Cui 2011-05-24 19:27:48 UTC
(In reply to comment #12)
> http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=e8fd633fe45ef338a45350d4414d93005a54417a

With this fix, I can verify the crt*.o files are installed into target image now.