I have an SoC with Cortex A9 ARMv7 architecture. I need to be able to run python scripts on a board with this SoC. So I need to cross-compile Python for this platform.
The SoC has ARMv7 architecture, so I've installed the arm-linux-gnueabihf cross-compiler for Ubuntu 20.04 running in the VirtualBox.
I am following this instruction:
First I've downloaded Python 2.7.1 sources and extracted it to the
/home/user/python/Python-2.7.1directory.Then I've downloaded the patch from the instruction I am following.
Then I've applied the patch:
patch -p1 < python-2.7.1-cross-compile.patchThen I've compiled some tools for host:
./configure make python Parser/pgen mv python hostpython mv Parser/pgen Parser/hostpgen make distcleanThen I've configured Python for cross-compilation:
readonly CROSS_COMPILER=arm-linux-gnueabihf CC=${CROSS_COMPILER}-gcc \ CXX=${CROSS_COMPILER}-g++ \ AR=${CROSS_COMPILER}-ar \ RANLIB=${CROSS_COMPILER}-ranlib \ ./configure \ --host=${CROSS_COMPILER} \ --target=${CROSS_COMPILER} \ --prefix=/pythonAnd then I finally cross-compile it:
make \ HOSTPYTHON=./hostpython \ HOSTPGEN=./Parser/hostpgen \ BLDSHARED="${CROSS_COMPILER}-gcc -shared" \ CROSS_COMPILE=${CROSS_COMPILER}- \ CROSS_COMPILE_TARGET=yesBut eventually I have got an
IndentationError:/usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tmpnam': /home/user/python/Python-2.7.1/./Modules/posixmodule.c:7346: warning: the use of `tmpnam_r' is dangerous, better use `mkstemp' /usr/lib/gcc-cross/arm-linux-gnueabihf/9/../../../../arm-linux-gnueabihf/bin/ld: libpython2.7.a(posixmodule.o): in function `posix_tempnam': /home/user/python/Python-2.7.1/./Modules/posixmodule.c:7301: warning: the use of `tempnam' is dangerous, better use `mkstemp' File "./setup.py", line 316 self.announce('*** WARNING: renaming "%s" since importing it' ^ IndentationError: expected an indented block make: *** [Makefile:425: sharedmods] Error 1
What I do wrong and how to solve this problem?
It seems that Python itself is successfully compiled and linked because after all this process I get the python file in the build directory:
$ file python
python: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, BuildID[sha1]=1a757bca3295fe062ffbee5cf2d791eb36861524, for GNU/Linux 3.2.0, with debug_info, not stripped