[Numpy-discussion] Compiler options for mingw?

David Cournapeau david@ar.media.kyoto-u.ac...
Sun Nov 30 00:02:20 CST 2008


Zachary Pincus wrote:
> Regarding the windows binary installer, it appears that it selects the  
> optimized/unoptimized binary at *install time*, which causes  
> complications for further bundling of numpy with e.g. py2exe for use  
> on other machines. (E.g. my dev machine has SSE3, and it appears that  
> SSE3-optimized binaries get installed on it, which then causes  
> crashing when I bundle up a numpy script with py2exe ad run it on an  
> older box.) Is this in fact the case? 

Yes

> If so, is there any easy way to  
> force the installer to  just use the basic unoptimized configuration?  

No at the moment, but you can easily decompress the .exe content to get
the internal .exe (which are straight installers built by python
setup.py setup.py bdist_wininst). It should be possible to force an
architecture at install time using a command line option, but I don't
have the time ATM to support this.

If you are willing to add the option, you should add the option to the
template .nsi file:

http://projects.scipy.org/scipy/numpy/browser/trunk/tools/win32build/nsis_scripts/numpy-superinstaller.nsi.in

The documentation is on nsis webpage:

http://nsis.sourceforge.net/Main_Page

> On the other hand, if I'm using a SSE-free BLAS/LAPACK or non at all,  
> there'll be no SSE optimization done? I understand that gcc4, and thus  
> mingw derived from that version, will automatically try to use sse  
> instructions where possible if not specifically disabled, which is  
> what induced my original question. 

First, mingw uses gcc3, unless you use a custom built or alpha release.
Also, I am pretty sure that by default, gcc does NOT use any SSE
optimization. You have to request it.

> So, to be certain that gcc isn't  
> introducing sse instructions under the covers, I would still like to  
> know if there's a way to pass compiler flags to the build stage of  
> numpy. On UNIX, CFLAGS seems to do the trick, but on windows with  
> mingw the flags don't seem to be recognized... (E.g. setting CFLAGS to  
> '-mfoo' causes an invalid option error on OS X, but not with windows.)

This may be due to the 'shell' in windows, I don't know. Generally,
using CFLAGS is not reliable with numpy.distutils. But again, in numpy
trunk, no arch specific flag is added by numpy.distutils anymore, so you
should not need it.

David


More information about the Numpy-discussion mailing list