简体   繁体   中英

cross compile PyZMQ using some arm-gcc

I want to cross compile PyZmq for an ARM-Cortex-A8 processor (AM335). But in my case the compiler is being run with flags which are not available for this processor.

I followed this and this post and taking into account that the mentioned patches are obsolete I'm currently following this procedure:

  • have target toolchain available (tested)
  • have ZeroMQ compiled with this toolchain (works)
  • have python3 libs and headers available for target
  • have Cython for Python3 installed (for host platform)
  • my setup.cfg looks like this:

     [global] have_sys_un_h = False [build_ext] libraries = python3.1 library_dirs = ../path/to/target/python/lib/python3.1 include_dirs = ../path/to/target/python/include/python3.1/ [bdist_egg] plat-name = linux-armv 

then I run:

git clone git://github.com/zeromq/pyzmq.git  pyzmq-arm-cortexa8/
cd pyzmq-git-arm-cortexa8/
export PATH=/path/to/compiler/bin:$PATH
export CC="arm-cortexa8-linux-gnueabihf-gcc"
export LDSHARED="arm-cortexa8-linux-gnueabihf-gcc -shared"
python3 ./setup.py configure --zmq=../zeromq-4.0.4-arm-cortexa8/
python3 ./setup.py build

But then building the Cython-generated files fails - the output is:

running build
running build_py
running build_ext
running configure
Warning: Skipping zmq version check
************************************************
skipping 'zmq/backend/cython/_device.c' Cython extension (up-to-date)
building 'zmq.backend.cython._device' extension
arm-cortexa8-linux-gnueabihf-gcc -Wno-unused-result -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../zeromq-4.0.4-arm-cortexa8/include -Izmq/utils -Izmq/backend/cython -Izmq/devices -I../platform-phyCORE-AM335x/sysroot-target/usr/include/python3.1/ -I/usr/include/python3.3m -c zmq/backend/cython/_device.c -o build/temp.linux-x86_64-3.3/zmq/backend/cython/_device.o
arm-cortexa8-linux-gnueabihf-gcc: error: unrecognized command line option '-fstack-protector-strong'
arm-cortexa8-linux-gnueabihf-gcc: error: unrecognized command line option '-m64'
arm-cortexa8-linux-gnueabihf-gcc: error: unrecognized argument in option '-mtune=generic'
arm-cortexa8-linux-gnueabihf-gcc: note: valid arguments to '-mtune=' are: arm1020e arm1020t arm1022e arm1026ej-s arm10e arm10tdmi arm1136j-s arm1136jf-s arm1156t2-s arm1156t2f-s arm1176jz-s arm1176jzf-s arm2 arm250 arm3 arm6 arm60 arm600 arm610 arm620 arm7 arm70 arm700 arm700i arm710 arm7100 arm710c arm710t arm720 arm720t arm740t arm7500 arm7500fe arm7d arm7di arm7dm arm7dmi arm7m arm7tdmi arm7tdmi-s arm8 arm810 arm9 arm920 arm920t arm922t arm926ej-s arm940t arm946e-s arm966e-s arm968e-s arm9e arm9tdmi cortex-a15 cortex-a5 cortex-a7 cortex-a8 cortex-a9 cortex-m0 cortex-m1 cortex-m3 cortex-m4 cortex-r4 cortex-r4f cortex-r5 ep9312 fa526 fa606te fa626 fa626te fa726te fmp626 generic-armv7-a iwmmxt iwmmxt2 mpcore mpcorenovfp native strongarm strongarm110 strongarm1100 strongarm1110 xscale
error: command 'arm-cortexa8-linux-gnueabihf-gcc' failed with exit status 1

(the same happens when I run python3 setupegg.py build bdist_egg but I don't need the egg anyway)

So for some reason the generated sources are being built with flags which would fit my host system but not the target compiler: -fstack-protector-strong , -m64 and -mtune=generic . I tried to modify CFLAGS and OPT like mentioned here but despite this doesn't work I doubt that's the most sophisticated approach anyway..

So the question is: what am I doing wrong here? How do I tell the setup process to provide the correct flags to the cross compiler? And why does this procedure seem to work with the Android-NDK which should produce the same errors?

Btw. I'm working on a recent Fedora 20 / x86_64

Alternative solution

Have you ever tried Buildroot ? It provides both Python3 and zmq.

git clone git://git.buildroot.net/buildroot
cd buildroot
make beaglebone_defconfig
make menuconfig

In menu select external toolchain, select Python3 and zmq under "Target Packages" and then python-pyzmq under Python3 external packages.

make 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM