Bug 3156

Summary: ld problems with relocated toolchain
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Jack Mitchell <jack>
Component: devtools / tool chainAssignee: Laurentiu Palcu <laurentiu.palcu>
Status: VERIFIED INVALID QA Contact:
Severity: normal    
Priority: High CC: alexandru.c.georgescu, ioanax.grigoropol, jessica.zhang, meta.mr.watcher, meta.watcher
Version: unspecified   
Target Milestone: 1.3 M5   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Attachments:
Description Flags
c++ test application
none
Compilation output
none
Compilation Output
none
Make output none

Description Jack Mitchell 2012-09-21 14:32:41 UTC
I am currently having issues building my application with the latest toolchain.

I have used the new capabilities of it being relocatable to place it somewhere sensible and I think this may be what is breaking it. My old toolchain in /opt still works perfectly.

The error I receive is:

/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/ld: cannot find crtbegin.o: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [R0005] Error 1

However, crtbeign.o is at the path:

   [jack@archHP armv7a-vfp-neon-poky-linux-gnueabi]$ pwd
/home/jack/Projects/R0005-SDK-210912/sysroots/armv7a-vfp-neon-poky-linux-gnueabi
   [jack@archHP armv7a-vfp-neon-poky-linux-gnueabi]$ find . -name
   crtbegin.o
   ./usr/lib/arm-poky-linux-gnueabi/4.7.2/crtbegin.o
   [jack@archHP armv7a-vfp-neon-poky-linux-gnueabi]$ ls usr/lib
   lib/     libexec/
   [jack@archHP armv7a-vfp-neon-poky-linux-gnueabi]$ ls usr/libexec/
   pt_chown
   [jack@archHP armv7a-vfp-neon-poky-linux-gnueabi]$
Comment 1 Jack Mitchell 2012-09-21 15:16:04 UTC
Exact steps:

bitbake meta-toolchain
run toolchain setup script
tell application to use new toolchain and sysroot
compile

This was appearing before the patches that were merged today.

Works fine when installed in default location.

Some more verbose output:

/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/as -v -I /home/jack/Projects/R0005-SDK-210912/sysroots/armv7a-vfp-neon-poky-linux-gnueabi/usr/include -mcpu=cortex-a8 -mfloat-abi=softfp -mfpu=neon -meabi=5 -o src/systemConfig.o /tmp/ccr24jiu.s
GNU assembler version 2.22 (arm-poky-linux-gnueabi) using BFD version (GNU Binutils) 2.22
COMPILER_PATH=/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/:/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/
LIBRARY_PATH=/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../lib/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/:/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../lib/armv7a-vfp-neon-poky-linux-gnueabi/gcc/
COLLECT_GCC_OPTIONS='-I' '/home/jack/Projects/R0005-SDK-210912/sysroots/armv7a-vfp-neon-poky-linux-gnueabi/usr/include' '-O0' '-mfpu=neon' '-mfloat-abi=softfp' '-mcpu=cortex-a8' '-g3' '-Wall' '-Wextra' '-c' '-fmessage-length=0' '-v' '-MMD' '-MP' '-MF' 'src/systemConfig.d' '-MT' 'src/systemConfig.d' '-o' 'src/systemConfig.o' '-mtls-dialect=gnu'
/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/ld: cannot find crt1.o: No such file or directory
/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/ld: cannot find crti.o: No such file or directory
/home/jack/Projects/R0005-SDK-210912/sysroots/x86_64-pokysdk-linux/usr/bin/armv7a-vfp-neon-poky-linux-gnueabi/../../libexec/armv7a-vfp-neon-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/4.7.2/ld: cannot find crtbegin.o: No such file or directory
/lib/libpthread.so.0: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [R0005] Error 1
Comment 2 Jessica 2012-09-21 16:39:22 UTC
Jack,

Just want to confirm that the error shows with the toolchain generatd with the most recent patch that Laurentiu sent and merged into master (as of last night or today as to which time zone we're talking about), right?  
Also, why chang this to target 1.1.2.  The relocatable SDK is a new feature in 1.3, so not applicatible to anything prior to 1.3
Comment 3 Jack Mitchell 2012-09-21 16:47:33 UTC
Hi Jessica,

I performed a git pull at around 4pm GMT - I cannot tell you the revision until I am back at work on Monday. I imagine it would be: 

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=30b7781650e3ff092d04889beab2e87eaff29cdb

Best Regards,
Jack.
Comment 4 Laurentiu Palcu 2012-09-21 17:28:23 UTC
Created attachment 832 [details]
c++ test application
Comment 5 Laurentiu Palcu 2012-09-21 17:28:49 UTC
Created attachment 833 [details]
Compilation output
Comment 6 Laurentiu Palcu 2012-09-21 17:33:13 UTC
I created a small C++ test app and tested if it compiles with both mips and arm toolchains I just generated. It compiled just fine! No error about not finding the crt*.o objects.

I attached both the test app and the compilation output.

I'm afraid I'm gonna need more info about your setup. At my end, it just works!

Steps I followed:

$ MACHINE=qemuarm bitbake meta-toolchain-sdk
$ bash tmp/deploy/sdk/poky-eglibc-x86_64-arm-toolchain-gmae-1.2+snapshot-20120921.sh
$ source environment-setup-armv5te-poky-linux-gnueabi
$ make
$ qemu-arm ../sdk/sysroots/armv5te-poky-linux-gnueabi/lib/ld-linux.so.3 --library-path ../sdk/sysroots/armv5te-poky-linux-gnueabi/lib:../sdk/sysroots/armv5te-poky-linux-gnueabi/usr/lib ./test_hw
Constructor!
Hello World!
Destructor!
Comment 7 Jack Mitchell 2012-09-24 08:44:03 UTC
Created attachment 834 [details]
Compilation Output

You can see there are still some reference to /opt in the output, however I have no idea where they're coming from.
Comment 8 Jack Mitchell 2012-09-24 08:45:39 UTC
It might also be worth noting that my application is a C application rather than C++. I am also compiling from within Eclipse using thier own autmatic makefiles and I do not pass it a sysroot, but instead I pass it the sysroot lib and include directories.
Comment 9 Jack Mitchell 2012-09-24 08:47:11 UTC
Created attachment 835 [details]
Make output
Comment 10 Laurentiu Palcu 2012-09-24 08:54:42 UTC
From the make.output it looks like the crt*.o objects are found just fine if running make manually... It might be an Eclipse plugin issue here not creating the Makefiles correctly and/or not sourcing the environment properly.
Comment 11 Jack Mitchell 2012-09-24 09:01:15 UTC
Ok, can I just note that I am not using the Yocto Elclipse Plugin here but a standard Eclipse project configured to use the toolchain.
Comment 12 Jessica 2012-09-24 16:33:28 UTC
Jack,

Is there any particular reason that you're not passing eclipse project a sysroot and instead of your sysroot include and lib sub-dirs? 

Also, please pass the sysroot as the root directory of your sysroot per your setup, for you case, "-sysroot=/home/jack/Projects/R0005-SDK-210912/sysroots"
Comment 13 Jack Mitchell 2012-09-25 08:35:32 UTC
This is now fixed.

I needed to pass the --sysroot flag to both the compiler AND the linker - I had tried the sysroot flag with one but not realised that it didn't also set it for the other.

Thank you for your help everyone, sorry for wasting your time!
Comment 14 Laurentiu Palcu 2012-09-25 09:18:11 UTC
Closing, problem solved.
Comment 15 Alexandru Georgescu 2012-10-16 13:33:09 UTC
verified