Bug 12757

Summary: kernel do_configure fails to use tools in recipe-sysroot-native
Product: [Build System, Metadata & Runtime] OE-Core Reporter: He Zhe <zhe.he>
Component: kernelAssignee: Bruce Ashfield <bruce.ashfield>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: Medium+ CC: randy.macleod, tom.zanussi, zhenfeng.zhao
Version: 2.6   
Target Milestone: 2.6 M1   
Hardware: All   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description He Zhe 2018-05-22 03:12:58 UTC
ERROR: linux-yocto-dev-4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0 do_configure: Function failed: do_configure (log file is located at /buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/temp/log.do_configure.36193)                                                                         
ERROR: Logfile of failure stored in: /buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/temp/log.do_configure.36193
Log data follows:                                                                
| DEBUG: Executing python function check_oldest_kernel                           
| DEBUG: Python function check_oldest_kernel finished                            
| DEBUG: Executing shell function do_configure                                   
| NOTE: make HOSTCC=gcc  -isystem/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/include -O2 -pipe -L/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -L/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-rpath-link,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -Wl,-rpath-link,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-rpath,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -Wl,-rpath,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/buildarea/path/build/qemux86-64-poky/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2 HOSTCPP=gcc  -E -C /buildarea/path/build/qemux86-64-poky/build/tmp/work-shared/qemux86/kernel-source O=/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/linux-qemux86-standard-build oldnoconfig
| make: Entering directory `/buildarea/path/build/qemux86-64-poky/build/tmp/work-shared/qemux86/kernel-source'
| make[1]: Entering directory `/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/linux-qemux86-standard-build'
| arch/x86/Makefile:184: *** Compiler lacks asm-goto support..  Stop.            
| make[1]: Leaving directory `/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/linux-qemux86-standard-build'
| make: *** [sub-make] Error 2                                                   
| make: Leaving directory `/buildarea/path/build/qemux86-64-poky/build/tmp/work-shared/qemux86/kernel-source'
| WARNING: /buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/temp/run.do_configure.36193:1 exit 2 from 'make HOSTCC="gcc  -isystem/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/include -O2 -pipe -L/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -L/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-rpath-link,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -Wl,-rpath-link,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-rpath,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/usr/lib -Wl,-rpath,/buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/recipe-sysroot-native/lib -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/buildarea/path/build/qemux86-64-poky/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2" HOSTCPP="gcc  -E" "$@"'
| ERROR: Function failed: do_configure (log file is located at /buildarea/path/build/qemux86-64-poky/build/tmp/work/qemux86-poky-linux/linux-yocto-dev/4.16-rc++gitAUTOINC+4f7cfac9d0_0edcedd118-r0/temp/log.do_configure.36193)
ERROR: Task (/buildarea/path/poky/meta/recipes-kernel/linux/linux-yocto-dev.bb:do_configure) failed with exit code '1'



Using linux-yocto-dev as virtual/kenrel can cause the above error.
PREFERRED_PROVIDER_virtual/kernel="linux-yocto-dev"

The latest kernel includes the following commit(linux-yocto-4.12 has not yet). With that, "make oldnoconfig" would run scripts/gcc-goto.sh which runs i586-poky-linux-gcc to check if asm "goto" works well. But i586-poky-linux-gcc is NOT found in this case.

Prepending the following code gcc-goto.sh would show us that every directories in recipe-sysroot-native and recipe-sysroot do not exist at the very time of do_configure running.

But after the error recipe-sysroot-native and recipe-sysroot will have been there.

Tasks dependencies seem defined well.
"linux-yocto-dev.do_configure" -> "linux-yocto-dev.do_prepare_recipe_sysroot"
"linux-yocto-dev.do_prepare_recipe_sysroot" -> "gcc-cross-i586.do_populate_sysroot"

Only if we cleansstate virtual/kernel and rebuild it, can it pass.
This can be reproduced every time.



echo $@ > /tmp/goto.log 2>&1
echo "----------------" >> /tmp/goto.log 2>&1
which i586-poky-linux-gcc >> /tmp/goto.log 2>&1
echo "----------------" >> /tmp/goto.log 2>&1
for i in `echo "$PATH"|sed 's/:/ /g'`;do
        echo $i >> /tmp/goto.log 2>&1
        ls $i >> /tmp/goto.log 2>&1
done
echo "----------------" >> /tmp/goto.log 2>&1
echo "PATH=$PATH" >> /tmp/goto.log 2>&1
echo "----------------" >> /tmp/goto.log 2>&1
cat << "END" | $@ -x c - -c -o /tmp/a.out >> /tmp/goto.log 2>&1 && echo "y"




commit e501ce957a786ecd076ea0cfb10b114e6e4d0f40
Author:     Peter Zijlstra <peterz@infradead.org>
AuthorDate: Wed Jan 17 11:42:07 2018 +0100
Commit:     Thomas Gleixner <tglx@linutronix.de>
CommitDate: Tue Mar 20 10:58:02 2018 +0100

    x86: Force asm-goto
    
    We want to start using asm-goto to guarantee the absence of dynamic
    branches (and thus speculation).
    
    A primary prerequisite for this is of course that the compiler
    supports asm-goto. This effecively lifts the minimum GCC version to
    build an x86 kernel to gcc-4.5.
    
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Cc: torvalds@linux-foundation.org
    Link: https://lkml.kernel.org/r/20180319201327.GJ4043@hirez.programming.kicks-ass.net
