Pip/easy_install ignoring ARCHFLAGS in SciPy insta

2019-02-24 12:44发布

I'm trying to compile SciPy for both 32-bit and 64-bit architectures, since some of the applications that use the library are only one arch or the other, following advice from a few SO questions. This command has worked for me in a similar build about two months ago, but now it seems that some of the compiled shared libraries are only targeting x86_64:

sudo ARCHFLAGS="-arch i386 -arch x86_64" pip install scipy

I've tried several versions of this command, including setting the environment variables before sudo, including -m32 -m64 in FFlags, using the OSX Command Line Tools, a full Xcode install, using clang instead of the LLVM that comes with OSX following the official SciPy install instructions, easy_install instead of pip and even ./configure'ing separately, etc., but I can't seem to get it to work. Oddly, some of the .so's are building with both architectures, but some are not:

dhcp-10-249-71-202:~ kastman$ file /Library/Python/2.7/site-packages/scipy/optimize/*.so
/Library/Python/2.7/site-packages/scipy/optimize/_cobyla.so:   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_lbfgsb.so:   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_minpack.so:  Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_nnls.so:     Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_slsqp.so:    Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so:    Mach-O universal binary with 2 architectures
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so (for architecture i386): Mach-O bundle i386
/Library/Python/2.7/site-packages/scipy/optimize/_zeros.so (for architecture x86_64):   Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/minpack2.so:  Mach-O 64-bit bundle x86_64
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so: Mach-O universal binary with 2 architectures
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so (for architecture i386):  Mach-O bundle i386
/Library/Python/2.7/site-packages/scipy/optimize/moduleTNC.so (for architecture x86_64):    Mach-O 64-bit bundle x86_64

Looking at the make log, it looks like the args are being passed successfully for both the libraries that seem to work and those that don't:

# Minpack doesn't build fat binaries
/usr/local/bin/gfortran -Wall -Wall -undefined dynamic_lookup -bundle build/temp.macosx-10.7-intel-2.7/build/src.macosx-10.7-intel-2.7/scipy/optimize/minpack2/minpack2module.o build/temp.macosx-10.7-intel-2.7/build/src.macosx-10.7-intel-2.7/fortranobject.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/minpack2/dcsrch.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/minpack2/dcstep.o -L/usr/local/gfortran/lib/gcc/x86_64-apple-darwin11/4.6.2 -Lbuild/temp.macosx-10.7-intel-2.7 -lgfortran -o build/lib.macosx-10.7-intel-2.7/scipy/optimize/minpack2.so
building 'scipy.optimize._slsqp' extension
compiling C sources
C compiler: clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe

#... but moduleTNC does.
llvm-gcc-4.2 -Wl,-F. -bundle -undefined dynamic_lookup -Wl,-F. -arch i386 -arch x86_64 build/temp.macosx-10.7-intel-2.7/scipy/optimize/tnc/moduleTNC.o build/temp.macosx-10.7-intel-2.7/scipy/optimize/tnc/tnc.o -Lbuild/temp.macosx-10.7-intel-2.7 -o build/lib.macosx-10.7-intel-2.7/scipy/optimize/moduleTNC.so
building 'scipy.optimize._cobyla' extension
compiling C sources
C compiler: clang -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arch x86_64 -pipe

Is it possible that the difference is the gfortran compiler I'm using? I used brew install gfortran which is supposed to be good according to the SciPy documentation. I would think the important line would be the C compiler: clang line, which appears to be nearly identical, including both -arch's.

The last most detailed build I've tried was:

sudo env ARCHFLAGS="-arch i386 -arch x86_64" ARCH="i386 x86_64" CC="clang" CXX="clang" FFLAGS="-ff2c -m32 -m64" pip install scipy

Does anyone have suggestions about how to further diagnose this?

(OSX 10.7, recent MacBookPro, compiling with gcc from the CLI tools and from Xcode)

1条回答
干净又极端
2楼-- · 2019-02-24 13:12

Pulling from source and building appears to correctly create fat binaries. I'm not sure if this is a bug that's already been fixed (I didn't see anything on the scipy dev list) or if it has to do with pip/easy_install, but here's what I did to get it to work:

git clone https://github.com/scipy/scipy.git; cd scipy
export ARCHFLAGS='-arch i386 -arch x86_64'
python setup.py config
python setup.py build
sudo python setup.py install

No special CC environment variables, gfortran was from brew install gfortran, and surprisingly it looks like gcc was llvm-gcc.

查看更多
登录 后发表回答