<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>9020</bug_id>
          
          <creation_ts>2016-02-01 13:53:06 +0000</creation_ts>
          <short_desc>populate_sdk fails when I have another version of gcc in my own layer</short_desc>
          <delta_ts>2016-03-29 15:11:23 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>configuration</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>x86_64</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>2.1 M4</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Maksim E. Kozlov">maksim.e.kozlov</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>maksim.e.kozlov</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>58387</commentid>
    <comment_count>0</comment_count>
    <who name="Maksim E. Kozlov">maksim.e.kozlov</who>
    <bug_when>2016-02-01 13:53:06 +0000</bug_when>
    <thetext>Error occurs when I try to do &apos;-c populate_sdk&apos;

I have my own layer which contains additional gcc version (4.8.4) which was just copied from older version of OE core with only modifications of paths of included files to get inc files from current dirrectory, not from meta/recipes-devtools/gcc

Layer has BBFILE_PRIORITY_my-layer = &quot;6&quot; and my distro has GCCVERSION ?= &quot;4.8%&quot;. With this configuration all build tasks are working fine (include -c populate_sdk).
Bat when I change GCCVERSION ?= &quot;5.%&quot; I get error.

At first I faced with strange error during the nativesdk-libgcc-initial building:

...

| /work/tmp/ram/proteus/tmp-uclibc/work-shared/gcc-5.3.0-r0/gcc-5.3.0/libgcc/config/i386/cpuinfo.c: In function &apos;get_available_features&apos;:
| /work/tmp/ram/proteus/tmp-uclibc/work-shared/gcc-5.3.0-r0/gcc-5.3.0/libgcc/config/i386/cpuinfo.c:303:17: error: &apos;bit_AVX512F&apos; undeclared (first use in this function)
|        if (ebx &amp; bit_AVX512F)
|                  ^

...

| make: *** [cpuinfo.o] Error 1
| make: *** Waiting for unfinished jobs....

...

| WARNING: exit code 1 from a shell command.
| ERROR: oe_runmake failed
| ERROR: Function failed: do_compile (log file is located at /work/tmp/ram/proteus/tmp-uclibc/work/x86_64-nativesdk-oesdk-linux/nativesdk-libgcc-initial/5.3.0-r0/temp/log.do_compile.12613)
ERROR: Task 5 (virtual:nativesdk:/work/openembedded/meta/recipes-devtools/gcc/libgcc-initial_5.3.bb, do_compile) failed with exit code &apos;1&apos;
NOTE: Tasks Summary: Attempted 176 tasks of which 0 didn&apos;t need to be rerun and 1 failed.
No currently running tasks (176 of 181)

Summary: 1 task failed:
  virtual:nativesdk:/work/openembedded/meta/recipes-devtools/gcc/libgcc-initial_5.3.bb, do_compile
Summary: There were 2 ERROR messages shown, returning a non-zero exit code.

After some investigation I found that it is building not only gcc 5.3.0 which defined by GCCVERSION but also 4.8.4 version from my layer. And after that I print current and preferred versions of all recipes and saw strange thing:

$ bitbake nativesdk-libgcc-initial -s | grep gcc
gcc                                                 :4.8.4-r0                 :5.3.0-r0
gcc-cross-canadian-mipsel                           :4.8.4-r0                 :5.3.0-r0
gcc-cross-initial-mipsel                            :4.8.4-r0                 :5.3.0-r0
gcc-cross-mipsel                                    :4.8.4-r0                 :5.3.0-r0
gcc-crosssdk-initial-x86_64                         :4.8.4-r0                          
gcc-crosssdk-x86_64                                 :4.8.4-r0                          
gcc-runtime                                         :4.8.4-r0                 :5.3.0-r0
gcc-source-4.8.4                                    :4.8.4-r0                          
gcc-source-4.9.3                                    :4.9.3-r0                          
gcc-source-5.3.0                                    :5.3.0-r0                          
gccmakedep                                         1:1.0.3-r3                          
libgcc                                              :4.8.4-r0                 :5.3.0-r0
libgcc-initial                                      :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc                                       :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc-runtime                               :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc-sanitizers                            :4.8.4-r0                 :5.3.0-r0
nativesdk-libgcc                                    :4.8.4-r0                 :5.3.0-r0
nativesdk-libgcc-initial                            :4.8.4-r0                 :5.3.0-r0

