Bug 3920 - Recipe for meta-toolchain creates an environment script with bad LDFLAGS
Summary: Recipe for meta-toolchain creates an environment script with bad LDFLAGS
Status: RESOLVED NOTABUG
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 arm
: Medium major
Target Milestone: 1.4
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2013-02-21 15:20 UTC by Nick G
Modified: 2013-03-02 13:40 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick G 2013-02-21 15:20:43 UTC
I built a meta-toolchain using Yocto and wanted to use this to build a seperate u-boot and kernel (version 3.8 which is not in the meta-ti at the moment) to keep things consistent.

Sadly, I found that the flags exported by the environment-setup script are 'duff'. 

This is what I did...
Get a version of U-boot that has support for the am335x
[nick@zeus scratch]$ git clone git://git.denx.de/u-boot.git
[nick@zeus scratch]$ cd u-boot/
[nick@zeus u-boot]$ git checkout v2013.01.01

Source the environment
[nick@zeus u-boot]$ source /opt/poky/1.3/environment-setup-armv7a-vfp-neon-poky-linux-gnueabi 
[nick@zeus u-boot]$ export CROSS_COMPILE=arm-poky-linux-gnueabi-
[nick@zeus u-boot]$ export ARCH=arm
[nick@zeus u-boot]$ make  am335x_evm_config
Generating include/autoconf.mk
Configuring for am335x_evm - Board: am335x_evm, Options: SERIAL1,CONS_INDEX=1
[nick@zeus u-boot]$ make -s -j4
arm-poky-linux-gnueabi-ld.bfd: unrecognized option '-Wl,-O1'
arm-poky-linux-gnueabi-ld.bfd: use the --help option for usage information
make[1]: *** [libam33xx.o] Error 1
make: *** [arch/arm/cpu/armv7/am33xx/libam33xx.o] Error 2


When you look at the LDFLAGS you can see that they are set to some fairly mental values given the ld doesn't understand them:

[nick@zeus u-boot]$ echo $LDFLAGS 
-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed

To confirm this is the issue, by changing them to remove -Wl and -O1 (which are flags for CC):

[nick@zeus u-boot]$ export LDFLAGS="--hash-style=gnu"
[nick@zeus u-boot]$ make -s
Image Name:   U-Boot 2013.01-00328-g47104c3 fo
Created:      Thu Feb 21 15:04:39 2013
Image Type:   ARM U-Boot Firmware (uncompressed)
Data Size:    327812 Bytes = 320.13 kB = 0.31 MB
Load Address: 80800000
Entry Point:  00000000
Section CHSETTINGS offset 40 length c
CHSETTINGS (c0c0c0c1) valid:0 version:1 reserved:0 flags:0
GP Header: Size 14155 LoadAddr 402f0400
Section ESHCNITT offset 40000000 length c000000
CHSETTINGS (c1c0c0c0) valid:0 version:0 reserved:1 flags:0
GP Header: Size 14155 LoadAddr 402f0400
[nick@zeus u-boot]$ make clean
[nick@zeus u-boot]$ make -s -j4
Image Name:   U-Boot 2013.01-00328-g47104c3 fo
Created:      Thu Feb 21 15:05:08 2013
Image Type:   ARM U-Boot Firmware (uncompressed)
Data Size:    327812 Bytes = 320.13 kB = 0.31 MB
Load Address: 80800000
Entry Point:  00000000
Section CHSETTINGS offset 40 length c
CHSETTINGS (c0c0c0c1) valid:0 version:1 reserved:0 flags:0
GP Header: Size 14155 LoadAddr 402f0400
Section ESHCNITT offset 40000000 length c000000
CHSETTINGS (c1c0c0c0) valid:0 version:0 reserved:1 flags:0
GP Header: Size 14155 LoadAddr 402f0400
Comment 1 Richard Purdie 2013-02-22 14:52:00 UTC
I think it is assumed that gcc is being used as the linker (CCLD) in the majority of cases. These flags match the flags used in bitbake.conf and throughout the build system. There is no one magic set of flags which will likely work for all software.
Comment 2 Richard Purdie 2013-03-02 13:40:15 UTC
As mentioned, the LDFLAGS do match those used by bitbake when running builds and it is assumed gcc is being used for CCLD. It all comes down to using the correct configuration to build the software (see the .bb files for specific examples for specific pieces of software). Resolving the bug as such...