Bug 1276

Summary: [qemuppc] hello-mod fails to build
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Saul Wold <sgw>
Component: coreAssignee: Darren Hart <dvhart>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium CC: meta.mr.watcher, meta.watcher
Version: 1.0   
Target Milestone: 1.1   
Hardware: Other   
OS: ppc   
Whiteboard: bandaid available, investigating proper fix (16-Aug-2011)
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: ---

Description Saul Wold 2011-07-22 14:12:02 UTC
ERROR: Function 'do_compile' failed (see /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0/temp/log.do_compile.48446 for further information)
ERROR: Logfile of failure stored in: /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0/temp/log.do_compile.48446
Log data follows:
| ERROR: Function 'do_compile' failed (see /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0/temp/log.do_compile.48446 for further information)
| NOTE: make -j 32 -e MAKEFLAGS= CC=ccache powerpc-poky-linux-gcc  LD=powerpc-poky-linux-ld --sysroot=/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc  AR=powerpc-poky-linux-ar  -C /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel scripts
| make: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[1]: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[1]: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[1]: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[2]: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[2]: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[2]: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[2]: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make[1]: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| NOTE: make -j 32 -e MAKEFLAGS= KERNEL_PATH=/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel KERNEL_SRC=/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel KERNEL_VERSION=3.0.0-rc7-yocto-standard+ CC=ccache powerpc-poky-linux-gcc  LD=powerpc-poky-linux-ld --sysroot=/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc  AR=powerpc-poky-linux-ar
| make -C /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel M=/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0
| make[1]: Entering directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
|   Building modules, stage 2.
|   MODPOST 1 modules
|   LD [M]  /vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0/hello.ko
| powerpc-poky-linux-ld: cannot find arch/powerpc/lib/crtsavres.o: No such file or directory
| make[2]: *** [/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/work/qemuppc-poky-linux/hello-mod-0.1-r0/hello.ko] Error 1
| make[1]: *** [modules] Error 2
| make[1]: Leaving directory `/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/build/tmp/sysroots/qemuppc/kernel'
| make: *** [all] Error 2
| ERROR: oe_runmake failed
NOTE: package hello-mod-0.1-r0: task do_compile: Failed
NOTE: package task-core-qt-1.0-r3: task do_package: Started
ERROR: Task 6255 (/vol/1/sgw/autobuilder/poky-slave/poky-full-non/build/meta/recipes-kernel/hello-mod/hello-mod_0.1.bb, do_compile) failed with exit code '1'
Comment 1 Darren Hart 2011-08-16 10:58:38 UTC
This appears to be a bug in the Linux kernel build system. Removing the clean command from the kernel.bbclass allows hello-mod to build successfully. As the clean target is intended to clean everything except what is necessary to build external modules, it appears to be broken per spec. I'm looking into a fix.
Comment 2 Darren Hart 2011-08-16 20:48:09 UTC
There has been several issues regarding arch/powerpc/lib/crtsavres.o. It is the only .o required for module building in the kernel so far as I can tell, and the make system doesn't deal with it well.

I've sent details to the powerpc maintainers and Makefile contributors to try and come up with an informed solution (I don't know why it's listed in KBUILD_LDFLAGS_MODULE as it seems to build fine with that commented out).

If I am unsuccessful there, the following can serve as a fix until a proper upstream fix becomes available:

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 7dc9cc6..92c0736 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -159,6 +159,13 @@ kernel_do_install() {
        find $kerneldir -path $kerneldir/scripts -prune -o -name "*.[csS]" -exec rm '{}' \;
        find $kerneldir/Documentation -name "*.txt" -exec rm '{}' \;
 
+       # FIXME: remove this block once a fix is available in mainline.
+       # The clean target removes crtsavres.o which is present in
+       # KBUILD_LDFLAGS_MODULE, making it required to build external modules.
+       if [ ${ARCH} = "powerpc" ]; then
+               cp arch/powerpc/lib/crtsavres.o $kerneldir/arch/powerpc/lib/crtsavres.o
+       fi
+
        # Remove the following binaries which cause strip errors
        # during do_package for cross-compiled platforms
        bin_files="arch/powerpc/boot/addnote arch/powerpc/boot/hack-coff \