Here we can see that not for all gcc packages preferred version defined correctly - for gcc-crosssdk-initial-x86_64 and gcc-crosssdk-x86_64 preferred version udefined.
I think this is bug because 

At first, when I define SDKMACHINE ?= &quot;i686&quot; I see

$ bitbake nativesdk-libgcc-initial -s | grep gcc
gcc                                                 :4.8.4-r0                 :5.3.0-r0
gcc-cross-canadian-mipsel                           :4.8.4-r0                 :5.3.0-r0
gcc-cross-initial-mipsel                            :4.8.4-r0                 :5.3.0-r0
gcc-cross-mipsel                                    :4.8.4-r0                 :5.3.0-r0
gcc-crosssdk-i686                                   :4.8.4-r0                 :5.3.0-r0
gcc-crosssdk-initial-i686                           :4.8.4-r0                 :5.3.0-r0
gcc-runtime                                         :4.8.4-r0                 :5.3.0-r0
gcc-source-4.8.4                                    :4.8.4-r0                          
gcc-source-4.9.3                                    :4.9.3-r0                          
gcc-source-5.3.0                                    :5.3.0-r0                          
gccmakedep                                         1:1.0.3-r3                          
libgcc                                              :4.8.4-r0                 :5.3.0-r0
libgcc-initial                                      :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc                                       :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc-runtime                               :4.8.4-r0                 :5.3.0-r0
nativesdk-gcc-sanitizers                            :4.8.4-r0                 :5.3.0-r0
nativesdk-libgcc                                    :4.8.4-r0                 :5.3.0-r0
nativesdk-libgcc-initial                            :4.8.4-r0                 :5.3.0-r0

and &apos;-c populate_sdk&apos; work fine

At second, when I decrease my layer priority to &quot;5&quot;, I see

$ bitbake nativesdk-libgcc-initial -s | grep gcc
gcc                                                 :5.3.0-r0                          
gcc-cross-canadian-mipsel                           :5.3.0-r0                          
gcc-cross-initial-mipsel                            :5.3.0-r0                          
gcc-cross-mipsel                                    :5.3.0-r0                          
gcc-crosssdk-initial-x86_64                         :5.3.0-r0                          
gcc-crosssdk-x86_64                                 :5.3.0-r0                          
gcc-runtime                                         :5.3.0-r0                          
gcc-source-4.8.4                                    :4.8.4-r0                          
gcc-source-4.9.3                                    :4.9.3-r0                          
gcc-source-5.3.0                                    :5.3.0-r0                          
gccmakedep                                         1:1.0.3-r3                          
libgcc                                              :5.3.0-r0                          
libgcc-initial                                      :5.3.0-r0                          
nativesdk-gcc                                       :5.3.0-r0                          
nativesdk-gcc-runtime                               :5.3.0-r0                          
nativesdk-gcc-sanitizers                            :5.3.0-r0                          
nativesdk-libgcc                                    :5.3.0-r0                          
nativesdk-libgcc-initial                            :5.3.0-r0                          

and &apos;-c populate_sdk&apos; work fine as well

So I think that it happens something wrong with GCCVERSION when SDKMACHINE is defined as &quot;x84_64&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58401</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-02-01 21:59:27 +0000</bug_when>
    <thetext>Which version of the base metadata are you using?

We did used to see problems with the PREFERRED_VERSION settings for gcc-crosssdk not working. This was one of the issues which the datastore reimplementation allowed us to fix but that wouldn&apos;t fix older branches.

The settings come from:

http://git.yoctoproject.org/cgit.cgi/poky/tree/meta/conf/distro/include/tcmode-default.inc

PREFERRED_VERSION_gcc-crosssdk-${SDK_ARCH} ?= &quot;${SDKGCCVERSION}&quot;
PREFERRED_VERSION_gcc-crosssdk-initial-${SDK_ARCH} ?= &quot;${SDKGCCVERSION}&quot;

however you could try setting these manually and seeing if that helps you work around the issue?

PREFERRED_VERSION_gcc-crosssdk-i686 ?= &quot;${SDKGCCVERSION}&quot;
PREFERRED_VERSION_gcc-crosssdk-initial-i686 ?= &quot;${SDKGCCVERSION}&quot;
PREFERRED_VERSION_gcc-crosssdk-x86_64 ?= &quot;${SDKGCCVERSION}&quot;
PREFERRED_VERSION_gcc-crosssdk-initial-x86_64 ?= &quot;${SDKGCCVERSION}&quot;

