Bug 2531

Summary: ADT/Poky apps build fails with -static link option
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Robert Mueller <robert.mueller>
Component: coreAssignee: Paul Eggleton <bluelightning>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: High CC: alexandru.c.georgescu, jessica.zhang, meta.mr.watcher, meta.watcher, poky.adt.watcher, poky.watcher, richard.purdie, robert.mueller, song.liu
Version: 1.2   
Target Milestone: 1.3 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Robert Mueller 2012-06-01 18:09:45 UTC
It looks as though the default GCC configuration in ADT 1.2 with Denzil
(Yocto 1.2) does not support static linking out of the box. Is this a known
issue or intended behavior?


# echo $CXX
i586-poky-linux-g++
# echo $CXXFLAGS
-m32 -march=i586 --sysroot=/root/test-yocto/x86
# $CXX $CXXFLAGS -static hello.c
/opt/poky/1.2/sysroots/i686-pokysdk-linux/usr/libexec/i586-poky-linux/gcc/i5
86-poky-linux/4.6.4/ld: cannot find -lstdc++
/opt/poky/1.2/sysroots/i686-pokysdk-linux/usr/libexec/i586-poky-linux/gcc/i5
86-poky-linux/4.6.4/ld: cannot find -lm
/opt/poky/1.2/sysroots/i686-pokysdk-linux/usr/libexec/i586-poky-linux/gcc/i5
86-poky-linux/4.6.4/ld: cannot find -lc
collect2: ld returned 1 exit status
Comment 1 Jessica 2012-06-01 18:16:55 UTC
This is due to we are lacking static library files (.a) in the images that used to extracted as sysroot, e.g. sato-sdk
Comment 2 Saul Wold 2012-06-14 23:40:00 UTC
Which sysroot are you using and are you expecting all static libraries includes? Is this needed for 1.2 or can you work with 1.3 master?
Comment 3 Richard Purdie 2012-06-18 22:04:47 UTC
Moving to 1.3. Do we need some mechanism to include staticdev packages in sdk  images? I'd imagine this is a consequence of the more granular packaging. This should probably be looked at in the context of the other -dbg, -dev and -doc package bugs currently open...
Comment 4 Paul Eggleton 2012-07-11 13:07:54 UTC
Patches are now out on the OE-core list for review on this one (for merging into M3 rather than M2). They add a "staticdev-pkgs" IMAGE_FEATURES feature so that these packages can be optionally added.
Comment 5 Paul Eggleton 2012-07-30 12:50:25 UTC
Implemented in the following revisions:

fa5640d143beea4be101d6622d3fa133d04272f2
98b0f956e7d16c2791cc00dbb75187b886e4cbcd
Comment 6 Alexandru Georgescu 2012-09-25 09:38:27 UTC
Reopening since I could reproduce with http://autobuilder.yoctoproject.org/pub/nightly/20120916-2/toolchain/i686/poky-eglibc-i686-i586-toolchain-gmae-1.2+snapshot-20120916.sh

[yocto@vostro2 tmp]$ $CXX $CXXFLAGS -static compile.cpp 
/home/yocto/tmp/x86/sysroots/x86_64-pokysdk-linux/usr/bin/i586-poky-linux/i586-poky-linux-ld: cannot find -lstdc++
/home/yocto/tmp/x86/sysroots/x86_64-pokysdk-linux/usr/bin/i586-poky-linux/i586-poky-linux-ld: cannot find -lm
/home/yocto/tmp/x86/sysroots/x86_64-pokysdk-linux/usr/bin/i586-poky-linux/i586-poky-linux-ld: cannot find -lc
collect2: error: ld returned 1 exit status
[yocto@vostro2 tmp]$
Comment 7 Paul Eggleton 2012-09-25 09:43:36 UTC
I was told we would not add these files by default, we would just provide the option to add them, which I have done.

Jessica, what would you like to do here?
Comment 8 Jessica 2012-09-27 14:58:39 UTC
Yes, as long as we provide the mechanism to add them, we don't want to explode the image by adding them by default
Comment 9 Paul Eggleton 2012-09-27 18:25:20 UTC
OK, in that case I'll mark this as resolved again.
Comment 10 Alexandru Georgescu 2012-11-09 16:42:28 UTC
Hi,
I am reopening this because the static libraries are not installed in the sysroot of the standalone toolchain, built using the staticdev-pkgs option.


My investigation:
1. In order to have an image with static libraries, in local.conf the parameter "staticdev-pkgs" needs to be added as an extra image feature:
EXTRA_IMAGE_FEATURES = "debug-tweaks staticdev-pkgs"

2. Building and extracting the standalone toolchain (bitbake meta-toolchain-sdk) using this option does no add the *.a files under its sysroot libraries.

3. Instead, after building a core-image-sato-sdk qemu tarball image (using the same local.conf file as point 2.) and extracting it using runqemu-extract-sdk I could find the *.a files located in /usr/lib/ directory of that image.

So basically I believe there is a problem when the standalone toolchain is created (bitbake meta-toolchain-sdk).

tested with: "master:78983e939ab17f02f8911c8b0d0e326b419856b9"
Comment 11 Paul Eggleton 2012-11-10 13:17:47 UTC
It is not mentioned here but you need to set SDKIMAGE_FEATURES not (EXTRA_)IMAGE_FEATURES; meta-toolchain-sdk is not an image and therefore does not use the latter variables.
Comment 12 Alexandru Georgescu 2012-11-12 16:30:08 UTC
Hi Paul,
I have tried again only with: SDKIMAGE_FEATURES = "staticdev-pkgs ".

Build the toolchain with meta-toolchain-sdk. Again, I have the same errors :(.

Is there something wrong with my configuration?
Also, the static libraries should be available in the toolchain aswell, right?

Regards,
Alex.
Comment 13 Paul Eggleton 2012-11-12 17:39:59 UTC
So, you're right, looking again at this more closely it has only been implemented in a form that works for images; i.e. either for the images themselves with (EXTRA_)IMAGE_FEATURES or with SDKIMAGE_FEATURES for creating an SDK for an image (i.e. when you run bitbake -c populate_sdk name-of-image).

I'm not sure whether being able to add the staticdev packages easily to meta-toolchain-sdk was intended to be part of this task. If it is I would suggest creating a new bug rather than reopening this one as it is a non-trivial extension.
Comment 14 Alexandru Georgescu 2012-11-13 10:43:40 UTC
Ok Paul,
I will open a new bug.

Thank you for your help,
Alex.
Comment 15 Alexandru Georgescu 2012-11-15 15:08:40 UTC
Hi,
I have opened https://bugzilla.yoctoproject.org/show_bug.cgi?id=3441 for toolchain specific.