<?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>1948</bug_id>
          
          <creation_ts>2012-02-01 12:31:43 +0000</creation_ts>
          <short_desc>distutils builds are using &quot;cached&quot; environment from sstate-cache</short_desc>
          <delta_ts>2012-02-10 08:27:25 +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>Meta-yocto</product>
          <component>meta-yocto</component>
          <version>1.1.1</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</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>1.2 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Matthew McClintock">msm-oss</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>josh</cc>
    
    <cc>msm-oss</cc>
    
    <cc>nitin.a.kamble</cc>
    
    <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
    
    <cc>sgw</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>---</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>18447</commentid>
    <comment_count>0</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-01 12:31:43 +0000</bug_when>
    <thetext>Recipes that use distuils are pulling in some cached build steps/information from sstate-cache. 

Basically, let&apos;s say I build for BOARDA, then I delete that and reuse the sstate-cache for a BOARDB. The BOARDB link step will reuse the --sysroot from BOARDA instead of using the sysroot from BOARDB.

A problem recipe is python-pycairo. I was able to add the following patch to &quot;hack&quot; around the issue. I suspect a better fix is to add these exports to meta/classes/distutils.bbclass - or somehow delete wherever this bad information is cached and avoid packaging that information in sstate-cache in the first place.

diff --git a/meta/recipes-devtools/python/python-pycairo_1.8.10.bb b/meta/recipes-devtools/python/python-pycairo_1.8.10.bb
index b76724e..ee57978 100644
--- a/meta/recipes-devtools/python/python-pycairo_1.8.10.bb
+++ b/meta/recipes-devtools/python/python-pycairo_1.8.10.bb
@@ -6,7 +6,7 @@ LICENSE = &quot;LGPLv2.1 &amp; MPL-1&quot;
 LIC_FILES_CHKSUM = &quot;file://COPYING;md5=f2e071ab72978431b294a0d696327421&quot;
 # cairo &gt;= 1.8.8
 DEPENDS = &quot;cairo&quot;
-PR = &quot;r1&quot;
+PR = &quot;r2&quot;
 
 SRC_URI = &quot;http://cairographics.org/releases/py2cairo-${PV}.tar.gz&quot;
 
@@ -20,6 +20,10 @@ do_compile_prepend() {
 #fix the installation path of __init__.py
 #It was going in the sysroot instead of target install location
        sed -i -e &quot;s#dsy.get_python_lib()#&apos;${D}${PYTHON_SITEPACKAGES_DIR}&apos;#&quot; ${S}/setup.py
+
+# Append &quot;correct&quot; sysroot to linker step otherwise it&apos;s possible to use sysroot from
+# whatever sstate-cache was built against which would be wrong
+       export LDFLAGS=&quot;${LDFLAGS} ${TOOLCHAIN_OPTIONS}&quot;
 }</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18455</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2012-02-01 16:17:34 +0000</bug_when>
    <thetext>If no flags are passed to the linker it will use its builtin sysroot option which as you point out, can be incorrect in sstate builds. We cannot change the builtin values easily, we should however always ensure our linker command is being used. The question is why is $LD not being used? or $CCLD?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18456</commentid>
    <comment_count>2</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-01 16:29:33 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; If no flags are passed to the linker it will use its builtin sysroot option
&gt; which as you point out, can be incorrect in sstate builds. We cannot change the
&gt; builtin values easily, we should however always ensure our linker command is
&gt; being used. The question is why is $LD not being used? or $CCLD?

I tried:

export LD=${LD}

first with no luck.

-M</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18528</commentid>
    <comment_count>3</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-07 09:00:36 +0000</bug_when>
    <thetext>adding Nitin to see if he has any thoughts</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18529</commentid>
    <comment_count>4</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 09:36:27 +0000</bug_when>
    <thetext>I am seeing this in the run.do_compile

export LD=&quot;x86_64-poky-linux-ld --sysroot=/builddisk/build/build0/tmp/sysroots/qemux86-64&quot;
export LDFLAGS=&quot;-Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18530</commentid>
    <comment_count>5</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 09:41:53 +0000</bug_when>
    <thetext>and config.status inside python-pycairo has

LD=&apos;/usr/bin/ld -m elf_x86_64&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18531</commentid>
    <comment_count>6</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 10:20:45 +0000</bug_when>
    <thetext>Matthew,
 Does this work?

export LINK_CC=${LD}


PS: ignore the config.status comment, this file is a stale file in the source, and not part of the build process.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18532</commentid>
    <comment_count>7</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-07 13:15:58 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Matthew,
&gt;  Does this work?
&gt; 
&gt; export LINK_CC=${LD}
&gt; 
&gt; 
&gt; PS: ignore the config.status comment, this file is a stale file in the source,
&gt; and not part of the build process.

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index 79b962a..cdbcdd0 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -72,3 +72,5 @@ distutils_do_install() {
 }
 
 EXPORT_FUNCTIONS do_compile do_install
+
+export LINK_CC=${LD}

Still get the error below. LINK_CC or LD from the environment don&apos;t override the linker flags distutils uses.

