[Numpy-discussion] Is numpy ignoring CFLAGS?

David Cournapeau cournape@gmail....
Mon Jun 28 05:28:11 CDT 2010


On Mon, Jun 28, 2010 at 6:56 PM, Dr. David Kirkby
<david.kirkby@onetel.net> wrote:
> On 06/28/10 09:38 AM, Dag Sverre Seljebotn wrote:
>> Dr. David Kirkby wrote:
>>> On some 64-bit platforms, which include, but is not limited to:
>>>
>>>    * Some version of OS X (I don't know what versions or processors)
>>>    * Solaris on SPARC processors.
>>>    * Solaris on x86 processors.
>>>    * OpenSolaris on SPARC processors.
>>>    * OpenSolaris on x86 processors.
>>>    * HP-UX on PA-RISC processors.
>>>
>>> the default is to build 32-bit objects, but 64-bit objects can be created if
>>> needed. This is usually done via adding the -m64 flag when compiling with GCC or
>>> SunStudio, though the flag will be different with HP's compiler.
>>>
>>> Numpy is used as part of Sage, but it would appear that adding -m64 to CFLAGS
>>> will not work. A comment in the script used to build numpy shows:
>>>
>> First: Is Python built using -m64? If not, is there a reason that NumPy
>> in 64 bit and load it into 32 bit Python work? If Python is built with
>> -m64 I'd expect NumPy to pick it up automatically as it queries Python
>> for the build flags to use...
>
> Yes, Python is built 64-bit, using the -m64 option.
>
>>> # numpy's distutils is buggy and runs a conftest without
>>> # taking CFLAGS into account. With 64 bit OSX this results
>>> # in *boom*
>>>
>>> it then goes on to copy a file called gcc_fake, which is basically a script
>>> which gets renamed to gcc, but includes the -m64 flag.
>>>
>>> We are using numpy-1.3.0.
>>>
>>> Is this a known bug? If not, can I submit it to a bug database? Better still,
>>> does anyone have a patch to resolve it - I hate the idea of making
>>>
>> Until somebody who really knows an answer chimes in;
>>
>> AFAIK this is a "feature" in distutils itself, so it affects most Python
>> software. (Setting CFLAGS overwrites the necesarry CFLAGS settings, like
>> -fPIC and -fno-strict-aliasing, that is queried from Python). Try
>> setting "OPT" instead?
>>
>> Dag Sverre
>
> OPT has -m64 in it.
>
> This is the bit that shows how Python is built on Solaris (uname=SunOS). SAGE64
> will be set to "yes" for a 64-bit build.
>
> OPT="-g -O3 -m64 -Wall -Wstrict-prototypes"; export OPT
> ./configure $EXTRAFLAGS --prefix="$SAGE_LOCAL"  \
> --enable-unicode=ucs4 --with-gcc="gcc -m64"
>
>
> Many other parts of Sage seem to inherit the flags ok from Python, but not numpy.

Are you saying that OPT is not taken into account ? It seems to work
for me, e.g.

OPT="-m64" python setup.py build_ext

does put -m64 somewhere in CFLAGS. When using numpy.distutils, CFLAGS
should never be overriden unless you are ready to set up the whole set
of options manually. By default, CFLAGS is the concatenation of
BASECFLAGS, OPT and CCSHARED (in that order), and only OPT should be
tweaked in general.

David


More information about the NumPy-Discussion mailing list