<?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>7873</bug_id>
          
          <creation_ts>2015-06-10 21:40:17 +0000</creation_ts>
          <short_desc>python3-ctypes fails to cross compile</short_desc>
          <delta_ts>2015-06-24 15:25:04 +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>devtools / tool chain</component>
          <version>1.8</version>
          <rep_platform>All</rep_platform>
          <op_sys>arm</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>1.9 M2</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Peter Bergin">petan679</reporter>
          <assigned_to name="Alejandro Hernandez">alejandro.hernandez</assigned_to>
          <cc>benjamin.esquivel</cc>
    
    <cc>cristina-danielax.agurida</cc>
    
    <cc>jonas.goransson</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>ross.burton</cc>
          
          <qa_contact name="Cristina Agurida">cristina-danielax.agurida</qa_contact>
          <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>51623</commentid>
    <comment_count>0</comment_count>
      <attachid>2543</attachid>
    <who name="Peter Bergin">petan679</who>
    <bug_when>2015-06-10 21:40:17 +0000</bug_when>
    <thetext>Created attachment 2543
patch to fix reconfigure issue in _ctypes

There is a regression when building python3-ctypes. It worked fine in daisy but in fido and master it is broken. The symptom is that the library for _ctypes in missing in the rpm and on target.

When python3-ctypes is built with the recipes in fido do_configure fails with the printout in do_configure. The build goes on but the _ctypes module is not built.

DEBUG: Executing shell function do_configure
autoreconf: &apos;configure.ac&apos; or &apos;configure.in&apos; is required
NOTE: _ctypes failed to autoreconf


The cause of this error is an error with a path in the recipe for python3. With the attached patch that is backported from master the configure step works.

The next stop for the build is in the compile step. When trying to compile _ctypes the file setup.py does not take care of the configure parameter --with-system-ffi. This is because in setup.py the CONFIG_ARGS is taken from sysconfig lib for the host machine.

In some way when building for a x86 target on a x86_64 host the compilation works and the _ctypes library is present in the rpm. But when building for arm on a x86_64 the library for _ctype is not in the rpm.

To reproduce this issue in fido:

&gt; Setup a build for beaglebone
&gt; Apply the attached patch to poky
&gt; bitbake python3-ctypes
&gt; look in the do_compile log for failure building ctypes extension

I am currently using this with Freescla community BSP and my main problem is ctypes. But with this example building for Beaglebone no extension at all seems to be built.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51626</commentid>
    <comment_count>1</comment_count>
    <who name="Peter Bergin">petan679</who>
    <bug_when>2015-06-11 07:54:34 +0000</bug_when>
    <thetext>More information collected about this and it is regarding the PYTHONPATH when building.

When buildng in Daisy (working) PYTHONPATH is set to:

&apos;PYTHONPATH&apos;: &apos;/work/yocto/qep/qep-media-cgt_build/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/python3/3.3.3-r0.0/Python-3.3.3/build/lib.linux-arm-3.3:./Lib:./Lib/plat-linux&apos;

When building in fido (not working) PYTHONPATH is empty:

&apos;PYTHONPATH&apos;: &apos;&apos;

Importing sysconfigdata in fido case will take the host one and in daisy case will take the target one.

How should this work?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51630</commentid>
    <comment_count>2</comment_count>
    <who name="Peter Bergin">petan679</who>
    <bug_when>2015-06-11 08:46:02 +0000</bug_when>
    <thetext>From tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/python3/3.3.3-r1.0/build/Makefile:

PYTHON_FOR_BUILD=_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(CROSSPYTHONPATH) python3.3

It seems that CROSSPYTHONPATH shall be passed in as PYTHONPATH but in my case this one is empty when executing in the Makefile.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51643</commentid>
    <comment_count>3</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2015-06-11 14:33:37 +0000</bug_when>
    <thetext>FWIW, this works in master for me.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51655</commentid>
    <comment_count>4</comment_count>
    <who name="Peter Bergin">petan679</who>
    <bug_when>2015-06-11 18:04:08 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; FWIW, this works in master for me.

Which MACHINE are you building against?

With &apos;works&apos;, do you mean that you get your _ctype.so file in your RPM?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51706</commentid>
    <comment_count>5</comment_count>
    <who name="Jonas Göransson">jonas.goransson</who>
    <bug_when>2015-06-15 20:14:11 +0000</bug_when>
    <thetext>The recipe python3_3.3.3.bb applies the patch python3-use-CROSSPYTHONPATH-for-PYTHON_FOR_BUILD.patch:

   -	PYTHON_FOR_BUILD=&apos;_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(shell test -f pybuilddir.txt &amp;&amp; echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR) &apos;$interp
   +	PYTHON_FOR_BUILD=&apos;_PYTHON_PROJECT_BASE=$(abs_builddir) _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) PYTHONPATH=$(CROSSPYTHONPATH) &apos;$interp

