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 "<stdin>", line 1, in <module>
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

--------------------------------------------------------------------------




--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to