I am cross-compiling python-2.7.13 and python-3.5.7 from scratch using the following configuration command line options to the ./configure binary:
CONFIG_SITE=config.site ./configure \
--host=arm-linux-gnueabi \
--build=x86_64-pc-linux-gnu \
CC=/toolchain/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc \
RANLIB=/toolchain/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi/bin/arm-linux-gnueabi-ranlib \
READELF=/toolchain/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi/bin/arm-linux-gnueabi-readelf \
--enable-shared --enable-ipv6 --without-cxx-main --without-doc-strings --with-system-ffi --with-pydebug
After the configuration is successful and the required Makefile is generated, when I am executing make to generate the python binary I am getting the following error:
/toolchain/arm/gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi/bin/arm-linux-gnueabi-gcc -Xlinker -export-dynamic -o python \
Modules/python.o \
-L. -lpython2.7 -lpthread -ldl -lpthread -lutil -lm
./libpython2.7.so: undefined reference to `minor'
./libpython2.7.so: undefined reference to `major'
./libpython2.7.so: undefined reference to `makedev'
collect2: error: ld returned 1 exit status
make: *** [python] Error 1
The toolchain which is being used for the cross-compilation is gcc-arm-8.2-2018.08-x86_64-arm-linux-gnueabi downloaded from here: https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-a/downloads/8-2-2018-08
On further inspection of the /Modules/posixmodule.o executable using readelf, I found that the functions major, minor and makedev are in the UNDEF category, hence encountering the linking error.
readelf -s posixmodule.o | grep -i "major"
409: 00004cb8 20 FUNC LOCAL DEFAULT 1 os_major_impl
410: 00004ccc 124 FUNC LOCAL DEFAULT 1 os_major
1288: 0000065c 1 OBJECT LOCAL DEFAULT 5 os_major__doc__
1629: 00000000 0 NOTYPE GLOBAL DEFAULT UND major
readelf -s posixmodule.o | grep -i "major"
409: 00004cb8 20 FUNC LOCAL DEFAULT 1 os_major_impl
410: 00004ccc 124 FUNC LOCAL DEFAULT 1 os_major
1288: 0000065c 1 OBJECT LOCAL DEFAULT 5 os_major__doc__
1629: 00000000 0 NOTYPE GLOBAL DEFAULT UND major
readelf -s posixmodule.o | grep -i "minor"
404: 00004c28 20 FUNC LOCAL DEFAULT 1 os_minor_impl
405: 00004c3c 124 FUNC LOCAL DEFAULT 1 os_minor
1287: 00000658 1 OBJECT LOCAL DEFAULT 5 os_minor__doc__
1628: 00000000 0 NOTYPE GLOBAL DEFAULT UND minor
Could anyone help to resolve these errors?
glibc 2.28 no longer defines 'major', 'minor' and 'makedev' in <sys/types.h>, those now require to include <sys/sysmacros.h>.
So if you really need these specific versions of python, you should add this #include to the source files where these functions are called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With