This results in the generated python Makefile being dependent on CROSSPYTHONPATH being defined in order to work properly during crosscompilation. Adding the following CROSSPYTHONPATH export to a .bbappend file makes ctypes build successfully without any warnings.

   export CROSSPYTHONPATH = &quot;${B}/build/lib.linux-arm-${PYTHON_MAJMIN}:${S}/Lib:${S}/Lib/plat-linux&quot;

The CROSSPYTHONPATH is the resolved version of the original &quot;$(shell test -f pybuilddir.txt &amp;&amp; echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib:$(srcdir)/Lib/$(PLATDIR)&quot;.

Now setup.py loads the correct sysconfig target specific dicitionary _sysconfigdata.py found in &quot;${B}/build/lib.linux-arm-${PYTHON_MAJMIN}&quot;. When CROSSPYTHONPATH is missing it uses the native (x86_64) python sysconfig instead and on my platform fails to build ctypes for arm.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51742</commentid>
    <comment_count>6</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-06-16 21:58:49 +0000</bug_when>
    <thetext>I can confirm ctypes fails to compile on arm, hence ctypes*.so is not on the final rpm or target, I will send a patch soon to fix this for all archs on fido and master</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51883</commentid>
    <comment_count>7</comment_count>
    <who name="Alejandro Hernandez">alejandro.hernandez</who>
    <bug_when>2015-06-23 15:50:35 +0000</bug_when>
    <thetext>Fixed here:

http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=fbed86a87064783be376179b3627f55612cd6188</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51906</commentid>
    <comment_count>8</comment_count>
    <who name="Cristina Agurida">cristina-danielax.agurida</who>
    <bug_when>2015-06-24 15:25:04 +0000</bug_when>
    <thetext>Verified on master: 8ef99a00dc75c6eed87aa1bc1528614a2a27eddf</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>2543</attachid>
            <date>2015-06-10 21:40:17 +0000</date>
            <delta_ts>2015-06-10 21:40:17 +0000</delta_ts>
            <desc>patch to fix reconfigure issue in _ctypes</desc>
            <filename>python3_ctypes_reconf.patch</filename>
            <type>text/plain</type>
            <size>690</size>
            <attacher name="Peter Bergin">petan679</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL21ldGEvcmVjaXBlcy1kZXZ0b29scy9weXRob24vcHl0aG9uM18zLjMuMy5i
YiBiL21ldGEvcmVjaXBlcy1kZXZ0b29scy9weXRob24vcHl0aG9uM18zLjMuMy5iYgppbmRleCA2
MTQ3NDA4Li45MTYyYWQ3IDEwMDY0NAotLS0gYS9tZXRhL3JlY2lwZXMtZGV2dG9vbHMvcHl0aG9u
L3B5dGhvbjNfMy4zLjMuYmIKKysrIGIvbWV0YS9yZWNpcGVzLWRldnRvb2xzL3B5dGhvbi9weXRo
b24zXzMuMy4zLmJiCkBAIC03NSw5ICs3NSw5IEBAIGV4cG9ydCBfUFlUSE9OX1BST0pFQ1RfU1JD
ID0gIiR7U30iCiAjIE5vIGN0eXBlcyBvcHRpb24gZm9yIHB5dGhvbiAzCiBQWVRIT05MU0JPUFRT
ID0gIiIKIAotZG9fY29uZmlndXJlX3ByZXBlbmQoKSB7Citkb19jb25maWd1cmVfYXBwZW5kKCkg
ewogCXJtIC1mICR7U30vTWFrZWZpbGUub3JpZwotCWF1dG9yZWNvbmYgLVdjcm9zcyAtLXZlcmJv
c2UgLS1pbnN0YWxsIC0tZm9yY2UgLS1leGNsdWRlPWF1dG9wb2ludCBNb2R1bGVzL19jdHlwZXMv
bGliZmZpIHx8IGJibm90ZSAiX2N0eXBlcyBmYWlsZWQgdG8gYXV0b3JlY29uZiIKKwlhdXRvcmVj
b25mIC1XY3Jvc3MgLS12ZXJib3NlIC0taW5zdGFsbCAtLWZvcmNlIC0tZXhjbHVkZT1hdXRvcG9p
bnQgLi4vUHl0aG9uLSR7UFZ9L01vZHVsZXMvX2N0eXBlcy9saWJmZmkKIH0KIAogZG9fY29tcGls
ZSgpIHsK
</data>

          </attachment>
      

    </bug>

</bugzilla>