Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!1.eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed7.news.xs4all.nl!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.91.MISMATCH!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'warnings': 0.03; 'configure': 0.04; 'binary': 0.05; 'importerror:': 0.05; 'bash': 0.07; 'makefile': 0.07; 'reason,': 0.07; 'setup.py': 0.07; 'undefined': 0.07; 'x86': 0.07; 'defined,': 0.09; 'failed:': 0.09; 'grep': 0.09; 'libraries.': 0.09; "system's": 0.09; 'bug': 0.10; 'python': 0.11; 'python.': 0.11; 'importing': 0.15; 'interpreter': 0.15; 'skip:p 40': 0.15; 'echo': 0.16; 'elf': 0.16; 'googled': 0.16; 'mismatch:': 0.16; 'ncursesw': 0.16; 'pgen': 0.16; 'renaming': 0.16; 'sed': 0.16; "skip:' 60": 0.16; 'substituted': 0.16; 'debugging': 0.18; 'exists': 0.18; 'odd': 0.18; 'shell': 0.18; '>>>': 0.20; 'math': 0.20; 'extension': 0.20; 'handling': 0.20; 'fix': 0.21; 'machine': 0.21; 'trying': 0.22; 'saying': 0.22; '"",': 0.22; 'arm': 0.22; 'libraries': 0.22; 'parser': 0.22; 'strip': 0.22; 'bit': 0.23; 'normally': 0.23; 'references': 0.23; 'import': 0.24; '(most': 0.24; 'skip:b 30': 0.24; 'script': 0.25; 'install': 0.25; 'header :User-Agent:1': 0.26; 'idea': 0.26; 'error': 0.27; 'least': 0.27; "i'm": 0.29; 'skip:/ 40': 0.29; 'sleep': 0.29; 'random': 0.29; 'there.': 0.30; "skip:' 10": 0.30; 'version,': 0.31; 'supposed': 0.31; 'run': 0.32; 'skip:d 20': 0.32; 'gets': 0.32; 'skip:p 30': 0.32; 'compiled': 0.32; 'embedded': 0.32; 'getting': 0.33; 'symbol': 0.33; 'traceback': 0.33; 'file': 0.34; 'skip:- 10': 0.34; 'needed': 0.34; 'wrong': 0.35; 'could': 0.35; 'to:addr :python-list': 0.35; 'installing': 0.35; 'unicode': 0.35; 'skip:o 20': 0.35; 'according': 0.36; 'handle': 0.36; 'but': 0.36; 'hi,': 0.37; 'correctly': 0.37; "skip:' 20": 0.37; 'skip:- 20': 0.37; 'version': 0.38; 'building': 0.38; 'say': 0.38; 'skip:p 20': 0.38; 'doing': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'build': 0.40; 'sure': 0.40; 'some': 0.40; 'received:secureserver.net': 0.60; 'more': 0.62; 'information': 0.62; 'needing': 0.63; 'waiting': 0.63; 'received:phx3.secureserver.net': 0.67; 'received:prod.phx3.secureserver.net': 0.67; 'skip:$ 10': 0.67; 'carried': 0.72; '../configure': 0.84; './configure': 0.84; 'compiles': 0.84; 'processor.': 0.84; 'received:173.201': 0.91; 'received:173.201.192': 0.91; 'device.': 0.93; '***': 0.95; 'confirms': 0.95 Date: Mon, 29 Jun 2015 23:45:42 +0000 From: Andrew Robinson User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0 MIME-Version: 1.0 To: python-list@python.org Subject: Cross compiling C Python2.7.10 for arm on x86_64 linux box. Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 164 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1435646809 news.xs4all.nl 2941 [2001:888:2000:d::a6]:45649 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:93312 Hi, I'm Needing to get python 2.7.10 to cross compile correctly for an ARM embedded device. I'm very close, as it does build with warnings, but the result is defective and I'm not sure how to fix it. For some odd reason, the interpreter does run -- but I either get random segfaults -- or if I configure --without-pymalloc, I get messages when I import libraries saying that: ----------------------------------------------------------------------- Python 2.7.10 (default, Jun 29 2015, 23:00:31) [GCC 4.8.1 20130401 (prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import math Traceback (most recent call last): File "", line 1, in ImportError: /mnt/user/lib/python2.7/lib-dynload/math.so: undefined symbol: Py_InitModule4 [40857 refs] >>> ----------------------------------------------------------------------- That message suggests this might be an issue with 32/64 bit machine architectures confilicts according to information I googled on it. I am also seeing many warnings during build like the following which confirms some kind of build size mismatch: *** WARNING: renaming "pyexpat" since importing it failed: build/lib.linux-x86_64-2.7/pyexpat.so: wrong ELF class: ELFCLASS32 building '_elementtree' extension I think Py_InitModule4 is normally found in libpython2.7.so, as the symbol at least exists in the 32 and 64 bit complations of python that I have ; but when I check the cross compiled version, it's not there. So I think the python ./configure script might be getting confused about the size of the target it's trying to build as I am building it on a 64 bit x86 machine, and the target is a 32 bit arm processor. The following is what I am doing from bash shell (linux) to try and cross compile python. And idea of what I am doing wrong ? ----------------------------------------------------------------------- # A par# A parser generator and build system version of python are supposed to be # needed to run parts of the cross compilation; I do see python used in the # Makefile, but no references to a buid version of PGEN are defined, # so I don't know if PGEN gets used or not -- but I build it anyway... # As this is what receipies on the web say to do... make distclean ./configure make Parser/pgen python mv python python_for_build mv Parser/pgen Parser/pgen_for_build make distclean # fix setup.py to handle installing to the target system's fake install # directory found on the build system at $DEVICEROOT. if grep -q os.environ['DEVICEROOT'] ; then echo "Already patched" ; else sed -i setup.py 's%^[[:space:]]*math_libs = [].*$% if 'DEVICEROOT' in os.environ:\n lib_dirs += os.environ['DEVICEROOT']+'/mnt/user/lib\n lib_dirs += os.environ['DEVICEROOT']+'/mnt/user/include\n'% fi # We want utf-8, unicode terminal handling -- so make sure python compiles # with ncursesw substituted for curses. CURSESFLAGS=`pkg-config --cflags ncursesw` # Configure python to be built CFLAGS="${CFLAGS} ${CURSESFLAGS} -g3 -ggdb -gdwarf-4" ./configure --host=${CROSSTARGET} --build=i686-linux --enable-unicode --enable-shared --with-pydebug --prefix=/mnt/user --disable-ipv6 --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes PYTHON_FOR_BUILD=${PWD}/python_for_build # Fix a bug in the Makefile # The build version of python, ought not try to actually use the ARM libraries. sed -i -e 's%\([[:space:]]\)\(PYTHONPATH=$(DESTDIR)$(LIBDEST)\)%\1-\2%' Makefile echo "Fix the makefile if you can" sleep 10 make PYTHON_FOR_BUILD=${PWD}/python_for_build CROSS_COMPILE_TARGET=yes echo " Waiting to allow you to see error messages before installing " sleep 10 # Optionally, binary file stripping could be carried out on the python binary # Don't strip if you are doing debugging of python # strip --strip-unneeded python make install DESTDIR=${DEVICEROOT} PYTHON_FOR_BUILD=${PWD}/python_for_build PGEN_FOR_BUILD=${PWD}/pgen_for_build ser generator and build system version of python are supposed to be # needed to run parts of the cross compilation; I do see python used in the # Makefile, but no references to a buid version of PGEN are defined, # so I don't know if PGEN gets used or not -- but I build it anyway... # As this is what receipies on the web say to do... make distclean ./configure make Parser/pgen python mv python python_for_build mv Parser/pgen Parser/pgen_for_build make distclean # fix setup.py to handle installing to the target system's fake install # directory found on the build system at $DEVICEROOT. if grep -q os.environ['DEVICEROOT'] ; then echo "Already patched" ; else sed -i setup.py 's%^[[:space:]]*math_libs = [].*$% if 'DEVICEROOT' in os.environ:\n lib_dirs += os.environ['DEVICEROOT']+'/mnt/user/lib\n lib_dirs += os.environ['DEVICEROOT']+'/mnt/user/include\n'% fi # We want utf-8, unicode terminal handling -- so make sure python compiles # with ncursesw substituted for curses. CURSESFLAGS=`pkg-config --cflags ncursesw` # Configure python to be built CFLAGS="${CFLAGS} ${CURSESFLAGS} -g3 -ggdb -gdwarf-4" ./configure --host=${CROSSTARGET} --build=i686-linux --enable-unicode --enable-shared --with-pydebug --prefix=/mnt/user --disable-ipv6 --without-pymalloc ac_cv_file__dev_ptmx=yes ac_cv_file__dev_ptc=no ac_cv_have_long_long_format=yes PYTHON_FOR_BUILD=${PWD}/python_for_build # Fix a bug in the Makefile # The build version of python, ought not try to actually use the ARM libraries. sed -i -e 's%\([[:space:]]\)\(PYTHONPATH=$(DESTDIR)$(LIBDEST)\)%\1-\2%' Makefile echo "Fix the makefile if you can" sleep 10 make PYTHON_FOR_BUILD=${PWD}/python_for_build CROSS_COMPILE_TARGET=yes echo " Waiting to allow you to see error messages before installing " sleep 10 # Optionally, binary file stripping could be carried out on the python binary # Don't strip if you are doing debugging of python # strip --strip-unneeded python make install DESTDIR=${DEVICEROOT} PYTHON_FOR_BUILD=${PWD}/python_for_build PGEN_FOR_BUILD=${PWD}/pgen_for_build --------------------------------------------------------------------------