I am trying to cross compile on python3.6 from x86_64-pc-linux-gnu to i686-pc-linux-gnu. I have prepared an sdk with bin-utils, kernel headers, glibc & gcc.
After downloading and extracting python 3.6. These are the steps that i followed to do cross-compilation
$ export PATH=/home/ach/x-tools/i686-pc-linux-gnu/bin:$PATH
$ PLAT=i686-pc-linux-gnu-
$ CC=${PLAT}gcc \
CXX=${PLAT}g++ \
AR=${PLAT}ar \
RANLIB=${PLAT}ranlib \
./configure \
--build=x86_64-pc-linux-gnu \
--host=x86_64-pc-linux-gnu \
--target=i686-pc-linux-gnu \
--prefix=$HOME/Downloads/cross-python/depsBuild/python \
--disable-ipv6 \
ac_cv_file__dev_ptmx=no \
ac_cv_file__dev_ptc=no \
ac_cv_have_long_long_format=yes \
--enable-shared
$ CROSSBASE=/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot \
CFLAGS="-I${CROSSBASE}/include -I{CROSSBASE}/usr/include" \
LDFLAGS="-L${CROSSBASE}/lib -L{CROSSBASE}/usr/lib" \
make \
HOSTPYTHON=$HOME/Downloads/cross-python/depsBuild/pythonhost/python \
BLDSHARED="${PLAT}gcc -shared" \
CROSS_COMPILE=$PLAT \
CROSS_COMPILE_TARGET=yes \
HOSTARCH=x86_64-linux-gnu \
BUILDARCH=x86_64-linux-gnu
ERROR
CC='i686-pc-linux-gnu-gcc' LDSHARED='i686-pc-linux-gnu-gcc -shared' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' _PYTHON_PROJECT_BASE=/home/ach/Downloads/cross-python/Python-3.6.9 _PYTHON_HOST_PLATFORM=linux-i686 PYTHONPATH=/home/ach/Downloads/cross-python/Python-3.6.9/build/lib.linux-i686-3.6:./Lib _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_m_linux_i386-linux-gnu python3.6 ./setup.py -q build
In file included from /home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/features.h:378:0,
from /home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/limits.h:25,
from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/limits.h:194,
from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/syslimits.h:7,
from /home/ach/x-tools/i686-pc-linux-gnu/lib/gcc/i686-pc-linux-gnu/7.4.0/include-fixed/limits.h:34,
from ./Include/Python.h:11,
from /home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.c:8:
/usr/include/i386-linux-gnu/sys/cdefs.h:467:49: error: missing binary operator before token "("
#if __GNUC_PREREQ (4,8) || __glibc_clang_prereq (3,5)
^
In file included from ./Include/Python.h:25:0,
from /home/ach/Downloads/cross-python/Python-3.6.9/Modules/_struct.c:8:
/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/stdio.h:48:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'typedef'
typedef struct _IO_FILE FILE;
^~~~~~~
/home/ach/x-tools/i686-pc-linux-gnu/i686-pc-linux-gnu/sysroot/usr/include/stdio.h:49:1: error: unknown type name '__END_NAMESPACE_STD'
__END_NAMESPACE_STD
^~~~~~~~~~~~~~~~~~~
During the cross compilations its referring to all the header files inside my cross-compiled platform. But all of a sudden its referring to /usr/include/i386-linux-gnu/sys/cdefs.h
and from there all the errors are started.
I have spend good amount of time googling about it..But unfortunately not much of the information present regarding the python3 cross-compiling. Any help is greatly appreciated.Happy to give more info if needed.
Thanks