| Flag | Description | Known Issues
|
| -O2 | Enables nearly all supported optimizations that do not involve a space-speed tradeoff. Does not enable loop unrolling or function inlining. As compared to -O, -O2 yields faster binaries at the cost of greater compilation time. | This flag is generally approved, and generally considered safe. It is the recommended default for Gentoo and probably most other distributions as well.
|
| -Os | Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size. Usually produces binaries smaller than those compiled with -O2, but also may slightly degrade performance (or increase performance due to more effective caching, reduced dependencies, and smaller code to link/execute). | This is a default flag for recent linux kernels.
|
| -O3 | Enables all optimizations specified by -O2 and also -finline-functions, -funswitch-loops and -fgcse-after-reload. The generated binary is most often bigger, and may be faster or slower. | Considered risky.
|
| -falign-functions=64 | Intended for Athlon-XP. Align to 64 byte command buffer on Athlon-XP. | Probably detrimental on processors with smaller cache sizes, such as the Athlon XP (512k L2 cache), Pentium 4 (256k/512k L2 cache). It might work better with newer Intel processors, such as the Pentium D 8xx (2x1 MB L2 cache) or the Pentium D 9xx (2x2 MB L2 cache).
|
| -fivopts | Enabled by default in gcc-4.3.1 (other versions not checked). | According to the media-libs/mesa-7.0.1 ebuild, this flag is buggy on gcc 4.2!
|
| -fomit-frame-pointer | Don't keep the frame pointer in a register for functions that don't need one. This avoids the instructions to save, set up and restore frame pointers; it also makes an extra register available in many functions. This flag is automatically enabled on optimization levels -O, -O2, -O3 and -Os on machines where it does not interfere with debugging. | This flag can harm debugging on some machines. According to http://www.gentoo.org/proj/en/qa/backtraces.xml, this flag avoids gdb from generating a backtrace reliably.
When used to compile Wine this flag breaks Wine's internal routines for protected apps and games, making these unusable as protection cannot be verified or bypassed, so its advised to do not use this flag to build Wine.
|
| -frename-registers | Allows processor registers to be used more flexibly. | Avoid using this flag at all. It's pointless on any architectures except for PPC and x86_64, and it's buggy even there. It slows down compiling noticeably too. There is some probability that the compiler will emit incorrect code on many packages. On amd64 gcc4 will take three times longer to compile (it'll halt on insn-attrtab.c).
|
| -fsee | Removes redundant instructions and rearranges those that remain optimally. | Buggy in GCC 4.2, can cause miscompilation. Less buggy in GCC 4.3, but still causes miscompilation, although more rarely. Compiling ffmpeg results in rapidly growing memory use. Was added to O3 but later removed.
|
| -ftracer | Strengthens other optimization passes by duplicating code. | Although they seem to compile fine, TeTeX and GTK+-2.6 misbehave weirdly at runtime. It also bloats code a bit.
|
| -ftree-loop-linear | "Perform linear loop transformations on tree." according to the gcc manual. | Unfortunately, this flag triggers a bug (#25211) in gcc version 4.1.x;in particular, when compiling the mesa package. Supposedly works in gcc versions <=4.0.3 or >=4.2.0.
|
| -ftree-parallelize-loops=n | Tries to split logic intensive loops into parallel operations. Intended for SMP systems. | New switch in GCC 4.3, often causes miscompilation when combined with vectorisation, in which dependencies may fail on depended packages compiled with both switches. Based on OpenMP.
|
| -ftree-vectorize | Tries to vectorize loops - make them use single instruction multiple data operations (GCC 4.x) | Most packages compile, but many produce segfaults : fontconfig, poppler, librsvg, dbus, alsa-lib, zlib, bjam (boost-build), particularly on Pentium 4s. Included in O3 as of GCC 4.3, safe as of 4.3.2.
|
| -fvect-cost-model | Performs analysis on code before vectorising, to ensure that it is worth vectorising. | New flag in GCC 4.3. Not dangerous to use, but can be counter-productive in that it prevents vectorisation that would be beneficial. Has no effect without -ftree-vectorize.
|
| -malign-double | Control whether GCC aligns "double", "long double", and "long long" variables on a two word boundary or a one word boundary | Unfortunately, code compiled with this flag might not work with code compiled without this flag, and the gcc manual does mention this. GNU tar compiled with this flag produced strange errors, and strace showed that stat function calls were returning corrupted values, versus GNU tar compiled without this flag which worked fine. A glibc compiled without this flag seems to be the culprit.
|
| -mfpmath=sse,387 | Attempt to use both SSE and i387 floating point math | Do not use this flag. The GCC register allocator will produce suboptimal floating point code since it doesn't grok two distinct register stacks yet. It's still marked experimental even in the latest GCC release (4.0.0 as of now). The only platform on which this MAY improve things is AMD64, and it's controversial even there. Causes strange bugs with GTK applications like gaim. See bug #74439 for an example.
|
| Flag | Category | Description | Known Issues
|
| -ffast-math | Approximation | Compromises floating point number accuracy slightly, for speed improvements. | Breaks IEEE or ISO norms; can trigger segfaults.
OpenOffice will segfault if KDE dialogs are used and kde-libs was compiled with -ffast-math. Apache 2 segfaults with GCC 4.1.1 and this flag. Breakages are also known to occur with postgresql, mpfr, gmp and nss_ldap. Automatically used within ffmpeg where it is safe. Appears to trigger a bug in sys-devel/m4-1.4.10.
|
| -mmmx -m3dnow -msse -msse2 -msse3 -mssse3 | Instruction sets | These switches enable or disable the use of instructions in the MMX, SSE, or 3DNow! extended instruction sets. | Automatically set by most -march flags. Only use these for compiling Mesa 3D drivers. Don't add to make.conf. Beneficial when no buit-in target automatically uses them.
|
| -fvisibility=hidden | Developer-only flag | | Do not use this flag in your C(XX)FLAGS! It requires source level changes from the developers or from the Gentoo maintainers, and it will sooner or later badly break your system. Won't compile: pango-1.8.1, perl-5.8.6-r4. Will compile but cause malfunctions later on: Many shared libraries (known example nvidia-glx-7167-r1). Used where safe by KDE, if USE contains kdehiddenvisibility.
|
| -D_FILE_OFFSET_BITS=64 | file size limit | On 32-bit systems, enables file sizes over 2Gigabytes. Useful for ftp of iso images works with lftp gftp (Opera probably) | Causes emerge of glibc-2.5 to fail - remove this flag before merging glibc and restore it afterwards. If you "succeed" to merge glibc with it, further breakage may occur, such as non-functional ALSA dmix device (all applications using it failing with "Inappropriate ioctl for device"). If you still think it's worth it, avoid mixing binaries compiled with and without this flag; because it changes the width of off_t, struct/stack bugs are possible. If you use it, recompile your whole system to be safe.
|
| -W | Verbose Compile Warnings | Enables more warnings when compiling | Although most packages work fine some die silently because they don't expect feedback.
|