How to compile missing extensions modules when cross compiling Python 3.5.2 for ARM on Linux
<p>When cross compiling Python for ARM many of the extension modules are not build. How do I build the missing extension modules, mainly math, select, sockets, while cross compiling Python 3.5.2 for ARM on Linux?  However, when compiling for the native platform the extension modules are properly build.</p>

<p>These were my cross-compilation steps:</p>

<pre><code>CONFIG_SITE=config.site CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ AR=arm-linux-gnueabihf-ar RANLIB=arm-linux-gnueabihf-ranlib READELF=arm-linux-gnueabihf-readelf ./configure --enable-shared --host=arm-linux --build=x86_64-linux-gnu --disable-ipv6 --prefix=/opt/python3
make
sudo PATH=/home/benny/workspace/projects/webshield/src/dntl_ws/sw/toolchain/gcc-linaro-4.9-2016.02-x86_64_arm-linux-gnueabihf/bin:$PATH make install
</code></pre>

<p>These are the modules built when cross-compiled:</p>

<pre><code>_ctypes_test 
cmath 
_json 
_testcapi 
_testbuffer 
_testimportmultiple 
_testmultiphase 
_lsprof 
_opcode 
parser 
mmap 
audioop 
_crypt 
_csv 
termios 
resource 
nis 
_multibytecodec 
_codecs_kr 
_codecs_jp 
_codecs_cn 
_codecs_tw 
_codecs_hk 
_codecs_iso2022 
_decimal 
_multiprocessing 
ossaudiodev 
xxlimited 
_ctypes 
</code></pre>

<p>These are the compilation steps on an x86 machine:</p>

<pre><code>CONFIG_SITE=config.site ./configure --enable-shared --disable-ipv6 --prefix=/opt/python3
make
sudo make install
</code></pre>

<p>These are the modules built when natively compiled:</p>

<pre><code>_struct 
_ctypes_test 
array 
cmath 
math 
_datetime 
_random 
_bisect 
_heapq 
_pickle 
_json 
_testcapi 
_testbuffer 
_testimportmultiple 
_testmultiphase 
_lsprof 
unicodedata 
_opcode 
fcntl 
grp 
spwd 
select 
parser 
mmap 
syslog 
audioop 
readline 
_crypt 
_csv 
_posixsubprocess 
_socket 
_sha256 
_sha512 
_md5 
_sha1 
termios 
resource 
nis 
binascii 
pyexpat 
_elementtree 
_multibytecodec 
_codecs_kr 
_codecs_jp 
_codecs_cn 
_codecs_tw 
_codecs_hk 
_codecs_iso2022 
_decimal 
_multiprocessing 
ossaudiodev 
xxlimited 
_ctypes 
</code></pre>

<p>I also tried building for ARM natively on an ARM machine and the extensions were build successfully.</p>

<p>The tool chain used for cross compilation is:</p>

<pre><code>gcc version 4.9.4 20151028 (prerelease) (Linaro GCC 4.9-2016.02) 
</code></pre>

<p>My host machine is:</p>

<pre><code>Ubuntu 16.04.1 LTS 
Linux whachamacallit 4.4.0-42-generic #62-Ubuntu SMP Fri Oct 7 23:11:45 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
</code></pre>

<h2>Root Cause ( Courtesy: Xavier de Gaye)</h2>

<blockquote>
  <p>There was already a native python3.5 (from the Ubuntu repository) is the PATH. So the problem is that setup.py in build_extensions() does not build the extensions that have been already built statically into this native Ubuntu interpreter.
  <a href="http://bugs.python.org/issue28444#msg278717" rel="nofollow">http://bugs.python.org/issue28444#msg278717</a></p>
</blockquote>

<h2>Temporary Solution</h2>

<blockquote>
  <p>A patch has been submitted at <a href="http://bugs.python.org/issue28444" rel="nofollow">http://bugs.python.org/issue28444</a> and is working successfully.</p>
</blockquote>

python python-3.x arm cross-compiling embedded-linux