should do it.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>58415</commentid>
    <comment_count>2</comment_count>
    <who name="Maksim E. Kozlov">maksim.e.kozlov</who>
    <bug_when>2016-02-02 09:03:52 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Which version of the base metadata are you using?

I&apos;m using master branch from 
git://git.openembedded.org/openembedded-core repository, but I did this on the jethro branch as well... the same effect

&gt; 
&gt; We did used to see problems with the PREFERRED_VERSION settings for
&gt; gcc-crosssdk not working. This was one of the issues which the datastore
&gt; reimplementation allowed us to fix but that wouldn&apos;t fix older branches.
&gt; 
&gt; The settings come from:
&gt; 
&gt; http://git.yoctoproject.org/cgit.cgi/poky/tree/meta/conf/distro/include/
&gt; tcmode-default.inc
&gt; 
&gt; PREFERRED_VERSION_gcc-crosssdk-${SDK_ARCH} ?= &quot;${SDKGCCVERSION}&quot;
&gt; PREFERRED_VERSION_gcc-crosssdk-initial-${SDK_ARCH} ?= &quot;${SDKGCCVERSION}&quot;
&gt; 
&gt; however you could try setting these manually and seeing if that helps you
&gt; work around the issue?
&gt; 
&gt; PREFERRED_VERSION_gcc-crosssdk-i686 ?= &quot;${SDKGCCVERSION}&quot;
&gt; PREFERRED_VERSION_gcc-crosssdk-initial-i686 ?= &quot;${SDKGCCVERSION}&quot;
&gt; PREFERRED_VERSION_gcc-crosssdk-x86_64 ?= &quot;${SDKGCCVERSION}&quot;
&gt; PREFERRED_VERSION_gcc-crosssdk-initial-x86_64 ?= &quot;${SDKGCCVERSION}&quot;
&gt; 
&gt; should do it.
I tried to set these variables explicitly but with no effect

Since I&apos;m using git://git.openembedded.org/openembedded-core repository, I tried to check how it works on the master branch from git://git.yoctoproject.org/poky.git repo - the same wrong behavior

But when I switched to the jethro branch and tried again, I found that it works correctly

So this bug appears in &apos;master&apos; branches of both repositories and in the jethro branch from git://git.openembedded.org/openembedded-core repo, but doesn&apos;t appear in the jethro branch from git://git.yoctoproject.org/poky.git</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59441</commentid>
    <comment_count>3</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-02-24 17:43:05 +0000</bug_when>
    <thetext>I think I tracked down the issue illustrated by the following patch:

diff --git a/bitbake/lib/bb/providers.py b/bitbake/lib/bb/providers.py
index 68c8d59..ffa532c 100644
--- a/bitbake/lib/bb/providers.py
+++ b/bitbake/lib/bb/providers.py
@@ -121,11 +121,14 @@ def findPreferredProvider(pn, cfgData, dataCache, pkg_pn = None, item = None):
     preferred_file = None
     preferred_ver = None
 
-    localdata = data.createCopy(cfgData)
-    localdata.setVar(&apos;OVERRIDES&apos;, &quot;%s:pn-%s:%s&quot; % (data.getVar(&apos;OVERRIDES&apos;, localdata), pn, pn))
-    bb.data.update_data(localdata)
+    # pn can contain &apos;_&apos;, e.g. gcc-cross-x86_64 and an override cannot
+    # hence we do this manually rather than use OVERRIDES
+    preferred_v = cfgData.getVar(&quot;PREFERRED_VERSION_pn-%s&quot; % pn, True)
+    if not preferred_v:
+        preferred_v = cfgData.getVar(&quot;PREFERRED_VERSION_%s&quot; % pn, True)
+    if not preferred_v:
+        preferred_v = cfgData.getVar(&quot;PREFERRED_VERSION&quot;, True)
 
-    preferred_v = localdata.getVar(&apos;PREFERRED_VERSION&apos;, True)
     if preferred_v:
         m = re.match(&apos;(\d+:)*(.*)(_.*)*&apos;, preferred_v)
         if m:</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>59734</commentid>
    <comment_count>4</comment_count>
    <who name="Maksim E. Kozlov">maksim.e.kozlov</who>
    <bug_when>2016-03-04 14:17:38 +0000</bug_when>
    <thetext>It seems working. Thanks</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>60490</commentid>
    <comment_count>5</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2016-03-29 15:11:23 +0000</bug_when>
    <thetext>http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=030d920e2db45fa924f868638b906422c731101b</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>