Comment 1 Bruce Ashfield 2018-05-28 15:19:40 UTC
So what are the steps to reproduce this ?

I've obviously been building and booting linux-yocto-dev with each upgrade, and I'm not running into it.

I was able to build and boot today, so does this have to be a completely clean build ?  or some other set of steps ? I've tried various clean/distclean steps on linux-yocto-dev.

I think I triggered this once, but can't anymore .. so I need some steps to reproduce.

root@qemux86-64:~# uname -a
Linux qemux86-64 4.17.0-rc7-yoctodev-standard #1 SMP PREEMPT Mon May 28 15:07:26 UTC 2018 x86_64 GNU/Linux
root@qemux86-64:~#
Comment 2 He Zhe 2018-05-28 16:03:29 UTC
I just tried again. After updating from latest poky, I can still reproduce it by appending the follow line to local.conf. And I got the same output of do_configure error.
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-dev"
Comment 3 Bruce Ashfield 2018-05-28 16:04:15 UTC
(In reply to comment #2)
> I just tried again. After updating from latest poky, I can still reproduce
> it by appending the follow line to local.conf. And I got the same output of
> do_configure error.
> PREFERRED_PROVIDER_virtual/kernel = "linux-yocto-dev"

Then we are stumped. Since obviously, that's the only way to enable linux-yocto-dev, and that's how I build it as well.
Comment 4 Bruce Ashfield 2018-05-30 17:21:22 UTC
With this change, I can no longer reproduce the problem.

Can you manually make this change and try a fresh build ?

-----------------

diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
index 68d218584a7e..15b3f326bde7 100644
--- a/meta/classes/kernel.bbclass
+++ b/meta/classes/kernel.bbclass
@@ -494,7 +494,8 @@ sysroot_stage_all () {
        :
 }
 
-KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig"
+KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} CC="${KERNEL_CC}" oldnoconfig"
+#KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig"
 
 python check_oldest_kernel() {
     oldest_kernel = d.getVar('OLDEST_KERNEL')
Comment 5 Bruce Ashfield 2018-05-30 19:25:20 UTC
Oops. Sorry, I forgot about the QA error this triggers, do not test it
yet!

Bruce(In reply to comment #4)
> With this change, I can no longer reproduce the problem.
> 
> Can you manually make this change and try a fresh build ?
> 
> -----------------
> 
> diff --git a/meta/classes/kernel.bbclass b/meta/classes/kernel.bbclass
> index 68d218584a7e..15b3f326bde7 100644
> --- a/meta/classes/kernel.bbclass
> +++ b/meta/classes/kernel.bbclass
> @@ -494,7 +494,8 @@ sysroot_stage_all () {
>         :
>  }
>  
> -KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig"
> +KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} CC="${KERNEL_CC}"
> oldnoconfig"
> +#KERNEL_CONFIG_COMMAND ?= "oe_runmake_call -C ${S} O=${B} oldnoconfig"
>  
>  python check_oldest_kernel() {
>      oldest_kernel = d.getVar('OLDEST_KERNEL')

Oops. Sorry, I forgot about the QA error this triggers, do not test it
yet!

Bruce
Comment 6 He Zhe 2018-05-31 10:00:43 UTC
Thanks, Bruce. I've validated your patch. It works for do_configure.

But I don't get how it takes effect. In the patch we just overwrite CC with KERNEL_CC which is x86_64-wrs-linux-gcc plus some parameters. CC originally defined in top Makefile is also x86_64-wrs-linux-gcc. How come this overwrite makes x86_64-wrs-linux-gcc available?

Meanwhile I checked the tools in recipe-sysroot-native and recipe-sysroot as did in the first comment, some of them like recipe-sysroot/usr/bin/crossscripts or bison are still unavailable during do_configure. Seems we miss the real bug.
Comment 7 Bruce Ashfield 2018-05-31 13:06:51 UTC
(In reply to comment #6)
> Thanks, Bruce. I've validated your patch. It works for do_configure.
> 
> But I don't get how it takes effect. In the patch we just overwrite CC with
> KERNEL_CC which is x86_64-wrs-linux-gcc plus some parameters. CC originally
> defined in top Makefile is also x86_64-wrs-linux-gcc. How come this
> overwrite makes x86_64-wrs-linux-gcc available?
> 
> Meanwhile I checked the tools in recipe-sysroot-native and recipe-sysroot as
> did in the first comment, some of them like
> recipe-sysroot/usr/bin/crossscripts or bison are still unavailable during
> do_configure. Seems we miss the real bug.

That was just a debug/informational patch. From what I was seeing, we were using the host compiler and it was missing the right support. By using that compiler definition, either we get a clear failure or force the sysroot population. That's the part I'm working on now.
Comment 8 Bruce Ashfield 2018-06-19 14:12:25 UTC
merged to oe-core rev ff1bdd75d50f0ebac3d599e461685ace29559a82