lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


2012/12/1 Sam Roberts <vieuxtech@gmail.com>:
> On Fri, Nov 30, 2012 at 9:10 PM,  <meino.cramer@gmx.de> wrote:
>> What CFLAGS do you suggest in general?

If debugging is not necessary:
    -O2 -fomit-frame-pointer

If you *might* need to debug the code, but don't want to recompile in that case:
    -O2 -g

For hunting down bugs with gdb:
    -O0 -g

*IMPORTANT*: For any code that might end up in a shared library, add
-fPIC to your CFLAGS.

O3 performance is sometimes *worse* than O2 (because it often
increases code size), so IMHO it's better to stick with O2 when you
don't know specifically that O3 will benefit you.
It might be sensible to substitute Os for O2 when you are compiling
for embedded targets where memory is scarce.
Optimizations generally make debugging harder, but not impossible.
For some targets you might want to consider using -fpic instead of
-fPIC, but IMHO it's not worth distinguishing (similar to O2 vs. O3).

I don't think it pays off to really bother with optimizing desktop
applications (on the CFLAG- level) anyway- as long as you don't make
major mistakes (i.e. not allowing SSE for a fractal rendering app or
something like that) it'll make very little difference, *especially*
compared to the speed-boost your applications get from an SSD
(compared to disk-based storage).

--Wolfgang