Bug 605

Summary: GCC-cross uses incorrect paths making sstate copy unusable
Product: [Build System, Metadata & Runtime] Meta-yocto Reporter: Gary Thomas <gary>
Component: meta-yoctoAssignee: Kevin Tian <kevin.tian>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: kevin.tian, poky.bs.watcher, poky.watcher, richard.purdie, sgw
Version: unspecified   
Target Milestone: 1.0 M3   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---
Attachments:
Description Flags
Add --sysroot to ${KERNEL_CC} to fix path problems none

Description Gary Thomas 2010-12-20 10:38:11 UTC
I just tried this experiment:
  * Build Poky on MachineA to some directory $NEW
  * Copy Poky ($POKYBASE) and $NEW/sstate-cache to MachineB, in this case
    the path for $POKYBASE is the same on both machines but $NEW differs.
    MachineA:$NEW does not exist on MachineB
  * Try to build on Machine B, pointing SSTATE_MIRRORS to $NEW/sstate-cache
    This build is in $NEW2
The process fails for me building the kernel:
  | arm-poky-linux-gnueabi-ld: libgcc.a: No such file: No such file or directory
Looking carefully, I can see that the compiler is looking for libgcc.a in
the directory path $NEW that is only on MachineA.
Comment 1 Gary Thomas 2010-12-20 10:39:37 UTC
My test was based on commit bb783afd4daa3f57fb26e2bb86f5bc9cbeb11df0
Comment 2 Kevin Tian 2010-12-21 03:55:08 UTC
I only have one machine, and thus tried a different step:

* build Poky in $DIR1, with sstate generated in ${SSTATE-CACHE} (a global one)
* then with same $POKYBASE, create a new build $DIR2, with SSTATE_MIRRORS
pointing to ${SSTATE-CACHE}
* move $DIR1 to $DIR1.bak

I think this way it's identical to what Gary did with two machines, but I didn't see such failures.

so Gary, could you try latest poky master or verify whether my single-machine steps may expose same failure in your side? Or is there any step not equivalent between our cases?

Mine commit is based on:


commit 60ccdaa0ea128ac19113c0746c6e12bd02b2fc12
Author: Mark Hatle <mark.hatle@windriver.com>
Date:   Wed Nov 24 18:06:04 2010 -0600

    poky-init-build-env: Enable all POSIX shells

    Update the script so that it will work in more then just bash.  If bash
    is not used, it will assume the PWD is the Poky location.  (This is because
    BASH_SOURCE is a bash-ism, and equivalent functionality is not available in
    other shells).

    This has been verified with dash (see comment in the code), ksh, zsh and
    of course bash.

    Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Comment 3 Gary Thomas 2010-12-23 04:25:26 UTC
Created attachment 82 [details]
Add --sysroot to ${KERNEL_CC} to fix path problems
Comment 4 Richard Purdie 2010-12-23 05:47:09 UTC
Gary, could you paste a little more context around the error please? Is this whilst building something in kernel space or userspace (like tracing tools)? The kernel itself shouldn't need libgcc...
Comment 5 Gary Thomas 2010-12-27 10:59:03 UTC
I have my own kernel recipe which is very simple and based
on 2.6.32.

I've reproduced this error on a single machine like this:
  * Build Poky in /local/poky_base
  * Rename /local/poky_base to /local/poky_base_moved
  * Build Poky in /local/poky_rebuild, pointing SSTATE_MIRRORS
    to /local/poky_base_moved/sstate-cache
  * Bump PR on my kernel recipe (manually)
  * Rebuild - fails linking the kernel

What I found is I get this error:
  arm-poky-linux-gnueabi-ld --sysroot=/local/poky_rebuild/tmp/sysroots/armv7a-poky-linux-gnueabi     --defsym zreladdr=0x80008000 --defsym initrd_phys=0x80800000 --defsym params_phys=0x80000100 -p --no-undefined -X libgcc.a -T arch/arm/boot/compressed/vmlinux.lds arch/arm/boot/compressed/head.o arch/arm/boot/compressed/piggy.o arch/arm/boot/compressed/misc.o -o arch/arm/boot/compressed/vmlinux 
  arm-poky-linux-gnueabi-ld: libgcc.a: No such file: No such file or directory

This is derived from the bootstrap Makefile.  Using grep in the arch/arm/boot
tree, I found this:
  tmp/work/cobra3530p60-poky-linux-gnueabi/linux-am-2.6.32-1/linux-am-2.6.32/arch/arm/boot/compressed/Makefile:  $(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name) -T

The problem with this is that $(CC) in the kernel build
corresponds to ${KERNEL_CC} from meta/classes/kernel.bbclass
Without the --sysroot= in that variable, it will try and find
libgcc.a in the tree where GCC was built (/local/poky_base)
but it's no longer there.

It's pretty obvious that at least for this kernel, the 
dependency on libgcc.a is explicit.  Adding the --sysroot=
option to ${KERNEL_CC} seems like a useful way to fix
the build.
Comment 6 Kevin Tian 2011-01-18 06:04:01 UTC
fixed by 14762f71b9f839432ede0406b9443ce20b918378