Bug 4718

Summary: python (built for powerpc) distutils has paths to host compiler toolchain
Product: buildroot Reporter: William Welch <bvwelch>
Component: OtherAssignee: Gustavo Zacarias <gustavo>
Status: RESOLVED WONTFIX    
Severity: minor CC: buildroot
Priority: P5    
Version: 2011.11   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description William Welch 2012-01-21 23:13:02 UTC
I suspect that I probably missed somewhere that I could have set this up, and I think I can workaround it using distutil.cfg, but I was surprised that when I ran "python setup.py build_ext --inplace", the errors were showing path names from the host where I ran buildroot, rather than my native powerpc toolchain.

Otherwise, buildroot is working great, thank you!
Comment 1 Thomas Petazzoni 2012-01-31 19:43:30 UTC
Python support for cross-compilation is quite horrible, so the problem may be quite hard to fix.

Could you give some steps to reproduce what you are seeing?
Comment 2 William Welch 2012-02-01 17:23:06 UTC
(In reply to comment #1)
> Python support for cross-compilation is quite horrible, so the problem may be
> quite hard to fix.
> 
> Could you give some steps to reproduce what you are seeing?

First, may I say that with some more research I found a workaround that is easy and works good.

But, here is what happens without the workaround:


python setup.py build_ext --inplace

running build_ext
building '_ncapio' extension
creating build
creating build/temp.linux-ppc-2.7

/home/bwelch/jan23a/buildroot-2011.11/output/host/usr/bin/powerpc-unknown-linux-uclibc-gcc -fno-strict-aliasing -pipe -Os -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c _ncapio.c -o build/temp.linux-ppc-2.7/_ncapio.o

unable to execute /home/bwelch/jan23a/buildroot-2011.11/output/host/usr/bin/powerpc-unknown-linux-uclibc-gcc: No such file or directory

error: command '/home/bwelch/jan23a/buildroot-2011.11/output/host/usr/bin/powerpc-unknown-linux-uclibc-gcc' failed with exit status 1

Note that instead of using my native powerpc 'gcc' and 'ld', somehow it tried to use pathnames from my host computer's cross-toolcain??

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

Now the simple workaround:

export CC='gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions'
export LDSHARED='ld -shared'

running build_ext
building '_ncapio' extension
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -fno-strict-aliasing -pipe -Os -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c _ncapio.c -o build/temp.linux-ppc-2.7/_ncapio.o

ld -shared build/temp.linux-ppc-2.7/_ncapio.o -L/usr/lib -lpython2.7 -o /root/ncapio/_ncapio.so


# works fine

thank you!  buildroot, python, native gcc all working great
Comment 3 Thomas Petazzoni 2013-05-26 10:54:21 UTC
Giving this bug to Gustavo, since he's been working on Python cross-compilation issues recently.
Comment 4 Gustavo Zacarias 2013-07-10 13:18:00 UTC
Target toolchain is deprecated so this bug is basically invalid/wontfix now.
Building modules in the target isn't supported nor encouraged.

*IF* you wanted to patch this for an older version of buildroot you'd need to tweak $(TARGET_DIR)/usr/lib/python2.7/config/Makefile and substitute the appropiate CC/CXX/AR/RANLIB/PYTHON_FOR_BUILD/PGEN_FOR_BUILD definitions to those matching the target.

But it's completely unsupported, it may or may not work and might need additional tweaking.