GCC quick reference
|
Debugging & Profiling-g Produce debugging information in a format GDB (the GNU command line debugger) can use, and embed it in the object code or executable.-ggdb Produce debugging information optimized for GDB use. -p, -pg Produce profiling (performance) information for prof or gprof. The gprof profiling is more detailed, including information about which functions call which other functions, and how many times. -fprofile-arcs, -ftest-coverage Counts how many times each branch of an if, if-else, or loop statement is taken. Extremely detailed information about how your program executes, generated and logged when the program is run. -print-search-dirs Prints the directories where GCC will look for library files, etc. OptimizationOptimization produces faster and smaller assembly code, object code, and executables. It may produce assembly code that does not correspond line-by-line to the C source code, so that it mixes computation from multiple lines of C source or multiple iterations of a loop.-O, -O1 Optimize some -O2 Optimize a lot -O3 Optimize the most -funroll-loops Unroll loops where possible -fno-strict-aliasing Don't assume that a double * and an int * can never point to the same place (for example). Otherwise, -02 might break our floating-point addition emulator code (Assignment 3). -mcpu=pentium4, -m64, -m32, -msse2 Produce code optimized for Pentium 4, 64-bit x86-64, or processors with the SSE2 extensions, respectively. There are many more options like this. With no options, only code that runs on the Intel 80386 AND all later processors is generated. Linking-Ldirectory Searches directory in addition to the standard directories for libraries.-llibrary Searches for the file liblibrary.a or .so to link with the current object files (if it contains needed functions). Should appear after the input files in your gcc command. -static Do not link with dynamically loaded libraries (DLLs or .so libraries). Put all necessary functions into the final executable. -Idirectory Searches directory for header files, in addition to standard include directories. |