Actually I need to debug generated C code. To do this I have to
disable optimization option. ("-O2"). But I cannot find file where
these default options are specified.
How to get around it ?
My system:
uname -a
Linux 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:28:05 UTC 2010
x86_64 GNU/Linux
gcc --version
gcc (Ubuntu 4.4.3-4ubuntu5) 4.4.3
python --version
Python 2.6.5
cython --version
Cython version 0.11.2
> When I run
> python setup.py build_ext --inplace
> GCC is always invoked with default options
> gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -
> Wstrict-prototypes -fPIC
>
> Actually I need to debug generated C code. To do this I have to
> disable optimization option. ("-O2"). But I cannot find file where
> these default options are specified.
> How to get around it ?
You specify this with
Extension(..., extra_compile_args=["-O0"])
which should happen after (and override) the -O2 option. Setting the
CFLAGS environment variable may work as well, but I'm not sure.
- Robert
Those are the CFLAGS that were used by the build of your CPython
interpreter, it remembers them for later extension builds.
>> Actually I need to debug generated C code. To do this I have to
>> disable optimization option. ("-O2"). But I cannot find file where
>> these default options are specified.
>> How to get around it ?
>
> You specify this with
>
> Extension(..., extra_compile_args=["-O0"])
>
> which should happen after (and override) the -O2 option. Setting the
> CFLAGS environment variable may work as well, but I'm not sure.
Yes, CFLAGS are appended after the default configuration.
Stefan
> Any one tried compiling with -O3 instead of default -O2? I'm wondering
> if theire could be some performance gain from it.
I usually compile with -O3. Distutils uses whatever the Python library
was compiled with, and that's the default we use for Sage.
- Robert