Jump to content

Useful GCC compiler flags

From My Second Brain
Flag What it does
-O2 Turn on all optional optimisations except or loop unrolling, function inlining, and strict aliasing optimizations
-pipe Speeds up compilation (has no effect on outputted file). Tells the compiler to use pipes rather than temporary files
-Wall Enable all compiler warnings (helps to spot potentially troublesome code)
-Wextra Print extra warning messages, specifically: A pointer is compared against integer zero with < , <= , > , or >= . (C++ only) An enumerator and a non-enumerator both appear in a conditional expression. (C++ only) Ambiguous virtual bases
-m16 Generate 16-bit code
-ffreestanding Only use those features available in the freestanding environment
-nostdlib Don't include the standard library
-masm=intel Use Intel syntax for inline assembly rather than AT&T syntax (does this work?)
-fno-pic Tells the compiler to not generate position independent code
-mno-sse Floating point arguments to be passed onto the stack rather than sse registers.
-mno-sse2 Floating point arguments to be passed onto the stack rather than sse2 registers.
-fno-stack-protector Disables stack protection
-I. Look for header files in the current folder