[Numpy-discussion] building 32 bit numpy on 64 bit linux
david.jones74 at gmail.com
Fri Dec 13 07:50:31 EST 2013
On 12/12/13 16:35, Julian Taylor wrote:
> On 12.12.2013 20:40, David Jones wrote:
>> On 12/12/13 15:54, Julian Taylor wrote:
>>> On 12.12.2013 19:58, David Jones wrote:
>>>> I'm trying to compile 32-bit numpy on a 64 bit Centos 6 system, but fails with the message:
>>>> "Broken toolchain: cannot link a simple C program"
>>> this might work:
>>> CC="gcc -m32" LDSHARED="gcc -m32" FF="gfortran -m32" linux32 python
>>> setup.py build
>> That didn't work. It says it can't find executable "gcc -m32". I tried
>> changing ccompiler.py, per the stackoverflow post. I got further that
>> time, but it fails with the message:
> weird it works for me with libpython2.7-dev:i386 installed on amd64
> Ubuntu 13.10 (multiarch is friggin great :D)
> But I had to add an additional LDFLAGS="-m32 -shared"
> CC="gcc -m32" LDSHARED="gcc -m32 -shared" LDFLAGS="-m32 -shared" linux32
> python setup.py build
> you should be able to work around this error message by writing small
> wrapper scripts for the compiler:
> cat << EOF > gcc-32
> gcc -m32 "$@"
> CC=gcc-32 ....
I actually didn't expect it to work. It just seemed too simple. So, I'm
surprised it worked for you. First off, are we using the same version of
I'm using Python 2.7.5, built with the following options:
CFLAGS="-g -O2 -m32" LDFLAGS="-m32" ./configure --enable-unicode=ucs4
--enable-shared --prefix=/opt/python/ia32 --with-valgrind
I'm building Numpy 1.8.0.
I'll try the wrapper method. It seems that distutils isn't always
passing the build options to the compiler and linker, so spoofing gcc
and gfortran may work.
It appears that numpy.distutils doesn't actually apply the linker flags.
It never calls the link_executable function, except indirectly through
it's reimplementation of the distutils config module. Moreover, the
config module doesn't expose the necessary arguments of link_executable
to set the build flags.
I want to look more into the code to see exactly what's happening. It
looks like the distutils config module and command package could use a
lot of work. It makes sense to pass in all the build options as
arguments to setup.py, rather than using environment variable. The
compiler modules support this, but they're never getting that
information from the config module. Of course, the may have been fixed
in Python 3. I don't know.
From what I can tell, distutils uses 3 methods to determine the build
1 - What version is of Python is being used? 32 bit or 64 bit?
2 - What's the architecture of the system? i.e. via uname -r.
3 - Environment variables.
Unfortunately the behavior is inconsistent and poorly documented.
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
More information about the NumPy-Discussion