[SciPy-dev] Mac OS X and gcc 4.2

David M. Cooke cookedm at physics.mcmaster.ca
Wed Aug 16 19:37:17 CDT 2006


On Wed, Aug 16, 2006 at 03:34:49PM -0500, Chris Kees wrote:
> Good Afternoon,
> 
> I'm trying to port  a set  of  finite  element  tools and linear/ 
> nonlinear multilevel solvers  to the new  numpy and  scipy. I'm  
> having trouble  even building the trunk of numpy and  scipy on Mac  
> OS  X using a  recent build of gcc  (version 4.2.0 20060710) . Is   
> it  pointless  for  me  to even try using something besides apple's  
> gcc  3.3? I'm just getting simple unrecognized option errors, but I  
> don't  know how to modify the configuration to get rid  of  them or   
> ignore  them.  Could  anyone  give me some pointers  here?
> 
> Thanks,
> Chris
> 
> errors with gcc 4.2:
> 
> ...
> gcc: _configtest.c
> gcc: unrecognized option '-no-cpp-precomp'
> cc1: error: unrecognized command line option "-arch"
> cc1: error: unrecognized command line option "-arch"
> cc1: error: unrecognized command line option "-Wno-long-double"
> gcc: unrecognized option '-no-cpp-precomp'
> cc1: error: unrecognized command line option "-arch"
> cc1: error: unrecognized command line option "-arch"
> cc1: error: unrecognized command line option "-Wno-long-double"
> failure.
> removing: _configtest.c _configtest.o

Annoying, eh? The *easiest* way I've found to use a different compiler
that takes a different set of flags is to make a compiler wrapper
script, that deletes the flags your compiler won't recognize, and add
others you think you need. I've attached the one I use on my Mac.
Just set CC to it before building:

$ CC=gcc-wrapper python setup.py build

Otherwise, you'll find that you're running into the problem that Python
adds flags from its Makefile (kept at lib/python2.4/Config/Makefile)
that there is no way to override (BASECFLAGS and OPT --
see distutils.sysconfig). Setting CFLAGS only adds flags to the compiler
command.

Alternatively, look in numpy/distutils/ccompiler.py at the top. Edit
_new_init_posix() to override the 'OPT' and 'BASECFLAGS' config_var
(the one for 'OPT' is already there), and uncomment the line below
that function that sets distutils.sysconfig._init_posix to this new
routine.

-- 
|>|\/|<
/--------------------------------------------------------------------------\
|David M. Cooke                      http://arbutus.physics.mcmaster.ca/dmc/
|cookedm at physics.mcmaster.ca


More information about the Scipy-dev mailing list