Useful Compiler Options

From MorphOS Library

Revision as of 14:37, 23 October 2010 by Krashan (talk | contribs) (Optimization options: Contents.)

Grzegorz Kraszewski


GCC compiler has hundreds of options. Some of them are irrelevant for typical usage, some of them are irrelevant to PowerPC architecture. This article presents a set of common option set used when compiling MorphOS programs. For detailed descriptions of all options see GCC manual.


Warning options

These options control warnings issued by compiler on some potentially dangerous language constructs. While some programmers complain on compiler being too picky, it is recommended to turn most of these options on. It can save hours of time wasted on debugging...

−Wall

−Wextra


Linker options

−noixemul

−s


Optimization options

−On, where n ranges from 0 to 3. The parameter is a global control of execution speed optimizer. Higher numbers make the optimizer more aggressive. −O2 seems to be the best for everyday use. −O3 turns on many optimizations which can significantly increase the executable size. Good programmer optimizes his algorithms in the first place, compiler optimizations can't fix design errors...

−Os, turns on executable size optimization, at a cost of execution speed. Not very useful for typical applications.