| powerpc-fsl-linux-gcc -m32 -mhard-float -mcpu=e500mc --sysroot=/opt/yocto/cache-build/p4080ds/build_p4080ds_release/tmp/sysroots/p4080ds -shared -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -O2 -pipe -g -feliminate-unused-debug-types build/temp.linux-x86_64-2.6/src/cairomodule.o build/temp.linux-x86_64-2.6/src/context.o build/temp.linux-x86_64-2.6/src/font.o build/temp.linux-x86_64-2.6/src/matrix.o build/temp.linux-x86_64-2.6/src/path.o build/temp.linux-x86_64-2.6/src/pattern.o build/temp.linux-x86_64-2.6/src/surface.o -L/opt/yocto/cache-build/p4080ds/build_p4080ds_release/tmp/sysroots/p4080ds/usr/lib -lcairo -lpython2.6 -o build/lib.linux-x86_64-2.6/cairo/_cairo.so
| /local/home/mattsm/git/poky/build_p3041ds_release/tmp/sysroots/x86_64-linux/usr/bin/ppce500mc-fsl-linux/../../libexec/ppce500mc-fsl-linux/gcc/powerpc-fsl-linux/4.6.3/ld: cannot find crti.o: No such file or directory
| /local/home/mattsm/git/poky/build_p3041ds_release/tmp/sysroots/x86_64-linux/usr/bin/ppce500mc-fsl-linux/../../libexec/ppce500mc-fsl-linux/gcc/powerpc-fsl-linux/4.6.3/ld: cannot find crtbeginS.o: No such file or directory</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18533</commentid>
    <comment_count>8</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-07 13:17:07 +0000</bug_when>
    <thetext>The above example uses state-cache from the p4080ds machine, on a p3041ds machine. You can see the incorrect sysroot argument in the pasted text.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18534</commentid>
    <comment_count>9</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 13:26:11 +0000</bug_when>
    <thetext>Matthew, Is the gcc (path &amp; filename) and gcc parameters especially sysroot in the log correct ?

Looks like issue with $CC rather than $LD</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18535</commentid>
    <comment_count>10</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 13:32:17 +0000</bug_when>
    <thetext>Matthew,
Can you give definite steps for reproducing the issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18536</commentid>
    <comment_count>11</comment_count>
    <who name="Joshua Lock - Disabled">josh</who>
    <bug_when>2012-02-07 13:41:20 +0000</bug_when>
    <thetext>(In reply to comment #10)
&gt; Matthew,
&gt; Can you give definite steps for reproducing the issue?

Matthew provided these to me privately:

To reproduce you need to build something that uses distutil on one
machine and reuse the state cache on another machine or just change
the paths on the second build from sstate-cache.

$ git clone poky.git poky1
$ cd poky1
$ source oe-env-build
$ bitbake python-pycairo
$ cd ..
$ git clone poky.git poky2
$ cd poky2
$ source oe-env-build
$ cp -r ../../poky1/build/sstate-cache/ .
$ rm -rf ../../poky1
$ bitbake python-pycairo</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18537</commentid>
    <comment_count>12</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-07 15:46:56 +0000</bug_when>
    <thetext>I could not reproduce the issue following Joshua&apos;s steps. 
Matthew can you provide steps to reproduce the issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18539</commentid>
    <comment_count>13</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-07 16:45:52 +0000</bug_when>
    <thetext>(In reply to comment #9)
&gt; Matthew, Is the gcc (path &amp; filename) and gcc parameters especially sysroot in
&gt; the log correct ?
&gt; 
&gt; Looks like issue with $CC rather than $LD

Only for the linking step... the compile step uses the correct parameters. That&apos;s what&apos;s fishy here, just the compiler issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18548</commentid>
    <comment_count>14</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-08 11:47:45 +0000</bug_when>
    <thetext>This is what we are looking for to override for the distutils linker:

diff --git a/meta/classes/distutils.bbclass b/meta/classes/distutils.bbclass
index 79b962a..18ae805 100644
--- a/meta/classes/distutils.bbclass
+++ b/meta/classes/distutils.bbclass
@@ -72,3 +72,5 @@ distutils_do_install() {
 }
 
 EXPORT_FUNCTIONS do_compile do_install
+
+export LDSHARED=&quot;${CCLD} -shared&quot;

I will submit a patch if there are no further comments on using this to solve the linking sstate-cache problem</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18549</commentid>
    <comment_count>15</comment_count>
    <who name="Nitin Kamble">nitin.a.kamble</who>
    <bug_when>2012-02-08 12:26:58 +0000</bug_when>
    <thetext>Matthew,
  Can you explain how the LDSHARED var is getting used in the code? 
I did not find anything obvious in the waf code.

Nitin</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18550</commentid>
    <comment_count>16</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-08 12:29:20 +0000</bug_when>
    <thetext>(In reply to comment #15)
&gt; Matthew,
&gt;   Can you explain how the LDSHARED var is getting used in the code? 
&gt; I did not find anything obvious in the waf code.
&gt; 
&gt; Nitin

See:

tmp/work/x86_64-linux/python-native-2.6.6-r2.4/Python-2.6.6/Lib/distutils/sysconfig.py

It&apos;s importing LDSHARED from the environment to use as the linker.

-M</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18551</commentid>
    <comment_count>17</comment_count>
    <who name="Matthew McClintock">msm-oss</who>
    <bug_when>2012-02-08 13:07:06 +0000</bug_when>
    <thetext>Patch sent to ML for review</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18582</commentid>
    <comment_count>18</comment_count>
    <who name="Joshua Lock - Disabled">josh</who>
    <bug_when>2012-02-09 23:26:05 +0000</bug_when>
    <thetext>I can reproduce this issue with the steps in comment 11. With the submitted patch applied to the edison branch I can no longer reproduce the issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>18587</commentid>
    <comment_count>19</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2012-02-10 08:27:25 +0000</bug_when>
    <thetext>Fixed in master with http://git.yoctoproject.org/cgit.cgi/poky/commit/?id=433f2ead93438e0d4d59b24ed3d6097dd658972f, thanks Matthew!</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>