Linux "gcc" Command Line Options and Examples
GNU project C and C compiler

When you invoke GCC, it normally does preprocessing, compilation, assembly and linking. The "overall options" allow you to stop this process at an intermediate stage. For example, the -c option says not to run the linker.


Usage:

gcc [-c|-S|-E] [-std=standard]
[-g] [-pg] [-Olevel]
[-Wwarn...] [-Wpedantic]
[-Idir...] [-Ldir...]
[-Dmacro[=defn]...] [-Umacro]
[-foption...] [-mmachine-option...]
[-o outfile] [@file] infile...






Command Line Options:

-c
-S -E -o file -x language -v -### --help[=class[,...]] --target-help --version -pass-exit-codes -pipe -specs=file
gcc -c ...
-ansi
-std=standard -fgnu89-inline -fpermitted-flt-eval-methods=standard -aux-info filename
gcc -ansi ...
-fallow-parameterless-variadic-functions
-fno-asm -fno-builtin -fno-builtin-function -fgimple -fhosted -ffreestanding
gcc -fallow-parameterless-variadic-functions ...
-fopenacc
-fopenmp -fopenmp-simd -fms-extensions -fplan9-extensions -fsso-struct=endianness -fallow-single-precision
gcc -fopenacc ...
-fabi-version
-fno-access-control -faligned-new=n -fargs-in-order=n -fcheck-new -fconstexpr-depth=n
gcc -fabi-version ...
-fconstexpr-loop-limit
-ffriend-injection -fno-elide-constructors -fno-enforce-eh-specs -ffor-scope -fno-for-scope
gcc -fconstexpr-loop-limit ...
-fno-gnu-keywords
-fno-implicit-templates -fno-implicit-inline-templates -fno-implement-inlines -fms-extensions
gcc -fno-gnu-keywords ...
-fnew-inheriting-ctors
-fnew-ttp-matching -fno-nonansi-builtins -fnothrow-opt -fno-operator-names -fno-optional-diags
gcc -fnew-inheriting-ctors ...
-fpermissive
-fno-pretty-templates -frepo -fno-rtti -fsized-deallocation -ftemplate-backtrace-limit=n -ftemplate-depth=n
gcc -fpermissive ...
-fno-threadsafe-statics
-fuse-cxa-atexit -fno-weak -nostdinc++ -fvisibility-inlines-hidden -fvisibility-ms-compat
gcc -fno-threadsafe-statics ...
-fext-numeric-literals
-Wabi=n -Wabi-tag -Wconversion-null -Wctor-dtor-privacy -Wdelete-non-virtual-dtor -Wliteral-suffix
gcc -fext-numeric-literals ...
-Wmultiple-inheritance
-Wnamespaces -Wnarrowing -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor -Wreorder -Wregister -Weffc++
gcc -Wmultiple-inheritance ...
-Wstrict-null-sentinel
-Wtemplates -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions
gcc -Wstrict-null-sentinel ...
-Wsign-promo
Objective-C and Objective-C++ Language Options
gcc -Wsign-promo ...
-fconstant-string-class
-fgnu-runtime -fnext-runtime -fno-nil-receivers -fobjc-abi-version=n -fobjc-call-cxx-cdtors
gcc -fconstant-string-class ...
-fobjc-direct-dispatch
-fobjc-exceptions -fobjc-gc -fobjc-nilcheck -fobjc-std=objc1 -fno-local-ivars
gcc -fobjc-direct-dispatch ...
-fivar-visibility
-freplace-objc-classes -fzero-link -gen-decls -Wassign-intercept
gcc -fivar-visibility ...
-Wno-protocol
Diagnostic Message Formatting Options
gcc -Wno-protocol ...
-fmessage-length
-fdiagnostics-show-location=[once|every-line] -fdiagnostics-color=[auto|never|always]
gcc -fmessage-length ...
-fno-diagnostics-show-option
-fno-diagnostics-show-caret -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
gcc -fno-diagnostics-show-option ...
-fsyntax-only
-fmax-errors=n -Wpedantic -pedantic-errors -w -Wextra -Wall -Waddress -Waggregate-return -Walloc-zero
gcc -fsyntax-only ...
-Walloc-size-larger-than
-Walloca -Walloca-larger-than=n -Wno-aggressive-loop-optimizations -Warray-bounds -Warray-bounds=n
gcc -Walloc-size-larger-than ...
-Wno-attributes
-Wbool-compare -Wbool-operation -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined
gcc -Wno-attributes ...
-Wc90-c99-compat
-Wc99-c11-compat -Wc++-compat -Wc++11-compat -Wc++14-compat -Wcast-align -Wcast-qual -Wchar-subscripts
gcc -Wc90-c99-compat ...
-Wchkp
-Wclobbered -Wcomment -Wconditionally-supported -Wconversion -Wcoverage-mismatch -Wno-cpp -Wdangling-else
gcc -Wchkp ...
-Wdate-time
-Wdelete-incomplete -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init -Wdisabled-optimization
gcc -Wdate-time ...
-Wno-discarded-qualifiers
-Wno-discarded-array-qualifiers -Wno-div-by-zero -Wdouble-promotion -Wduplicated-branches
gcc -Wno-discarded-qualifiers ...
-Wduplicated-cond
-Wempty-body -Wenum-compare -Wno-endif-labels -Wexpansion-to-defined -Werror -Werror=* -Wfatal-errors
gcc -Wduplicated-cond ...
-Wfloat-equal
-Wformat -Wformat=2 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral -Wformat-overflow=n
gcc -Wfloat-equal ...
-Wformat-security
-Wformat-signedness -Wformat-truncation=n -Wformat-y2k -Wframe-address -Wframe-larger-than=len
gcc -Wformat-security ...
-Wno-free-nonheap-object
-Wjump-misses-init -Wignored-qualifiers -Wignored-attributes -Wincompatible-pointer-types -Wimplicit
gcc -Wno-free-nonheap-object ...
-Wimplicit-fallthrough
-Wimplicit-fallthrough=n -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Winline
gcc -Wimplicit-fallthrough ...
-Wno-int-conversion
-Wint-in-bool-context -Wno-int-to-pointer-cast -Winvalid-memory-model -Wno-invalid-offsetof -Winvalid-pch
gcc -Wno-int-conversion ...
-Wlarger-than
-Wlogical-op -Wlogical-not-parentheses -Wlong-long -Wmain -Wmaybe-uninitialized -Wmemset-elt-size
gcc -Wlarger-than ...
-Wmemset-transposed-args
-Wmisleading-indentation -Wmissing-braces -Wmissing-field-initializers -Wmissing-include-dirs
gcc -Wmemset-transposed-args ...
-Wno-multichar
-Wnonnull -Wnonnull-compare -Wnormalized=[none|id|nfc|nfkc] -Wnull-dereference -Wodr -Wno-overflow
gcc -Wno-multichar ...
-Wopenmp-simd
-Woverride-init-side-effects -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded -Wparentheses
gcc -Wopenmp-simd ...
-Wno-pedantic-ms-format
-Wplacement-new -Wplacement-new=n -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast
gcc -Wno-pedantic-ms-format ...
-Wno-pragmas
-Wredundant-decls -Wrestrict -Wno-return-local-addr -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar
gcc -Wno-pragmas ...
-Wshadow
-Wshadow=local -Wshadow=compatible-local -Wshift-overflow -Wshift-overflow=n -Wshift-count-negative
gcc -Wshadow ...
-Wshift-count-overflow
-Wshift-negative-value -Wsign-compare -Wsign-conversion -Wfloat-conversion -Wno-scalar-storage-order
gcc -Wshift-count-overflow ...
-Wsizeof-pointer-memaccess
-Wsizeof-array-argument -Wstack-protector -Wstack-usage=len -Wstrict-aliasing -Wstrict-aliasing=n
gcc -Wsizeof-pointer-memaccess ...
-Wstrict-overflow
-Wstrict-overflow=n -Wstringop-overflow=n -Wsuggest-attribute=[pure|const|noreturn|format]
gcc -Wstrict-overflow ...
-Wsuggest-final-types
-Wsuggest-final-methods -Wsuggest-override -Wmissing-format-attribute -Wsubobject-linkage -Wswitch
gcc -Wsuggest-final-types ...
-Wswitch-bool
-Wswitch-default -Wswitch-enum -Wswitch-unreachable -Wsync-nand -Wsystem-headers -Wtautological-compare
gcc -Wswitch-bool ...
-Wtrampolines
-Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations
gcc -Wtrampolines ...
-Wunsuffixed-float-constants
-Wunused -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros
gcc -Wunsuffixed-float-constants ...
-Wunused-parameter
-Wno-unused-result -Wunused-value -Wunused-variable -Wunused-const-variable -Wunused-const-variable=n
gcc -Wunused-parameter ...
-Wunused-but-set-parameter
-Wunused-but-set-variable -Wuseless-cast -Wvariadic-macros -Wvector-operation-performance -Wvla
gcc -Wunused-but-set-parameter ...
-Wbad-function-cast
-Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs
gcc -Wbad-function-cast ...
-Wold-style-declaration
-Wold-style-definition -Wstrict-prototypes -Wtraditional -Wtraditional-conversion
gcc -Wold-style-declaration ...
-Wdeclaration-after-statement
Debugging Options
gcc -Wdeclaration-after-statement ...
-g
-glevel -gcoff -gdwarf -gdwarf-version -ggdb -grecord-gcc-switches -gno-record-gcc-switches -gstabs -gstabs+
gcc -g ...
-gstrict-dwarf
-gno-strict-dwarf -gcolumn-info -gno-column-info -gvms -gxcoff -gxcoff+ -gz[=type] -fdebug-prefix-map=old=new
gcc -gstrict-dwarf ...
-fdebug-types-section
-feliminate-dwarf2-dups -fno-eliminate-unused-debug-types -femit-struct-debug-baseonly
gcc -fdebug-types-section ...
-femit-struct-debug-reduced
-femit-struct-debug-detailed[=spec-list] -feliminate-unused-debug-symbols -femit-class-debug-always
gcc -femit-struct-debug-reduced ...
-fno-merge-debug-strings
Optimization Options
gcc -fno-merge-debug-strings ...
-faggressive-loop-optimizations
-falign-functions[=n] -falign-jumps[=n] -falign-labels[=n] -falign-loops[=n] -fassociative-math
gcc -faggressive-loop-optimizations ...
-fauto-profile
-fauto-profile[=path] -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize
gcc -fauto-profile ...
-fbranch-target-load-optimize2
-fbtr-bb-exclusive -fcaller-saves -fcombine-stack-adjustments -fconserve-stack -fcompare-elim
gcc -fbranch-target-load-optimize2 ...
-fcprop-registers
-fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules -fcx-limited-range -fdata-sections
gcc -fcprop-registers ...
-fdce
-fdelayed-branch -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fdevirtualize-at-ltrans
gcc -fdce ...
-fdse
-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects -ffast-math -ffinite-math-only -ffloat-store
gcc -fdse ...
-fexcess-precision
-fforward-propagate -ffp-contract=style -ffunction-sections -fgcse -fgcse-after-reload -fgcse-las
gcc -fexcess-precision ...
-fgcse-lm
-fgraphite-identity -fgcse-sm -fhoist-adjacent-loads -fif-conversion -fif-conversion2 -findirect-inlining
gcc -fgcse-lm ...
-finline-functions
-finline-functions-called-once -finline-limit=n -finline-small-functions -fipa-cp -fipa-cp-clone
gcc -finline-functions ...
-fipa-bit-cp
-fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf -fira-algorithm=algorithm
gcc -fipa-bit-cp ...
-fira-region
-fira-hoist-pressure -fira-loop-pressure -fno-ira-share-save-slots -fno-ira-share-spill-slots
gcc -fira-region ...
-fisolate-erroneous-paths-dereference
-fisolate-erroneous-paths-attribute -fivopts -fkeep-inline-functions
gcc -fisolate-erroneous-paths-dereference ...
-fkeep-static-functions
-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage -floop-block -floop-interchange
gcc -fkeep-static-functions ...
-floop-strip-mine
-floop-unroll-and-jam -floop-nest-optimize -floop-parallelize-all -flra-remat -flto -flto-compression-level
gcc -floop-strip-mine ...
-flto-partition
-fmerge-all-constants -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
gcc -flto-partition ...
-fmove-loop-invariants
-fno-branch-count-reg -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
gcc -fmove-loop-invariants ...
-fno-guess-branch-probability
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 -fno-printf-return-value
gcc -fno-guess-branch-probability ...
-fno-sched-interblock
-fno-sched-spec -fno-signed-zeros -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
gcc -fno-sched-interblock ...
-fomit-frame-pointer
-foptimize-sibling-calls -fpartial-inlining -fpeel-loops -fpredictive-commoning -fprefetch-loop-arrays
gcc -fomit-frame-pointer ...
-fprofile-correction
-fprofile-use -fprofile-use=path -fprofile-values -fprofile-reorder-functions -freciprocal-math -free
gcc -fprofile-correction ...
-frename-registers
-freorder-blocks -freorder-blocks-algorithm=algorithm -freorder-blocks-and-partition -freorder-functions
gcc -frename-registers ...
-frerun-cse-after-loop
-freschedule-modulo-scheduled-loops -frounding-math -fsched2-use-superblocks -fsched-pressure
gcc -frerun-cse-after-loop ...
-fsched-spec-load
-fsched-spec-load-dangerous -fsched-stalled-insns-dep[=n] -fsched-stalled-insns[=n] -fsched-group-heuristic
gcc -fsched-spec-load ...
-fsched-critical-path-heuristic
-fsched-spec-insn-heuristic -fsched-rank-heuristic -fsched-last-insn-heuristic
gcc -fsched-critical-path-heuristic ...
-fsched-dep-count-heuristic
-fschedule-fusion -fschedule-insns -fschedule-insns2 -fsection-anchors -fselective-scheduling
gcc -fsched-dep-count-heuristic ...
-fselective-scheduling2
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fsemantic-interposition -fshrink-wrap
gcc -fselective-scheduling2 ...
-fshrink-wrap-separate
-fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops -fsplit-paths
gcc -fshrink-wrap-separate ...
-fsplit-wide-types
-fssa-backprop -fssa-phiopt -fstdarg-opt -fstore-merging -fstrict-aliasing -fstrict-overflow
gcc -fsplit-wide-types ...
-fthread-jumps
-ftracer -ftree-bit-ccp -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop
gcc -fthread-jumps ...
-ftree-dce
-ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting -ftree-loop-if-convert -ftree-loop-im
gcc -ftree-dce ...
-ftree-phiprop
-ftree-loop-distribution -ftree-loop-distribute-patterns -ftree-loop-ivcanon -ftree-loop-linear
gcc -ftree-phiprop ...
-ftree-loop-optimize
-ftree-loop-vectorize -ftree-parallelize-loops=n -ftree-pre -ftree-partial-pre -ftree-pta -ftree-reassoc
gcc -ftree-loop-optimize ...
-ftree-sink
-ftree-slsr -ftree-sra -ftree-switch-conversion -ftree-tail-merge -ftree-ter -ftree-vectorize -ftree-vrp
gcc -ftree-sink ...
-funconstrained-commons
-funit-at-a-time -funroll-all-loops -funroll-loops -funsafe-math-optimizations -funswitch-loops
gcc -funconstrained-commons ...
-p
-pg -fprofile-arcs --coverage -ftest-coverage -fprofile-dir=path -fprofile-generate -fprofile-generate=path
gcc -p ...
-fsanitize
-fsanitize-recover -fsanitize-recover=style -fasan-shadow-offset=number -fsanitize-sections=s1,s2,...
gcc -fsanitize ...
-fsanitize-undefined-trap-on-error
-fbounds-check -fcheck-pointer-bounds -fchkp-check-incomplete-type
gcc -fsanitize-undefined-trap-on-error ...
-fchkp-first-field-has-own-bounds
-fchkp-narrow-bounds -fchkp-narrow-to-innermost-array -fchkp-optimize
gcc -fchkp-first-field-has-own-bounds ...
-fchkp-use-fast-string-functions
-fchkp-use-nochk-string-functions -fchkp-use-static-bounds -fchkp-use-static-const-bounds
gcc -fchkp-use-fast-string-functions ...
-fchkp-treat-zero-dynamic-size-as-infinite
-fchkp-check-read -fchkp-check-read -fchkp-check-write -fchkp-store-bounds
gcc -fchkp-treat-zero-dynamic-size-as-infinite ...
-fchkp-instrument-calls
-fchkp-instrument-marked-only -fchkp-use-wrappers -fchkp-flexible-struct-trailing-arrays
gcc -fchkp-instrument-calls ...
-fstack-protector
-fstack-protector-all -fstack-protector-strong -fstack-protector-explicit -fstack-check
gcc -fstack-protector ...
-fstack-limit-register
-fstack-limit-symbol=sym -fno-stack-limit -fsplit-stack -fvtable-verify=[std|preinit|none]
gcc -fstack-limit-register ...
-fvtv-counts
-fvtv-debug -finstrument-functions -finstrument-functions-exclude-function-list=sym,sym,...
gcc -fvtv-counts ...
-finstrument-functions-exclude-file-list
Preprocessor Options
gcc -finstrument-functions-exclude-file-list ...
-Aquestion
-A-question[=answer] -C -CC -Dmacro[=defn] -dD -dI -dM -dN -dU -fdebug-cpp -fdirectives-only
gcc -Aquestion ...
-fdollars-in-identifiers
-fexec-charset=charset -fextended-identifiers -finput-charset=charset -fno-canonical-system-headers
gcc -fdollars-in-identifiers ...
-fpch-deps
-fpch-preprocess -fpreprocessed -ftabstop=width -ftrack-macro-expansion -fwide-exec-charset=charset
gcc -fpch-deps ...
-fworking-directory
-H -imacros file -include file -M -MD -MF -MG -MM -MMD -MP -MQ -MT -no-integrated-cpp -P -pthread
gcc -fworking-directory ...
-remap
Assembler Options
gcc -remap ...
-Wa,option
Linker Optionsobject-file-name -fuse-ld=linker -llibrary -nostartfiles -nodefaultlibs -nostdlib -pie -pthread -rdynamic -s -static
gcc -Wa,option ...
-static-libgcc
-static-libstdc++ -static-libasan -static-libtsan -static-liblsan -static-libubsan -static-libmpx
gcc -static-libgcc ...
-static-libmpxwrappers
Directory Options
gcc -static-libmpxwrappers ...
-Bprefix
-Idir -I- -idirafter dir -imacros file -imultilib dir -iplugindir=dir -iprefix file -iquote dir -isysroot dir
gcc -Bprefix ...
-isystem
dir -iwithprefix dir -iwithprefixbefore dir -Ldir -no-canonical-prefixes --no-sysroot-suffix -nostdinc -nostdinc++
gcc -isystem ...
--sysroot
Code Generation Options
gcc --sysroot ...
-fcall-saved-reg
-fcall-used-reg -ffixed-reg -fexceptions -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
gcc -fcall-saved-reg ...
-fasynchronous-unwind-tables
-fno-gnu-unique -finhibit-size-directive -fno-common -fno-ident -fpcc-struct-return -fpic -fPIC
gcc -fasynchronous-unwind-tables ...
-fpie
-fPIE -fno-plt -fno-jump-tables -frecord-gcc-switches -freg-struct-return -fshort-enums -fshort-wchar -fverbose-asm
gcc -fpie ...
-fpack-struct[
-fleading-underscore -ftls-model=model -fstack-reuse=reuse_level -ftrampolines -ftrapv -fwrapv
gcc -fpack-struct[ ...
-fvisibility
Developer Options
gcc -fvisibility ...
-fdisable-tree-pass-name
-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links -fdump-translation-unit[-n]
gcc -fdisable-tree-pass-name ...
-fdump-class-hierarchy[-n]
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline -fdump-passes -fdump-rtl-pass
gcc -fdump-class-hierarchy[-n] ...
-fdump-rtl-pass
-fdump-statistics -fdump-final-insns[=file] -fdump-tree-all -fdump-tree-switch
gcc -fdump-rtl-pass ...
-fdump-tree-switch-options
-fdump-tree-switch-options=filename -fcompare-debug[=opts] -fcompare-debug-second -fenable-kind-pass
gcc -fdump-tree-switch-options ...
-fenable-kind-pass
-fira-verbose=n -flto-report -flto-report-wpa -fmem-report-wpa -fmem-report -fpre-ipa-mem-report
gcc -fenable-kind-pass ...
-fpost-ipa-mem-report
-fopt-info -fopt-info-options[=file] -fprofile-report -frandom-seed=string -fsched-verbose=n
gcc -fpost-ipa-mem-report ...
-fsel-sched-verbose
-fsel-sched-dump-cfg -fsel-sched-pipelining-verbose -fstats -fstack-usage -ftime-report
gcc -fsel-sched-verbose ...
-ftime-report-details
-fvar-tracking-assignments-toggle -gtoggle -print-file-name=library -print-libgcc-file-name
gcc -ftime-report-details ...
-print-multi-directory
-print-multi-lib -print-multi-os-directory -print-prog-name=program -print-search-dirs -Q
gcc -print-multi-directory ...
-mstrict-align
-momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer -mtls-dialect=desc -mtls-dialect=traditional
gcc -mstrict-align ...
-mtls-size
-mfix-cortex-a53-835769 -mno-fix-cortex-a53-835769 -mfix-cortex-a53-843419 -mno-fix-cortex-a53-843419
gcc -mtls-size ...
-mlow-precision-recip-sqrt
-mno-low-precision-recip-sqrt -mlow-precision-sqrt -mno-low-precision-sqrt -mlow-precision-div
gcc -mlow-precision-recip-sqrt ...
-mno-low-precision-div
Adapteva Epiphany Options -mhalf-reg-file -mprefer-short-insn-regs -mbranch-cost=num -mcmove -mnops=num -msoft-cmpsf
gcc -mno-low-precision-div ...
-msplit-lohi
-mpost-inc -mpost-modify -mstack-offset=num -mround-nearest -mlong-calls -mshort-calls -msmall16
gcc -msplit-lohi ...
-mfp-mode=mode
ARC Options -mbarrel-shifter -mcpu=cpu -mA6 -mARC600 -mA7 -mARC700 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr -mea
gcc -mfp-mode=mode ...
-mno-mpy
-mmul32x16 -mmul64 -matomic -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap -mcrc
gcc -mno-mpy ...
-mdsp-packa
-mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape -mtelephony -mxy -misize -mannotate-align -marclinux
gcc -mdsp-packa ...
-marclinux_prof
-mlong-calls -mmedium-calls -msdata -mvolatile-cache -mtp-regno=regno -malign-call -mauto-modify-reg
gcc -marclinux_prof ...
-mbbit-peephole
-mno-brcc -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi -mexpand-adddi
gcc -mbbit-peephole ...
-mindexed-loads
-mlra -mlra-priority-none -mlra-priority-compact mlra-priority-noncompact -mno-millicode -mmixed-code
gcc -mindexed-loads ...
-mq-class
-mRcq -mRcw -msize-level=level -mtune=cpu -mmultcost=num -munalign-prob-threshold=probability -mmpy-option=multo
gcc -mq-class ...
-mdiv-rem
ARM Options -mapcs-frame -mno-apcs-frame -mabi=name -mapcs-stack-check -mno-apcs-stack-check -mapcs-reentrant
gcc -mdiv-rem ...
-mno-apcs-reentrant
-msched-prolog -mno-sched-prolog -mlittle-endian -mbig-endian -mfloat-abi=name -mfp16-format=name
gcc -mno-apcs-reentrant ...
-mthumb-interwork
-mno-thumb-interwork -mcpu=name -march=name -mfpu=name -mtune=name -mprint-tune-info
gcc -mthumb-interwork ...
-mstructure-size-boundary
-mabort-on-noreturn -mlong-calls -mno-long-calls -msingle-pic-base -mno-single-pic-base
gcc -mstructure-size-boundary ...
-mpic-register
-mnop-fun-dllimport -mpoke-function-name -mthumb -marm -mtpcs-frame -mtpcs-leaf-frame
gcc -mpic-register ...
-mcaller-super-interworking
-mcallee-super-interworking -mtp=name -mtls-dialect=dialect -mword-relocations -mfix-cortex-m3-ldrd
gcc -mcaller-super-interworking ...
-munaligned-access
AVR Options -mmcu=mcu -mabsdata -maccumulate-args -mbranch-cost=cost -mcall-prologues -mint8 -mn_flash=size -mno-interrupts
gcc -munaligned-access ...
-mno-specld-anomaly
-mcsync-anomaly -mno-csync-anomaly -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
gcc -mno-specld-anomaly ...
-mno-id-shared-library
-mshared-library-id=n -mleaf-id-shared-library -mno-leaf-id-shared-library -msep-data -mno-sep-data
gcc -mno-id-shared-library ...
-mcc-init
-mno-side-effects -mstack-align -mdata-align -mconst-align -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
gcc -mcc-init ...
-mno-gotplt
CR16 Options -mmac -mcr16cplus -mcr16c -msim -mint32 -mbit-ops -mdata-model=modelDarwin Options -all_load -allowable_client -arch -arch_errors_fatal -arch_only -bind_at_load -bundle -bundle_loader
gcc -mno-gotplt ...
-client_name
-compatibility_version -current_version -dead_strip -dependency-file -dylib_file -dylinker_install_name -dynamic
gcc -client_name ...
-dynamiclib
-exported_symbols_list -filelist -flat_namespace -force_cpusubtype_ALL -force_flat_namespace
gcc -dynamiclib ...
-headerpad_max_install_names
-iframework -image_base -init -install_name -keep_private_externs -multi_module
gcc -headerpad_max_install_names ...
-multiply_defined
-multiply_defined_unused -noall_load -no_dead_strip_inits_and_terms -nofixprebinding -nomultidefs
gcc -multiply_defined ...
-noprebind
-noseglinkedit -pagezero_size -prebind -prebind_all_twolevel_modules -private_bundle -read_only_relocs -sectalign
gcc -noprebind ...
-sectobjectsymbols
-whyload -seg1addr -sectcreate -sectobjectsymbols -sectorder -segaddr -segs_read_only_addr
gcc -sectobjectsymbols ...
-segs_read_write_addr
-seg_addr_table -seg_addr_table_filename -seglinkedit -segprot -segs_read_only_addr
gcc -segs_read_write_addr ...
-unexported_symbols_list
-weak_reference_mismatches -whatsloaded -F -gused -gfull -mmacosx-version-min=version -mkernel
gcc -unexported_symbols_list ...
-mone-byte-bool
DEC Alpha Options -mno-fp-regs -msoft-float -mieee -mieee-with-inexact -mieee-conformant -mfp-trap-mode=mode
gcc -mone-byte-bool ...
-mfp-rounding-mode
-mtrap-precision=mode -mbuild-constants -mcpu=cpu-type -mtune=cpu-type -mbwx -mmax -mfix -mcix
gcc -mfp-rounding-mode ...
-mdouble
-mno-double -mmedia -mno-media -mmuladd -mno-muladd -mfdpic -minline-plt -mgprel-ro -multilib-library-pic
gcc -mdouble ...
-mlinked-fp
-mlong-calls -malign-labels -mlibrary-pic -macc-4 -macc-8 -mpack -mno-pack -mno-eflags -mcond-move
gcc -mlinked-fp ...
-mno-cond-move
-moptimize-membar -mno-optimize-membar -mscc -mno-scc -mcond-exec -mno-cond-exec -mvliw-branch
gcc -mno-cond-move ...
-mno-vliw-branch
-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec -mno-nested-cond-exec -mtomcat-stats -mTLS -mtls
gcc -mno-vliw-branch ...
-mcpu
GNU/Linux Options -mglibc -muclibc -mmusl -mbionic -mandroid -tno-android-cc -tno-android-ldH8/300 Options -mrelax -mh -ms -mn -mexr -mno-exr -mint32 -malign-300HPPA Options -march=architecture-type -mcaller-copies -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls -mgas
gcc -mcpu ...
-mgnu-ld
-mhp-ld -mfixed-range=register-range -mjump-in-delay -mlinker-opt -mlong-calls -mlong-load-store
gcc -mgnu-ld ...
-mno-disable-fpregs
-mno-disable-indexing -mno-fast-indirect-calls -mno-gas -mno-jump-in-delay -mno-long-load-store
gcc -mno-disable-fpregs ...
-mno-portable-runtime
-mno-soft-float -mno-space-regs -msoft-float -mpa-risc-1-0 -mpa-risc-1-1 -mpa-risc-2-0
gcc -mno-portable-runtime ...
-mportable-runtime
IA-64 Options -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic -mvolatile-asm-stop -mregister-names -msdata
gcc -mportable-runtime ...
-mno-sdata
-mconstant-gp -mauto-pic -mfused-madd -minline-float-divide-min-latency -minline-float-divide-max-throughput
gcc -mno-sdata ...
-mno-inline-float-divide
-minline-int-divide-min-latency -minline-int-divide-max-throughput -mno-inline-int-divide
gcc -mno-inline-float-divide ...
-msched-br-in-data-spec
-msched-ar-in-data-spec -msched-in-control-spec -msched-spec-ldc -msched-spec-control-ldc
gcc -msched-br-in-data-spec ...
-msched-prefer-non-data-spec-insns
-msched-prefer-non-control-spec-insns -msched-stop-bits-after-every-cycle
gcc -msched-prefer-non-data-spec-insns ...
-msched-count-spec-in-critical-path
-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
gcc -msched-count-spec-in-critical-path ...
-msched-max-memory-insns-hard-limit
LM32 Options -mbarrel-shift-enabled -mdivide-enabled -mmultiply-enabled -msign-extend-enabled -muser-enabledM32R/D Options -m32r2 -m32rx -m32r -mdebug -malign-loops -mno-align-loops -missue-rate=number -mbranch-cost=number
gcc -msched-max-memory-insns-hard-limit ...
-mmodel
M32C Options -mcpu=cpu -msim -memregs=numberM680x0 Options -march=arch -mcpu=cpu -mtune=tune -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 -m68060 -mcpu32
gcc -mmodel ...
-m5200
-m5206e -m528x -m5307 -m5407 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 -mnobitfield -mrtd -mno-rtd
gcc -m5200 ...
-mdiv
-mno-div -mshort -mno-short -mhard-float -m68881 -msoft-float -mpcrel -malign-int -mstrict-align -msep-data
gcc -mdiv ...
-mno-sep-data
MCore Options -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates -mno-relax-immediates -mwide-bitfields
gcc -mno-sep-data ...
-mno-wide-bitfields
-m4byte-functions -mno-4byte-functions -mcallgraph-data -mno-callgraph-data -mslow-bytes -mno-slow-bytes
gcc -mno-wide-bitfields ...
-mno-lsim
MeP Options -mabsdiff -mall-opts -maverage -mbased=n -mbitops -mc=n -mclip -mconfig=name -mcop -mcop32 -mcop64 -mivc2
gcc -mno-lsim ...
-mdc
-mdiv -meb -mel -mio-volatile -ml -mleadz -mm -mminmax -mmult -mno-opts -mrepeat -ms -msatur -msdram -msim
gcc -mdc ...
-msimnovec
MicroBlaze Options -msoft-float -mhard-float -msmall-divides -mcpu=cpu -mmemcpy -mxl-soft-mul -mxl-soft-div
gcc -msimnovec ...
-mxl-barrel-shift
-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss -mxl-multiply-high -mxl-float-convert
gcc -mxl-barrel-shift ...
-mxl-float-sqrt
MIPS Options -EL -EB -march=arch -mtune=arch -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
gcc -mxl-float-sqrt ...
-mips32r6
-mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 -mips16 -mno-mips16 -mflip-mips16 -minterlink-compressed
gcc -mips32r6 ...
-mno-interlink-compressed
-minterlink-mips16 -mno-interlink-mips16 -mabi=abi -mabicalls -mno-abicalls -mshared -mno-shared
gcc -mno-interlink-compressed ...
-mplt
-mno-plt -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float -mno-float -msingle-float
gcc -mplt ...
-mdouble-float
-modd-spreg -mno-odd-spreg -mabs=mode -mnan=encoding -mdsp -mno-dsp -mdspr2 -mno-dspr2 -mmcu -mmno-mcu -meva
gcc -mdouble-float ...
-mno-eva
-mvirt -mno-virt -mxpa -mno-xpa -mmicromips -mno-micromips -mmsa -mno-msa -mfpu=fpu-type -msmartmips -mno-smartmips
gcc -mno-eva ...
-mpaired-single
-mno-paired-single -mdmx -mno-mdmx -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc -mlong64 -mlong32
gcc -mpaired-single ...
-msym32
-mno-sym32 -Gnum -mlocal-sdata -mno-local-sdata -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt -membedded-data
gcc -msym32 ...
-mno-embedded-data
-muninit-const-in-rodata -mno-uninit-const-in-rodata -mcode-readable=setting -msplit-addresses
gcc -mno-embedded-data ...
-mno-split-addresses
-mexplicit-relocs -mno-explicit-relocs -mcheck-zero-division -mno-check-zero-division -mdivide-traps
gcc -mno-split-addresses ...
-mdivide-breaks
-mload-store-pairs -mno-load-store-pairs -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls -mmad -mno-mad
gcc -mdivide-breaks ...
-mimadd
-mno-imadd -mfused-madd -mno-fused-madd -nocpp -mfix-24k -mno-fix-24k -mfix-r4000 -mno-fix-r4000 -mfix-r4400
gcc -mimadd ...
-mno-fix-r4400
-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 -mfix-vr4120 -mno-fix-vr4120 -mfix-vr4130
gcc -mno-fix-r4400 ...
-mno-fix-vr4130
-mfix-sb1 -mno-fix-sb1 -mflush-func=func -mno-flush-func -mbranch-cost=num -mbranch-likely
gcc -mno-fix-vr4130 ...
-mno-branch-likely
-mcompact-branches=policy -mfp-exceptions -mno-fp-exceptions -mvr4130-align -mno-vr4130-align -msynci
gcc -mno-branch-likely ...
-mno-synci
-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
gcc -mno-synci ...
-mframe-header-opt
MMIX Options -mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu -mabi=mmixware -mzero-extend -mknuthdiv
gcc -mframe-header-opt ...
-mtoplevel-symbols
-melf -mbranch-predict -mno-branch-predict -mbase-addresses -mno-base-addresses -msingle-exit
gcc -mtoplevel-symbols ...
-mno-single-exit
MN10300 Options -mmult-bug -mno-mult-bug -mno-am33 -mam33 -mam33-2 -mam34 -mtune=cpu-type -mreturn-pointer-on-d0 -mno-crt0
gcc -mno-single-exit ...
-mrelax
Moxie Options -meb -mel -mmul.x -mno-crt0MSP430 Options -msim -masm-hex -mmcu= -mcpu= -mlarge -msmall -mrelax -mwarn-mcu -mcode-region= -mdata-region=
gcc -mrelax ...
-msilicon-errata=
NDS32 Options -mbig-endian -mlittle-endian -mreduced-regs -mfull-regs -mcmov -mno-cmov -mperf-ext -mno-perf-ext -mv3push
gcc -msilicon-errata= ...
-mno-v3push
Nios II Options -G num -mgpopt=option -mgpopt -mno-gpopt -mel -meb -mno-bypass-cache -mbypass-cache -mno-cache-volatile
gcc -mno-v3push ...
-mcache-volatile
-mno-fast-sw-div -mfast-sw-div -mhw-mul -mno-hw-mul -mhw-mulx -mno-hw-mulx -mno-hw-div -mhw-div
gcc -mcache-volatile ...
-mcustom-insn
-mno-custom-insn -mcustom-fpu-cfg=name -mhal -msmallc -msys-crt0=name -msys-lib=name -march=arch -mbmx
gcc -mcustom-insn ...
-mno-bmx
Nvidia PTX Options -m32 -m64 -mmainkernel -moptimizePDP-11 Options -mfpu -msoft-float -mac0 -mno-ac0 -m40 -m45 -m10 -mbcopy -mbcopy-builtin -mint32 -mno-int16 -mint16
gcc -mno-bmx ...
-mno-int32
-mfloat32 -mno-float64 -mfloat64 -mno-float32 -mabshi -mno-abshi -mbranch-expensive -mbranch-cheap -munix-asm
gcc -mno-int32 ...
-mdec-asm
picoChip Options -mae=ae_type -mvliw-lookahead=N -msymbol-as-address -mno-inefficient-warningsPowerPC Options See RS/6000 and PowerPC Options.RISC-V Options -mbranch-cost=N-instruction -mplt -mno-plt -mabi=ABI-string -mfdiv -mno-fdiv -mdiv -mno-div -march=ISA-string
gcc -mdec-asm ...
-mtune
-msmall-data-limit=N-bytes -msave-restore -mno-save-restore -mstrict-align -mno-strict-align
gcc -mtune ...
-mcmodel
RL78 Options -msim -mmul=none -mmul=g13 -mmul=g14 -mallregs -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
gcc -mcmodel ...
-m64bit-doubles
RS/6000 and PowerPC Options -mcpu=cpu-type -mtune=cpu-type -mcmodel=code-model -mpowerpc64 -maltivec -mno-altivec
gcc -m64bit-doubles ...
-mpowerpc-gpopt
-mno-powerpc-gpopt -mpowerpc-gfxopt -mno-powerpc-gfxopt -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd
gcc -mpowerpc-gpopt ...
-mno-popcntd
-mfprnd -mno-fprnd -mcmpb -mno-cmpb -mmfpgpr -mno-mfpgpr -mhard-dfp -mno-hard-dfp -mfull-toc -mminimal-toc
gcc -mno-popcntd ...
-mno-fp-in-toc
-mno-sum-in-toc -m64 -m32 -mxl-compat -mno-xl-compat -mpe -malign-power -malign-natural -msoft-float
gcc -mno-fp-in-toc ...
-mhard-float
-mmultiple -mno-multiple -msingle-float -mdouble-float -msimple-fpu -mstring -mno-string -mupdate -mno-update
gcc -mhard-float ...
-mavoid-indexed-addresses
-mno-avoid-indexed-addresses -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align -mstrict-align
gcc -mavoid-indexed-addresses ...
-mno-strict-align
-mrelocatable -mno-relocatable -mrelocatable-lib -mno-relocatable-lib -mtoc -mno-toc -mlittle
gcc -mno-strict-align ...
-mlittle-endian
-mbig -mbig-endian -mdynamic-no-pic -maltivec -mswdiv -msingle-pic-base
gcc -mlittle-endian ...
-mprioritize-restricted-insns
-msched-costly-dep=dependence_type -minsert-sched-nops=scheme -mcall-sysv -mcall-netbsd
gcc -mprioritize-restricted-insns ...
-maix-struct-return
-msvr4-struct-return -mabi=abi-type -msecure-plt -mbss-plt -mblock-move-inline-limit=num -misel -mno-isel
gcc -maix-struct-return ...
-misel
-misel=no -mspe -mno-spe -mspe=yes -mspe=no -mpaired -mgen-cell-microcode -mwarn-cell-microcode -mvrsave
gcc -misel ...
-mno-vrsave
-mmulhw -mno-mulhw -mdlmzb -mno-dlmzb -mfloat-gprs=yes -mfloat-gprs=no -mfloat-gprs=single -mfloat-gprs=double
gcc -mno-vrsave ...
-mpointers-to-nested-functions
-mno-pointers-to-nested-functions -msave-toc-indirect -mno-save-toc-indirect -mpower8-fusion
gcc -mpointers-to-nested-functions ...
-mno-mpower8-fusion
-mpower8-vector -mno-power8-vector -mcrypto -mno-crypto -mhtm -mno-htm -mdirect-move -mno-direct-move
gcc -mno-mpower8-fusion ...
-mquad-memory
-mno-quad-memory -mquad-memory-atomic -mno-quad-memory-atomic -mcompat-align-parm -mno-compat-align-parm
gcc -mquad-memory ...
-mupper-regs-df
-mno-upper-regs-df -mupper-regs-sf -mno-upper-regs-sf -mupper-regs-di -mno-upper-regs-di -mupper-regs
gcc -mupper-regs-df ...
-mno-upper-regs
-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware -mgnu-attribute -mno-gnu-attribute
gcc -mno-upper-regs ...
-mstack-protector-guard
RX Options -m64bit-doubles -m32bit-doubles -fpu -nofpu -mcpu= -mbig-endian-data -mlittle-endian-data -msmall-data -msim
gcc -mstack-protector-guard ...
-mno-sim
-mas100-syntax -mno-as100-syntax -mrelax -mmax-constant-size= -mint-register= -mpid -mallow-string-insns
gcc -mno-sim ...
-mno-allow-string-insns
S/390 and zSeries Options -mtune=cpu-type -march=cpu-type -mhard-float -msoft-float -mhard-dfp -mno-hard-dfp -mlong-double-64
gcc -mno-allow-string-insns ...
-mlong-double-128
-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack -msmall-exec -mno-small-exec -mmvcle
gcc -mlong-double-128 ...
-mno-mvcle
-m64 -m31 -mdebug -mno-debug -mesa -mzarch -mhtm -mvx -mzvector -mtpf-trace -mno-tpf-trace -mfused-madd
gcc -mno-mvcle ...
-mno-fused-madd
Score Options -meb -mel -mnhwloop -muls -mmac -mscore5 -mscore5u -mscore7 -mscore7dSH Options -m1 -m2 -m2e -m2a-nofpu -m2a-single-only -m2a-single -m2a -m3 -m3e -m4-nofpu -m4-single-only -m4-single -m4
gcc -mno-fused-madd ...
-m4a-nofpu
-m4a-single-only -m4a-single -m4a -m4al -mb -ml -mdalign -mrelax -mbigtable -mfmovd -mrenesas -mno-renesas
gcc -m4a-nofpu ...
-mnomacsave
-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct -mprefergot -musermode -multcost=number
gcc -mnomacsave ...
-mbranch-cost
-mzdcbranch -mno-zdcbranch -mcbranch-force-delay-slot -mfused-madd -mno-fused-madd -mfsca -mno-fsca
gcc -mbranch-cost ...
-mfsrra
Solaris 2 Options -mclear-hwcap -mno-clear-hwcap -mimpure-text -mno-impure-text -pthreadsSPARC Options -mcpu=cpu-type -mtune=cpu-type -mcmodel=code-model -mmemory-model=mem-model -m32 -m64 -mapp-regs -mno-app-regs
gcc -mfsrra ...
-mfaster-structs
-mno-faster-structs -mflat -mno-flat -mfpu -mno-fpu -mhard-float -msoft-float -mhard-quad-float
gcc -mfaster-structs ...
-msoft-quad-float
-mstack-bias -mno-stack-bias -mstd-struct-return -mno-std-struct-return -munaligned-doubles
gcc -msoft-quad-float ...
-mno-unaligned-doubles
-muser-mode -mno-user-mode -mv8plus -mno-v8plus -mvis -mno-vis -mvis2 -mno-vis2 -mvis3 -mno-vis3
gcc -mno-unaligned-doubles ...
-mvis4
-mno-vis4 -mvis4b -mno-vis4b -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld -mpopc -mno-popc -msubxc
gcc -mvis4 ...
-mno-subxc
SPU Options -mwarn-reloc -merror-reloc -msafe-dma -munsafe-dma -mbranch-hints -msmall-mem -mlarge-mem -mstdmain
gcc -mno-subxc ...
-mfixed-range
-mea32 -mea64 -maddress-space-conversion -mno-address-space-conversion -mcache-size=cache-size
gcc -mfixed-range ...
-matomic-updates
System V Options -Qy -Qn -YP,paths -Ym,dirTILE-Gx Options -mcpu=CPU -m32 -m64 -mbig-endian -mlittle-endian -mcmodel=code-modelTILEPro Options -mcpu=cpu -m32V850 Options -mlong-calls -mno-long-calls -mep -mno-ep -mprolog-function -mno-prolog-function -mspace -mtda=n -msda=n
gcc -matomic-updates ...
-mzda
-mapp-regs -mno-app-regs -mdisable-callt -mno-disable-callt -mv850e2v3 -mv850e2 -mv850e1 -mv850es -mv850e -mv850
gcc -mzda ...
-mv850e3v5
VAX Options -mg -mgnu -munixVisium Options -mdebug -msim -mfpu -mno-fpu -mhard-float -msoft-float -mcpu=cpu-type -mtune=cpu-type -msv-mode
gcc -mv850e3v5 ...
-muser-mode
VMS Options -mvms-return-codes -mdebug-main=prefix -mmalloc64 -mpointer-size=sizeVxWorks Options -mrtp -non-static -Bstatic -Bdynamic -Xbind-lazy -Xbind-nowx86 Options -mtune=cpu-type -march=cpu-type -mtune-ctrl=feature-list -mdump-tune-features -mno-default -mfpmath=unit
gcc -muser-mode ...
-masm
-mno-fancy-math-387 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float -mno-wide-multiply -mrtd
gcc -masm ...
-malign-double
-mpreferred-stack-boundary=num -mincoming-stack-boundary=num -mcld -mcx16 -msahf -mmovbe -mcrc32 -mrecip
gcc -malign-double ...
-mrecip
-mvzeroupper -mprefer-avx128 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx -mavx2
gcc -mrecip ...
-mavx512f
-mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
gcc -mavx512f ...
-mpclmul
-mfsgsbase -mrdrnd -mf16c -mfma -mprefetchwt1 -mclflushopt -mxsavec -mxsaves -msse4a -m3dnow -m3dnowa -mpopcnt
gcc -mpclmul ...
-mabm
-mbmi -mtbm -mfma4 -mxop -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp -mmpx -mmwaitx -mclzero -mpku
gcc -mabm ...
-mthreads
-mms-bitfields -mno-align-stringops -minline-all-stringops -minline-stringops-dynamically -mstringop-strategy=alg
gcc -mthreads ...
-mmemcpy-strategy
-mmemset-strategy=strategy -mpush-args -maccumulate-outgoing-args -m128bit-long-double
gcc -mmemcpy-strategy ...
-m96bit-long-double
-mlong-double-64 -mlong-double-80 -mlong-double-128 -mregparm=num -msseregparm -mveclibabi=type
gcc -m96bit-long-double ...
-mvect8-ret-in-mem
-mpc32 -mpc64 -mpc80 -mstackrealign -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
gcc -mvect8-ret-in-mem ...
-mfentry
-mrecord-mcount -mnop-mcount -m8bit-idiv -mavx256-split-unaligned-load -mavx256-split-unaligned-store
gcc -mfentry ...
-malign-data
-mstack-protector-guard=guard -mmitigate-rop -mgeneral-regs-only -mindirect-branch=choice
gcc -malign-data ...
-mfunction-return
x86 Windows Options -mconsole -mcygwin -mno-cygwin -mdll -mnop-fun-dllimport -mthread -municode -mwin32 -mwindows
gcc -mfunction-return ...
-fno-set-stack-executable
Xstormy16 Options -msimXtensa Options -mconst16 -mno-const16 -mfused-madd -mno-fused-madd -mforce-no-pic -mserialize-volatile -mno-serialize-volatile
gcc -fno-set-stack-executable ...
-mtext-section-literals
-mno-text-section-literals -mauto-litpools -mno-auto-litpools -mtarget-align -mno-target-align
gcc -mtext-section-literals ...
-mlongcalls
zSeries Options See S/390 and zSeries Options.Options Controlling the Kind of OutputCompilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. GCC iscapable of preprocessing and compiling several files either into several assembler input files, or into one assembler input file;then each assembler input file produces an object file, and linking combines all the object files (those newly compiled, and thosespecified as input) into an executable file.For any given input file, the file name suffix determines what kind of compilation is done:file.cC source code that must be preprocessed.file.iC source code that should not be preprocessed.file.iiC++ source code that should not be preprocessed.file.mObjective-C source code. Note that you must link with the libobjc library to make an Objective-C program work.file.miObjective-C source code that should not be preprocessed.file.mmfile.MObjective-C++ source code. Note that you must link with the libobjc library to make an Objective-C++ program work. Note that .Mrefers to a literal capital M.file.miiObjective-C++ source code that should not be preprocessed.file.hC, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header (default), or C, C++ header file to beturned into an Ada spec (via the -fdump-ada-spec switch).file.ccfile.cpfile.cxxfile.cppfile.CPPfile.c++file.CC++ source code that must be preprocessed. Note that in .cxx, the last two letters must both be literally x. Likewise, .Crefers to a literal capital C.file.mmfile.MObjective-C++ source code that must be preprocessed.file.miiObjective-C++ source code that should not be preprocessed.file.hhfile.Hfile.hpfile.hxxfile.hppfile.HPPfile.h++file.tccC++ header file to be turned into a precompiled header or Ada spec.file.ffile.forfile.ftnFixed form Fortran source code that should not be preprocessed.file.Ffile.FORfile.fppfile.FPPfile.FTNFixed form Fortran source code that must be preprocessed (with the traditional preprocessor).file.f90file.f95file.f03file.f08Free form Fortran source code that should not be preprocessed.file.F90file.F95file.F03file.F08Free form Fortran source code that must be preprocessed (with the traditional preprocessor).file.goGo source code.file.brigBRIG files (binary representation of HSAIL).file.adsAda source code file that contains a library unit declaration (a declaration of a package, subprogram, or generic, or a genericinstantiation), or a library unit renaming declaration (a package, generic, or subprogram renaming declaration). Such files arealso called specs.file.adbAda source code file containing a library unit body (a subprogram or package body). Such files are also called bodies.file.dD source code file.file.diD interface code file.file.ddD documentation code file.file.sAssembler code.file.Sfile.sxAssembler code that must be preprocessed.otherAn object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.You can specify the input language explicitly with the -x option:
gcc -mlongcalls ...
-x
Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on thefile name suffix). This option applies to all following input files until the next -x option. Possible values for language are:c c-header cpp-outputc++ c++-header c++-cpp-outputobjective-c objective-c-header objective-c-cpp-outputobjective-c++ objective-c++-header objective-c++-cpp-outputassembler assembler-with-cppadadf77 f77-cpp-input f95 f95-cpp-inputgobrig
gcc -x ...
-o
Place output in file file. This applies to whatever sort of output is being produced, whether it be an executable file, anobject file, an assembler file or preprocessed C code.If -o is not specified, the default is to put an executable file in a.out, the object file for source.suffix in source.o, itsassembler file in source.s, a precompiled header file in source.suffix.gch, and all preprocessed C source on standard output.
gcc -o ...
-###
Like -v except the commands are not executed and arguments are quoted unless they contain only alphanumeric characters or "./-_".This is useful for shell scripts to capture the driver-generated command lines.
gcc -### ...
--help
Print (on the standard output) a description of the command-line options understood by gcc. If the -v option is also specifiedthen --help is also passed on to the various processes invoked by gcc, so that they can display the command-line options theyaccept. If the -Wextra option has also been specified (prior to the --help option), then command-line options that have nodocumentation associated with them are also displayed.
gcc --help ...
--target-help
Print (on the standard output) a description of target-specific command-line options for each tool. For some targets extratarget-specific information may also be printed.
gcc --target-help ...
-mapcs
The output is sensitive to the effects of previous command-line options, so for example it is possible to find out whichoptimizations are enabled at -O2 by using:
gcc -mapcs ...
-Q
Alternatively you can discover which binary optimizations are enabled by -O3 by using:gcc -c -Q -O3 --help=optimizers > /tmp/O3-optsgcc -c -Q -O2 --help=optimizers > /tmp/O2-optsdiff /tmp/O2-opts /tmp/O3-opts | grep enabled
gcc -Q ...
--version
Display the version number and copyrights of the invoked GCC.
gcc --version ...
-pass-exit-codes
Normally the gcc program exits with the code of 1 if any phase of the compiler returns a non-success return code. If you specify
gcc -pass-exit-codes ...
-pipe
Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on somesystems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble.
gcc -pipe ...
-specs
Process file after the compiler reads in the standard specs file, in order to override the defaults which the gcc driver programuses when determining what switches to pass to cc1, cc1plus, as, ld, etc. More than one -specs=file can be specified on thecommand line, and they are processed in order, from left to right.
gcc -specs ...
-wrapper
Invoke all subcommands under a wrapper program. The name of the wrapper program and its parameters are passed as a commaseparated list.gcc -c t.c -wrapper gdb,--argsThis invokes all subprograms of gcc under gdb --args, thus the invocation of cc1 is gdb --args cc1 ....
gcc -wrapper ...
-fplugin
Load the plugin code in file name.so, assumed to be a shared object to be dlopen'd by the compiler. The base name of the sharedobject file is used to identify the plugin for the purposes of argument parsing (See -fplugin-arg-name-key=value below). Eachplugin should define the callback functions specified in the Plugins API.
gcc -fplugin ...
-fplugin-arg-name-key
Define an argument called key with a value of value for the plugin called name.
gcc -fplugin-arg-name-key ...
-fdump-ada-spec[-slim]
For C and C++ source and include files, generate corresponding Ada specs.
gcc -fdump-ada-spec[-slim] ...
-fada-spec-parent
In conjunction with -fdump-ada-spec[-slim] above, generate Ada specs as child units of parent unit.
gcc -fada-spec-parent ...
-fdump-go-spec
For input files in any language, generate corresponding Go declarations in file. This generates Go "const", "type", "var", and"func" declarations which may be a useful way to start writing a Go interface to code written in some other language.@fileRead command-line options from file. The options read are inserted in place of the original @file option. If file does notexist, or cannot be read, then the option will be treated literally, and not removed.Options in file are separated by whitespace. A whitespace character may be included in an option by surrounding the entireoption in either single or double quotes. Any character (including a backslash) may be included by prefixing the character to beincluded with a backslash. The file may itself contain additional @file options; any such options will be processed recursively.Compiling C++ ProgramsC++ source files conventionally use one of the suffixes .C, .cc, .cpp, .CPP, .c++, .cp, or .cxx; C++ header files often use .hh,.hpp, .H, or (for shared template code) .tcc; and preprocessed C++ files use the suffix .ii. GCC recognizes files with these namesand compiles them as C++ programs even if you call the compiler the same way as for compiling C programs (usually with the name gcc).However, the use of gcc does not add the C++ library. g++ is a program that calls GCC and automatically specifies linking againstthe C++ library. It treats .c, .h and .i files as C++ source files instead of C source files unless -x is used. This program isalso useful when precompiling a C header file with a .h extension for use in C++ compilations. On many systems, g++ is alsoinstalled with the name c++.When you compile C++ programs, you may specify many of the same command-line options that you use for compiling programs in anylanguage; or command-line options meaningful for C and related languages; or options that are meaningful only for C++ programs.Options Controlling C DialectThe following options control the dialect of C (or languages derived from C, such as C++, Objective-C and Objective-C++) that thecompiler accepts:
gcc -fdump-go-spec ...
-ansi.
The -ansi option does not cause non-ISO programs to be rejected gratuitously. For that, -Wpedantic is required in addition to
gcc -ansi. ...
-std
Determine the language standard. This option is currently only supported when compiling C or C++.The compiler can accept several base standards, such as c90 or c++98, and GNU dialects of those standards, such as gnu90 orgnu++98. When a base standard is specified, the compiler accepts all programs following that standard plus those using GNUextensions that do not contradict it. For example, -std=c90 turns off certain features of GCC that are incompatible with ISOC90, such as the "asm" and "typeof" keywords, but not other GNU extensions that do not have a meaning in ISO C90, such asomitting the middle term of a "?:" expression. On the other hand, when a GNU dialect of a standard is specified, all featuressupported by the compiler are enabled, even when those features change the meaning of the base standard. As a result, somestrict-conforming programs may be rejected. The particular standard is used by -Wpedantic to identify which features are GNUextensions given that version of the standard. For example -std=gnu90 -Wpedantic warns about C++ style // comments, while
gcc -std ...
-fgnu89-inline
The option -fgnu89-inline tells GCC to use the traditional GNU semantics for "inline" functions when in C99 mode.Using this option is roughly equivalent to adding the "gnu_inline" function attribute to all inline functions.The option -fno-gnu89-inline explicitly tells GCC to use the C99 semantics for "inline" when in C99 or gnu99 mode (i.e., itspecifies the default behavior). This option is not supported in -std=c90 or -std=gnu90 mode.The preprocessor macros "__GNUC_GNU_INLINE__" and "__GNUC_STDC_INLINE__" may be used to check which semantics are in effect for"inline" functions.
gcc -fgnu89-inline ...
-fpermitted-flt-eval-methods
ISO/IEC TS 18661-3 defines new permissible values for "FLT_EVAL_METHOD" that indicate that operations and constants with asemantic type that is an interchange or extended format should be evaluated to the precision and range of that type. These newvalues are a superset of those permitted under C99/C11, which does not specify the meaning of other positive values of"FLT_EVAL_METHOD". As such, code conforming to C11 may not have been written expecting the possibility of the new values.
gcc -fpermitted-flt-eval-methods ...
-aux-info
Output to the given filename prototyped declarations for all functions declared and/or defined in a translation unit, includingthose in header files. This option is silently ignored in any language other than C.Besides declarations, the file indicates, in comments, the origin of each declaration (source file and line), whether thedeclaration was implicit, prototyped or unprototyped (I, N for new or O for old, respectively, in the first character after theline number and the colon), and whether it came from a declaration or a definition (C or F, respectively, in the followingcharacter). In the case of function definitions, a K&R-style list of arguments followed by their declarations is also provided,inside comments, after the declaration.
gcc -aux-info ...
-fno-asm
Do not recognize "asm", "inline" or "typeof" as a keyword, so that code can use these words as identifiers. You can use thekeywords "__asm__", "__inline__" and "__typeof__" instead. -ansi implies -fno-asm.In C++, this switch only affects the "typeof" keyword, since "asm" and "inline" are standard keywords. You may want to use the
gcc -fno-asm ...
-fno-builtin-function
Don't recognize built-in functions that do not begin with __builtin_ as prefix.GCC normally generates special code to handle certain built-in functions more efficiently; for instance, calls to "alloca" maybecome single instructions which adjust the stack directly, and calls to "memcpy" may become inline copy loops. The resultingcode is often both smaller and faster, but since the function calls no longer appear as such, you cannot set a breakpoint onthose calls, nor can you change the behavior of the functions by linking with a different library. In addition, when a functionis recognized as a built-in function, GCC may use information about that function to warn about problems with calls to thatfunction, or to generate more efficient code, even if the resulting code still contains calls to that function. For example,warnings are given with -Wformat for bad calls to "printf" when "printf" is built in and "strlen" is known not to modify globalmemory.With the -fno-builtin-function option only the built-in function function is disabled. function must not begin with __builtin_.If a function is named that is not built-in in this version of GCC, this option is ignored. There is no corresponding
gcc -fno-builtin-function ...
-fgimple
Enable parsing of function definitions marked with "__GIMPLE". This is an experimental feature that allows unit testing ofGIMPLE passes.
gcc -fgimple ...
-fhosted
Assert that compilation targets a hosted environment. This implies -fbuiltin. A hosted environment is one in which the entirestandard library is available, and in which "main" has a return type of "int". Examples are nearly everything except a kernel.This is equivalent to -fno-freestanding.
gcc -fhosted ...
-ffreestanding
Assert that compilation targets a freestanding environment. This implies -fno-builtin. A freestanding environment is one inwhich the standard library may not exist, and program startup may not necessarily be at "main". The most obvious example is anOS kernel. This is equivalent to -fno-hosted.
gcc -ffreestanding ...
-fopenacc-dim
Specify default compute dimensions for parallel offload regions that do not explicitly specify. The geom value is a triple of':'-separated sizes, in order 'gang', 'worker' and, 'vector'. A size can be omitted, to use a target-specific default value.
gcc -fopenacc-dim ...
-fopenmp
Enable handling of OpenMP directives "#pragma omp" in C/C++ and "!$omp" in Fortran. When -fopenmp is specified, the compilergenerates parallel code according to the OpenMP Application Program Interface v4.5 <http://www.openmp.org/>. This option implies
gcc -fopenmp ...
-pthread
and thus is only supported on targets that have support for -pthread. -fopenmp implies -fopenmp-simd.
gcc -pthread ...
-fopenmp-simd
Enable handling of OpenMP's SIMD directives with "#pragma omp" in C/C++ and "!$omp" in Fortran. Other OpenMP directives areignored.
gcc -fopenmp-simd ...
-fcilkplus
Enable the usage of Cilk Plus language extension features for C/C++. When the option -fcilkplus is specified, enable the usageof the Cilk Plus Language extension features for C/C++. The present implementation follows ABI version 1.2. This is anexperimental feature that is only partially complete, and whose interface may change in future versions of GCC as the officialspecification changes. Currently, all features but "_Cilk_for" have been implemented.
gcc -fcilkplus ...
-fgnu-tm
When the option -fgnu-tm is specified, the compiler generates code for the Linux variant of Intel's current Transactional MemoryABI specification document (Revision 1.1, May 6 2009). This is an experimental feature whose interface may change in futureversions of GCC, as the official specification changes. Please note that not all architectures are supported for this feature.For more information on GCC's support for transactional memory,Note that the transactional memory feature is not supported with non-call exceptions (-fnon-call-exceptions).
gcc -fgnu-tm ...
-fms-extensions
Accept some non-standard constructs used in Microsoft header files.In C++ code, this allows member names in structures to be similar to previous types declarations.typedef int UOW;struct ABC {UOW UOW;};Some cases of unnamed fields in structures and unions are only accepted with this option.Note that this option is off for all targets but x86 targets using ms-abi.
gcc -fms-extensions ...
-fplan9-extensions
Accept some non-standard constructs used in Plan 9 code.This enables -fms-extensions, permits passing pointers to structures with anonymous fields to functions that expect pointers toelements of the type of the field, and permits referring to anonymous fields declared using a typedef. This is only supportedfor C, not C++.
gcc -fplan9-extensions ...
-fcond-mismatch
Allow conditional expressions with mismatched types in the second and third arguments. The value of such an expression is void.This option is not supported for C++.
gcc -fcond-mismatch ...
-flax-vector-conversions
Allow implicit conversions between vectors with differing numbers of elements and/or incompatible element types. This optionshould not be used for new code.
gcc -flax-vector-conversions ...
-funsigned-char
Let the type "char" be unsigned, like "unsigned char".Each kind of machine has a default for what "char" should be. It is either like "unsigned char" by default or like "signed char"by default.Ideally, a portable program should always use "signed char" or "unsigned char" when it depends on the signedness of an object.But many programs have been written to use plain "char" and expect it to be signed, or expect it to be unsigned, depending on themachines they were written for. This option, and its inverse, let you make such a program work with the opposite default.The type "char" is always a distinct type from each of "signed char" or "unsigned char", even though its behavior is always justlike one of those two.
gcc -funsigned-char ...
-fsigned-char
Let the type "char" be signed, like "signed char".Note that this is equivalent to -fno-unsigned-char, which is the negative form of -funsigned-char. Likewise, the option
gcc -fsigned-char ...
-fno-signed-char
is equivalent to -funsigned-char.
gcc -fno-signed-char ...
-fno-unsigned-bitfields
These options control whether a bit-field is signed or unsigned, when the declaration does not use either "signed" or "unsigned".By default, such a bit-field is signed, because this is consistent: the basic integer types such as "int" are signed types.
gcc -fno-unsigned-bitfields ...
-fsso-struct
Set the default scalar storage order of structures and unions to the specified endianness. The accepted values are big-endian,little-endian and native for the native endianness of the target (the default). This option is not supported for C++.Warning: the -fsso-struct switch causes GCC to generate code that is not binary compatible with code generated without it if thespecified endianness is not the native endianness of the target.Options Controlling C++ DialectThis section describes the command-line options that are only meaningful for C++ programs. You can also use most of the GNU compileroptions regardless of what language your program is in. For example, you might compile a file firstClass.C like this:g++ -g -fstrict-enums -O -c firstClass.CIn this example, only -fstrict-enums is an option meant only for C++ programs; you can use the other options with any languagesupported by GCC.Some options for compiling C programs, such as -std, are also relevant for C++ programs.Here is a list of options that are only for compiling C++ programs:
gcc -fsso-struct ...
-fabi-compat-version
On targets that support strong aliases, G++ works around mangling changes by creating an alias with the correct mangled name whendefining a symbol with an incorrect mangled name. This switch specifies which ABI version to use for the alias.With -fabi-version=0 (the default), this defaults to 8 (GCC 5 compatibility). If another ABI version is explicitly selected,this defaults to 0. For compatibility with GCC versions 3.2 through 4.9, use -fabi-compat-version=2.If this option is not provided but -Wabi=n is, that version is used for compatibility aliases. If this option is provided alongwith -Wabi (without the version), the version from this option is used for the warning.
gcc -fabi-compat-version ...
-fno-access-control
Turn off all access checking. This switch is mainly useful for working around bugs in the access control code.
gcc -fno-access-control ...
-faligned-new
Enable support for C++17 "new" of types that require more alignment than "void* ::operator new(std::size_t)" provides. A numericargument such as "-faligned-new=32" can be used to specify how much alignment (in bytes) is provided by that function, but fewusers will need to override the default of "alignof(std::max_align_t)".
gcc -faligned-new ...
-fcheck-new
Check that the pointer returned by "operator new" is non-null before attempting to modify the storage allocated. This check isnormally unnecessary because the C++ standard specifies that "operator new" only returns 0 if it is declared "throw()", in whichcase the compiler always checks the return value even without this option. In all other cases, when "operator new" has a non-empty exception specification, memory exhaustion is signalled by throwing "std::bad_alloc". See also new (nothrow).
gcc -fcheck-new ...
-fconcepts
Enable support for the C++ Extensions for Concepts Technical Specification, ISO 19217 (2015), which allows code liketemplate <class T> concept bool Addable = requires (T t) { t + t; };template <Addable T> T add (T a, T b) { return a + b; }
gcc -fconcepts ...
-fconstexpr-depth
Set the maximum nested evaluation depth for C++11 constexpr functions to n. A limit is needed to detect endless recursion duringconstant expression evaluation. The minimum specified by the standard is 512.
gcc -fconstexpr-depth ...
-fdeduce-init-list
Enable deduction of a template type parameter as "std::initializer_list" from a brace-enclosed initializer list, i.e.template <class T> auto forward(T t) -> decltype (realfn (t)){return realfn (t);}void f(){forward({1,2}); // call forward<std::initializer_list<int>>}This deduction was implemented as a possible extension to the originally proposed semantics for the C++11 standard, but was notpart of the final standard, so it is disabled by default. This option is deprecated, and may be removed in a future version ofG++.
gcc -fdeduce-init-list ...
-ffriend-injection
Inject friend functions into the enclosing namespace, so that they are visible outside the scope of the class in which they aredeclared. Friend functions were documented to work this way in the old Annotated C++ Reference Manual. However, in ISO C++ afriend function that is not declared in an enclosing scope can only be found using argument dependent lookup. GCC defaults tothe standard behavior.This option is for compatibility, and may be removed in a future release of G++.
gcc -ffriend-injection ...
-fno-elide-constructors
The C++ standard allows an implementation to omit creating a temporary that is only used to initialize another object of the sametype. Specifying this option disables that optimization, and forces G++ to call the copy constructor in all cases. This optionalso causes G++ to call trivial member functions which otherwise would be expanded inline.In C++17, the compiler is required to omit these temporaries, but this option still affects trivial member functions.
gcc -fno-elide-constructors ...
-fno-enforce-eh-specs
Don't generate code to check for violation of exception specifications at run time. This option violates the C++ standard, butmay be useful for reducing code size in production builds, much like defining "NDEBUG". This does not give user code permissionto throw exceptions in violation of the exception specifications; the compiler still optimizes based on the specifications, sothrowing an unexpected exception results in undefined behavior at run time.
gcc -fno-enforce-eh-specs ...
-fno-extern-tls-init
The C++11 and OpenMP standards allow "thread_local" and "threadprivate" variables to have dynamic (runtime) initialization. Tosupport this, any use of such a variable goes through a wrapper function that performs any necessary initialization. When theuse and definition of the variable are in the same translation unit, this overhead can be optimized away, but when the use is ina different translation unit there is significant overhead even if the variable doesn't actually need dynamic initialization. Ifthe programmer can be sure that no use of the variable in a non-defining TU needs to trigger dynamic initialization (eitherbecause the variable is statically initialized, or a use of the variable in the defining TU will be executed before any uses inanother TU), they can avoid this overhead with the -fno-extern-tls-init option.On targets that support symbol aliases, the default is -fextern-tls-init. On targets that do not support symbol aliases, thedefault is -fno-extern-tls-init.
gcc -fno-extern-tls-init ...
-fno-for-scope
If -ffor-scope is specified, the scope of variables declared in a for-init-statement is limited to the "for" loop itself, asspecified by the C++ standard. If -fno-for-scope is specified, the scope of variables declared in a for-init-statement extendsto the end of the enclosing scope, as was the case in old versions of G++, and other (traditional) implementations of C++.If neither flag is given, the default is to follow the standard, but to allow and give a warning for old-style code that wouldotherwise be invalid, or have different behavior.
gcc -fno-for-scope ...
-fno-implicit-templates
Never emit code for non-inline templates that are instantiated implicitly (i.e. by use); only emit code for explicitinstantiations.
gcc -fno-implicit-templates ...
-fno-implicit-inline-templates
Don't emit code for implicit instantiations of inline templates, either. The default is to handle inlines differently so thatcompiles with and without optimization need the same set of explicit instantiations.
gcc -fno-implicit-inline-templates ...
-fno-implement-inlines
To save space, do not emit out-of-line copies of inline functions controlled by "#pragma implementation". This causes linkererrors if these functions are not inlined everywhere they are called.
gcc -fno-implement-inlines ...
-fnew-ttp-matching
Enable the P0522 resolution to Core issue 150, template template parameters and default arguments: this allows a template withdefault template arguments as an argument for a template template parameter with fewer template parameters. This flag is enabledby default for -std=c++1z.
gcc -fnew-ttp-matching ...
-fno-nonansi-builtins
Disable built-in declarations of functions that are not mandated by ANSI/ISO C. These include "ffs", "alloca", "_exit", "index","bzero", "conjf", and other related functions.
gcc -fno-nonansi-builtins ...
-fnothrow-opt
Treat a "throw()" exception specification as if it were a "noexcept" specification to reduce or eliminate the text size overheadrelative to a function with no exception specification. If the function has local variables of types with non-trivialdestructors, the exception specification actually makes the function smaller because the EH cleanups for those variables can beoptimized away. The semantic effect is that an exception thrown out of a function with such an exception specification resultsin a call to "terminate" rather than "unexpected".
gcc -fnothrow-opt ...
-fno-operator-names
Do not treat the operator name keywords "and", "bitand", "bitor", "compl", "not", "or" and "xor" as synonyms as keywords.
gcc -fno-operator-names ...
-fno-optional-diags
Disable diagnostics that the standard says a compiler does not need to issue. Currently, the only such diagnostic issued by G++is the one for a name having multiple meanings within a class.
gcc -fno-optional-diags ...
-fno-pretty-templates
When an error message refers to a specialization of a function template, the compiler normally prints the signature of thetemplate followed by the template arguments and any typedefs or typenames in the signature (e.g. "void f(T) [with T = int]"rather than "void f(int)") so that it's clear which template is involved. When an error message refers to a specialization of aclass template, the compiler omits any template arguments that match the default template arguments for that template. If eitherof these behaviors make it harder to understand the error message rather than easier, you can use -fno-pretty-templates todisable them.
gcc -fno-pretty-templates ...
-frepo
Enable automatic template instantiation at link time. This option also implies -fno-implicit-templates.
gcc -frepo ...
-fno-rtti
Disable generation of information about every class with virtual functions for use by the C++ run-time type identificationfeatures ("dynamic_cast" and "typeid"). If you don't use those parts of the language, you can save some space by using thisflag. Note that exception handling uses the same information, but G++ generates it as needed. The "dynamic_cast" operator canstill be used for casts that do not require run-time type information, i.e. casts to "void *" or to unambiguous base classes.
gcc -fno-rtti ...
-fsized-deallocation
Enable the built-in global declarationsvoid operator delete (void *, std::size_t) noexcept;void operator delete[] (void *, std::size_t) noexcept;as introduced in C++14. This is useful for user-defined replacement deallocation functions that, for example, use the size ofthe object to make deallocation faster. Enabled by default under -std=c++14 and above. The flag -Wsized-deallocation warnsabout places that might want to add a definition.
gcc -fsized-deallocation ...
-fstrict-enums
Allow the compiler to optimize using the assumption that a value of enumerated type can only be one of the values of theenumeration (as defined in the C++ standard; basically, a value that can be represented in the minimum number of bits needed torepresent all the enumerators). This assumption may not be valid if the program uses a cast to convert an arbitrary integervalue to the enumerated type.
gcc -fstrict-enums ...
-fstrong-eval-order
Evaluate member access, array subscripting, and shift expressions in left-to-right order, and evaluate assignment in right-to-left order, as adopted for C++17. Enabled by default with -std=c++1z. -fstrong-eval-order=some enables just the ordering ofmember access and shift expressions, and is the default without -std=c++1z.
gcc -fstrong-eval-order ...
-ftemplate-backtrace-limit
Set the maximum number of template instantiation notes for a single warning or error to n. The default value is 10.
gcc -ftemplate-backtrace-limit ...
-ftemplate-depth
Set the maximum instantiation depth for template classes to n. A limit on the template instantiation depth is needed to detectendless recursions during template class instantiation. ANSI/ISO C++ conforming programs must not rely on a maximum depthgreater than 17 (changed to 1024 in C++11). The default value is 900, as the compiler can run out of stack space before hitting1024 in some situations.
gcc -ftemplate-depth ...
-fuse-cxa-atexit
Register destructors for objects with static storage duration with the "__cxa_atexit" function rather than the "atexit" function.This option is required for fully standards-compliant handling of static destructors, but only works if your C library supports"__cxa_atexit".
gcc -fuse-cxa-atexit ...
-fno-use-cxa-get-exception-ptr
Don't use the "__cxa_get_exception_ptr" runtime routine. This causes "std::uncaught_exception" to be incorrect, but is necessaryif the runtime routine is not available.
gcc -fno-use-cxa-get-exception-ptr ...
-fvisibility-inlines-hidden
This switch declares that the user does not attempt to compare pointers to inline functions or methods where the addresses of thetwo functions are taken in different shared objects.The effect of this is that GCC may, effectively, mark inline methods with "__attribute__ ((visibility ("hidden")))" so that theydo not appear in the export table of a DSO and do not require a PLT indirection when used within the DSO. Enabling this optioncan have a dramatic effect on load and link times of a DSO as it massively reduces the size of the dynamic export table when thelibrary makes heavy use of templates.The behavior of this switch is not quite the same as marking the methods as hidden directly, because it does not affect staticvariables local to the function or cause the compiler to deduce that the function is defined in only one shared object.You may mark a method as having a visibility explicitly to negate the effect of the switch for that method. For example, if youdo want to compare pointers to a particular inline method, you might mark it as having default visibility. Marking the enclosingclass with explicit visibility has no effect.Explicitly instantiated inline methods are unaffected by this option as their linkage might otherwise cross a shared libraryboundary.
gcc -fvisibility-inlines-hidden ...
-fvisibility-ms-compat
This flag attempts to use visibility settings to make GCC's C++ linkage model compatible with that of Microsoft Visual Studio.The flag makes these changes to GCC's linkage model:1. It sets the default visibility to "hidden", like -fvisibility=hidden.2. Types, but not their members, are not hidden by default.3. The One Definition Rule is relaxed for types without explicit visibility specifications that are defined in more than oneshared object: those declarations are permitted if they are permitted when this option is not used.In new code it is better to use -fvisibility=hidden and export those classes that are intended to be externally visible.Unfortunately it is possible for code to rely, perhaps accidentally, on the Visual Studio behavior.Among the consequences of these changes are that static data members of the same type with the same name but defined in differentshared objects are different, so changing one does not change the other; and that pointers to function members defined indifferent shared objects may not compare equal. When this flag is given, it is a violation of the ODR to define types with thesame name differently.
gcc -fvisibility-ms-compat ...
-fno-weak
Do not use weak symbol support, even if it is provided by the linker. By default, G++ uses weak symbols if they are available.This option exists only for testing, and should not be used by end-users; it results in inferior code and has no benefits. Thisoption may be removed in a future release of G++.
gcc -fno-weak ...
-nostdinc++
Do not search for header files in the standard directories specific to C++, but do still search the other standard directories.(This option is used when building the C++ library.)In addition, these optimization, warning, and code generation options have meanings only for C++ programs:
gcc -nostdinc++ ...
-Wabi
Warn when G++ it generates code that is probably not compatible with the vendor-neutral C++ ABI. Since G++ now defaults toupdating the ABI with each major release, normally -Wabi will warn only if there is a check added later in a release series foran ABI issue discovered since the initial release. -Wabi will warn about more things if an older ABI version is selected (with
gcc -Wabi ...
-Wabi=2
If an explicit version number is provided and -fabi-compat-version is not specified, the version number from this option is usedfor compatibility aliases. If no explicit version number is provided with this option, but -fabi-compat-version is specified,that version number is used for ABI warnings.Although an effort has been made to warn about all such cases, there are probably some cases that are not warned about, eventhough G++ is generating incompatible code. There may also be cases where warnings are emitted even though the code that isgenerated is compatible.You should rewrite your code to avoid these warnings if you are concerned about the fact that code generated by G++ may not bebinary compatible with code generated by other compilers.Known incompatibilities in -fabi-version=2 (which was the default from GCC 3.4 to 4.9) include:* A template with a non-type template parameter of reference type was mangled incorrectly:extern int N;template <int &> struct S {};void n (S<N>) {2}This was fixed in -fabi-version=3.* SIMD vector types declared using "__attribute ((vector_size))" were mangled in a non-standard way that does not allow foroverloading of functions taking vectors of different sizes.The mangling was changed in -fabi-version=4.* "__attribute ((const))" and "noreturn" were mangled as type qualifiers, and "decltype" of a plain declaration was foldedaway.These mangling issues were fixed in -fabi-version=5.* Scoped enumerators passed as arguments to a variadic function are promoted like unscoped enumerators, causing "va_arg" tocomplain. On most targets this does not actually affect the parameter passing ABI, as there is no way to pass an argumentsmaller than "int".Also, the ABI changed the mangling of template argument packs, "const_cast", "static_cast", prefix increment/decrement, and aclass scope function used as a template argument.These issues were corrected in -fabi-version=6.* Lambdas in default argument scope were mangled incorrectly, and the ABI changed the mangling of "nullptr_t".These issues were corrected in -fabi-version=7.* When mangling a function type with function-cv-qualifiers, the un-qualified function type was incorrectly treated as asubstitution candidate.This was fixed in -fabi-version=8, the default for GCC 5.1.* "decltype(nullptr)" incorrectly had an alignment of 1, leading to unaligned accesses. Note that this did not affect the ABIof a function with a "nullptr_t" parameter, as parameters have a minimum alignment.This was fixed in -fabi-version=9, the default for GCC 5.2.* Target-specific attributes that affect the identity of a type, such as ia32 calling conventions on a function type (stdcall,regparm, etc.), did not affect the mangled name, leading to name collisions when function pointers were used as templatearguments.This was fixed in -fabi-version=10, the default for GCC 6.1.It also warns about psABI-related changes. The known psABI changes at this point include:* For SysV/x86-64, unions with "long double" members are passed in memory as specified in psABI. For example:union U {long double ld;int i;};"union U" is always passed in memory.
gcc -Wabi=2 ...
-Wabi-tag
Warn when a type with an ABI tag is used in a context that does not have that ABI tag. See C++ Attributes for more informationabout ABI tags.
gcc -Wabi-tag ...
-Wctor-dtor-privacy
Warn when a class seems unusable because all the constructors or destructors in that class are private, and it has neitherfriends nor public static member functions. Also warn if there are no non-private methods, and there's at least one privatemember function that isn't a constructor or destructor.
gcc -Wctor-dtor-privacy ...
-Wdelete-non-virtual-dtor
Warn when "delete" is used to destroy an instance of a class that has virtual functions and non-virtual destructor. It is unsafeto delete an instance of a derived class through a pointer to a base class if the base class does not have a virtual destructor.This warning is enabled by -Wall.
gcc -Wdelete-non-virtual-dtor ...
-Wliteral-suffix
Warn when a string or character literal is followed by a ud-suffix which does not begin with an underscore. As a conformingextension, GCC treats such suffixes as separate preprocessing tokens in order to maintain backwards compatibility with code thatuses formatting macros from "<inttypes.h>". For example:#define __STDC_FORMAT_MACROS#include <inttypes.h>#include <stdio.h>int main() {int64_t i64 = 123;printf("My int64: %" PRId64"\n", i64);}In this case, "PRId64" is treated as a separate preprocessing token.Additionally, warn when a user-defined literal operator is declared with a literal suffix identifier that doesn't begin with anunderscore. Literal suffix identifiers that don't begin with an underscore are reserved for future standardization.This warning is enabled by default.
gcc -Wliteral-suffix ...
-Wlto-type-mismatch
During the link-time optimization warn about type mismatches in global declarations from different compilation units. Requires
gcc -Wlto-type-mismatch ...
-flto
to be enabled. Enabled by default.
gcc -flto ...
-Wno-narrowing
For C++11 and later standards, narrowing conversions are diagnosed by default, as required by the standard. A narrowingconversion from a constant produces an error, and a narrowing conversion from a non-constant produces a warning, but
gcc -Wno-narrowing ...
-Wnoexcept
Warn when a noexcept-expression evaluates to false because of a call to a function that does not have a non-throwing exceptionspecification (i.e. "throw()" or "noexcept") but is known by the compiler to never throw an exception.
gcc -Wnoexcept ...
-Wnoexcept-type
Warn if the C++1z feature making "noexcept" part of a function type changes the mangled name of a symbol relative to C++14.Enabled by -Wabi and -Wc++1z-compat.template <class T> void f(T t) { t(); };void g() noexcept;void h() { f(g); } // in C++14 calls f<void(*)()>, in C++1z calls f<void(*)()noexcept>
gcc -Wnoexcept-type ...
-Wnon-virtual-dtor
Warn when a class has virtual functions and an accessible non-virtual destructor itself or in an accessible polymorphic baseclass, in which case it is possible but unsafe to delete an instance of a derived class through a pointer to the class itself orbase class. This warning is automatically enabled if -Weffc++ is specified.
gcc -Wnon-virtual-dtor ...
-Wregister
Warn on uses of the "register" storage class specifier, except when it is part of the GNU Explicit Register Variables extension.The use of the "register" keyword as storage class specifier has been deprecated in C++11 and removed in C++17. Enabled bydefault with -std=c++1z.
gcc -Wregister ...
-Wreorder
Warn when the order of member initializers given in the code does not match the order in which they must be executed. Forinstance:struct A {int i;int j;A(): j (0), i (1) { }};The compiler rearranges the member initializers for "i" and "j" to match the declaration order of the members, emitting a warningto that effect. This warning is enabled by -Wall.
gcc -Wreorder ...
-std=c++11,
The following -W... options are not affected by -Wall.
gcc -std=c++11, ...
-Weffc++
Warn about violations of the following style guidelines from Scott Meyers' Effective C++ series of books:* Define a copy constructor and an assignment operator for classes with dynamically-allocated memory.* Prefer initialization to assignment in constructors.* Have "operator=" return a reference to *this.* Don't try to return a reference when you must return an object.* Distinguish between prefix and postfix forms of increment and decrement operators.* Never overload "&&", "||", or ",".This option also enables -Wnon-virtual-dtor, which is also one of the effective C++ recommendations. However, the check isextended to warn about the lack of virtual destructor in accessible non-polymorphic bases classes too.When selecting this option, be aware that the standard library headers do not obey all of these guidelines; use grep -v to filterout those warnings.
gcc -Weffc++ ...
-Wno-non-template-friend
Disable warnings when non-template friend functions are declared within a template. In very old versions of GCC that predateimplementation of the ISO standard, declarations such as friend int foo(int), where the name of the friend is an unqualified-id,could be interpreted as a particular specialization of a template function; the warning exists to diagnose compatibilityproblems, and is enabled by default.
gcc -Wno-non-template-friend ...
-Wold-style-cast
Warn if an old-style (C-style) cast to a non-void type is used within a C++ program. The new-style casts ("dynamic_cast","static_cast", "reinterpret_cast", and "const_cast") are less vulnerable to unintended effects and much easier to search for.
gcc -Wold-style-cast ...
-Woverloaded-virtual
Warn when a function declaration hides virtual functions from a base class. For example, in:struct A {virtual void f();};struct B: public A {void f(int);};the "A" class version of "f" is hidden in "B", and code like:B* b;
gcc -Woverloaded-virtual ...
-Wno-pmf-conversions
Disable the diagnostic for converting a bound pointer to member function to a plain pointer.
gcc -Wno-pmf-conversions ...
-Wtemplates
Warn when a primary template declaration is encountered. Some coding rules disallow templates, and this may be used to enforcethat rule. The warning is inactive inside a system header file, such as the STL, so one can still use the STL. One may alsoinstantiate or specialize templates.
gcc -Wtemplates ...
-Wvirtual-inheritance
Warn when a class is defined with a virtual direct base class. Some coding rules disallow multiple inheritance, and this may beused to enforce that rule. The warning is inactive inside a system header file, such as the STL, so one can still use the STL.One may also define classes that indirectly use virtual inheritance.
gcc -Wvirtual-inheritance ...
-Wnamespaces
Warn when a namespace definition is opened. Some coding rules disallow namespaces, and this may be used to enforce that rule.The warning is inactive inside a system header file, such as the STL, so one can still use the STL. One may also use usingdirectives and qualified names.
gcc -Wnamespaces ...
-Wno-terminate
Disable the warning about a throw-expression that will immediately result in a call to "terminate".Options Controlling Objective-C and Objective-C++ Dialects(NOTE: This manual does not describe the Objective-C and Objective-C++ languages themselves.This section describes the command-line options that are only meaningful for Objective-C and Objective-C++ programs. You can alsouse most of the language-independent GNU compiler options. For example, you might compile a file some_class.m like this:gcc -g -fgnu-runtime -O -c some_class.mIn this example, -fgnu-runtime is an option meant only for Objective-C and Objective-C++ programs; you can use the other options withany language supported by GCC.Note that since Objective-C is an extension of the C language, Objective-C compilations may also use options specific to the C front-end (e.g., -Wtraditional). Similarly, Objective-C++ compilations may use C++-specific options (e.g., -Wabi).Here is a list of options that are only for compiling Objective-C and Objective-C++ programs:
gcc -Wno-terminate ...
-fgnu-runtime
Generate object code compatible with the standard GNU Objective-C runtime. This is the default for most types of systems.
gcc -fgnu-runtime ...
-fnext-runtime
Generate output compatible with the NeXT runtime. This is the default for NeXT-based systems, including Darwin and Mac OS X.The macro "__NEXT_RUNTIME__" is predefined if (and only if) this option is used.
gcc -fnext-runtime ...
-fno-nil-receivers
Assume that all Objective-C message dispatches ("[receiver message:arg]") in this translation unit ensure that the receiver isnot "nil". This allows for more efficient entry points in the runtime to be used. This option is only available in conjunctionwith the NeXT runtime and ABI version 0 or 1.
gcc -fno-nil-receivers ...
-fobjc-abi-version
Use version n of the Objective-C ABI for the selected runtime. This option is currently supported only for the NeXT runtime. Inthat case, Version 0 is the traditional (32-bit) ABI without support for properties and other Objective-C 2.0 additions. Version1 is the traditional (32-bit) ABI with support for properties and other Objective-C 2.0 additions. Version 2 is the modern(64-bit) ABI. If nothing is specified, the default is Version 0 on 32-bit target machines, and Version 2 on 64-bit targetmachines.
gcc -fobjc-abi-version ...
-fobjc-call-cxx-cdtors
For each Objective-C class, check if any of its instance variables is a C++ object with a non-trivial default constructor. Ifso, synthesize a special "- (id) .cxx_construct" instance method which runs non-trivial default constructors on any such instancevariables, in order, and then return "self". Similarly, check if any instance variable is a C++ object with a non-trivialdestructor, and if so, synthesize a special "- (void) .cxx_destruct" method which runs all such default destructors, in reverseorder.The "- (id) .cxx_construct" and "- (void) .cxx_destruct" methods thusly generated only operate on instance variables declared inthe current Objective-C class, and not those inherited from superclasses. It is the responsibility of the Objective-C runtime toinvoke all such methods in an object's inheritance hierarchy. The "- (id) .cxx_construct" methods are invoked by the runtimeimmediately after a new object instance is allocated; the "- (void) .cxx_destruct" methods are invoked immediately before theruntime deallocates an object instance.As of this writing, only the NeXT runtime on Mac OS X 10.4 and later has support for invoking the "- (id) .cxx_construct" and "-(void) .cxx_destruct" methods.
gcc -fobjc-call-cxx-cdtors ...
-fobjc-exceptions
Enable syntactic support for structured exception handling in Objective-C, similar to what is offered by C++. This option isrequired to use the Objective-C keywords @try, @throw, @catch, @finally and @synchronized. This option is available with boththe GNU runtime and the NeXT runtime (but not available in conjunction with the NeXT runtime on Mac OS X 10.2 and earlier).
gcc -fobjc-exceptions ...
-fobjc-gc
Enable garbage collection (GC) in Objective-C and Objective-C++ programs. This option is only available with the NeXT runtime;the GNU runtime has a different garbage collection implementation that does not require special compiler flags.
gcc -fobjc-gc ...
-fobjc-nilcheck
For the NeXT runtime with version 2 of the ABI, check for a nil receiver in method invocations before doing the actual methodcall. This is the default and can be disabled using -fno-objc-nilcheck. Class methods and super calls are never checked for nilin this way no matter what this flag is set to. Currently this flag does nothing when the GNU runtime, or an older version ofthe NeXT runtime ABI, is used.
gcc -fobjc-nilcheck ...
-fobjc-std
Conform to the language syntax of Objective-C 1.0, the language recognized by GCC 4.0. This only affects the Objective-Cadditions to the C/C++ language; it does not affect conformance to C/C++ standards, which is controlled by the separate C/C++dialect option flags. When this option is used with the Objective-C or Objective-C++ compiler, any Objective-C syntax that isnot recognized by GCC 4.0 is rejected. This is useful if you need to make sure that your Objective-C code can be compiled witholder versions of GCC.
gcc -fobjc-std ...
-freplace-objc-classes
Emit a special marker instructing ld(1) not to statically link in the resulting object file, and allow dyld(1) to load it in atrun time instead. This is used in conjunction with the Fix-and-Continue debugging mode, where the object file in question may berecompiled and dynamically reloaded in the course of program execution, without the need to restart the program itself.Currently, Fix-and-Continue functionality is only available in conjunction with the NeXT runtime on Mac OS X 10.3 and later.
gcc -freplace-objc-classes ...
-fzero-link
When compiling for the NeXT runtime, the compiler ordinarily replaces calls to "objc_getClass("...")" (when the name of the classis known at compile time) with static class references that get initialized at load time, which improves run-time performance.Specifying the -fzero-link flag suppresses this behavior and causes calls to "objc_getClass("...")" to be retained. This isuseful in Zero-Link debugging mode, since it allows for individual class implementations to be modified during program execution.The GNU runtime currently always retains calls to "objc_get_class("...")" regardless of command-line options.
gcc -fzero-link ...
-fno-local-ivars
By default instance variables in Objective-C can be accessed as if they were local variables from within the methods of the classthey're declared in. This can lead to shadowing between instance variables and other variables declared either locally inside aclass method or globally with the same name. Specifying the -fno-local-ivars flag disables this behavior thus avoiding variableshadowing issues.
gcc -fno-local-ivars ...
-gen-decls
Dump interface declarations for all classes seen in the source file to a file named sourcename.decl.
gcc -gen-decls ...
-Wassign-intercept
Warn whenever an Objective-C assignment is being intercepted by the garbage collector.
gcc -Wassign-intercept ...
-Wselector
Warn if multiple methods of different types for the same selector are found during compilation. The check is performed on thelist of methods in the final stage of compilation. Additionally, a check is performed for each selector appearing in a"@selector(...)" expression, and a corresponding method for that selector has been found during compilation. Because thesechecks scan the method table only at the end of compilation, these warnings are not produced if the final stage of compilation isnot reached, for example because an error is found during compilation, or because the -fsyntax-only option is being used.
gcc -Wselector ...
-Wstrict-selector-match
Warn if multiple methods with differing argument and/or return types are found for a given selector when attempting to send amessage using this selector to a receiver of type "id" or "Class". When this flag is off (which is the default behavior), thecompiler omits such warnings if any differences found are confined to types that share the same size and alignment.
gcc -Wstrict-selector-match ...
-Wundeclared-selector
Warn if a "@selector(...)" expression referring to an undeclared selector is found. A selector is considered undeclared if nomethod with that name has been declared before the "@selector(...)" expression, either explicitly in an @interface or @protocoldeclaration, or implicitly in an @implementation section. This option always performs its checks as soon as a "@selector(...)"expression is found, while -Wselector only performs its checks in the final stage of compilation. This also enforces the codingstyle convention that methods and selectors must be declared before being used.
gcc -Wundeclared-selector ...
-print-objc-runtime-info
Generate C header describing the largest structure that is passed by value, if any.Options to Control Diagnostic Messages FormattingTraditionally, diagnostic messages have been formatted irrespective of the output device's aspect (e.g. its width, ...). You can usethe options described below to control the formatting algorithm for diagnostic messages, e.g. how many characters per line, how oftensource location information should be reported. Note that some language front ends may not honor these options.
gcc -print-objc-runtime-info ...
-fdiagnostics-show-location
Only meaningful in line-wrapping mode. Instructs the diagnostic messages reporter to emit source location information once; thatis, in case the message is too long to fit on a single physical line and has to be wrapped, the source location won't be emitted(as prefix) again, over and over, in subsequent continuation lines. This is the default behavior.
gcc -fdiagnostics-show-location ...
-fno-diagnostics-color
Use color in diagnostics. WHEN is never, always, or auto. The default depends on how the compiler has been configured, it canbe any of the above WHEN options or also never if GCC_COLORS environment variable isn't present in the environment, and autootherwise. auto means to use color only when the standard error is a terminal. The forms -fdiagnostics-color and
gcc -fno-diagnostics-color ...
-fno-diagnostics-show-caret
By default, each diagnostic emitted includes the original source line and a caret ^ indicating the column. This optionsuppresses this information. The source line is truncated to n characters, if the -fmessage-length=n option is given. When theoutput is done to the terminal, the width is limited to the width given by the COLUMNS environment variable or, if not set, tothe terminal width.
gcc -fno-diagnostics-show-caret ...
-fdiagnostics-parseable-fixits
Emit fix-it hints in a machine-parseable format, suitable for consumption by IDEs. For each fix-it, a line will be printed afterthe relevant diagnostic, starting with the string "fix-it:". For example:fix-it:"test.c":{45:3-45:21}:"gtk_widget_show_all"The location is expressed as a half-open range, expressed as a count of bytes, starting at byte 1 for the initial column. In theabove example, bytes 3 through 20 of line 45 of "test.c" are to be replaced with the given string:0000000001111111111222222222212345678901234567890123456789gtk_widget_showall (dlg);^^^^^^^^^^^^^^^^^^gtk_widget_show_allThe filename and replacement string escape backslash as "\\", tab as "\t", newline as "\n", double quotes as "\"", non-printablecharacters as octal (e.g. vertical tab as "\013").An empty replacement string indicates that the given range is to be removed. An empty range (e.g. "45:3-45:3") indicates thatthe string is to be inserted at the given position.
gcc -fdiagnostics-parseable-fixits ...
-fdiagnostics-generate-patch
Print fix-it hints to stderr in unified diff format, after any diagnostics are printed. For example:
gcc -fdiagnostics-generate-patch ...
-42,5
void show_cb(GtkDialog *dlg){
gcc -42,5 ...
-
+ gtk_widget_show_all(dlg);}The diff may or may not be colorized, following the same rules as for diagnostics (see -fdiagnostics-color).
gcc - ...
-fno-show-column
Do not print column numbers in diagnostics. This may be necessary if diagnostics are being scanned by a program that does notunderstand the column numbers, such as dejagnu.Options to Request or Suppress WarningsWarnings are diagnostic messages that report constructions that are not inherently erroneous but that are risky or suggest there mayhave been an error.The following language-independent options do not enable specific warnings but control the kinds of diagnostics produced by GCC.
gcc -fno-show-column ...
-fmax-errors
Limits the maximum number of error messages to n, at which point GCC bails out rather than attempting to continue processing thesource code. If n is 0 (the default), there is no limit on the number of error messages produced. If -Wfatal-errors is alsospecified, then -Wfatal-errors takes precedence over this option.
gcc -fmax-errors ...
-w
Inhibit all warning messages.
gcc -w ...
-Werror
Make all warnings into errors.
gcc -Werror ...
-Wfatal-errors
This option causes the compiler to abort compilation on the first error occurred rather than trying to keep going and printingfurther error messages.You can request many specific warnings with options beginning with -W, for example -Wimplicit to request warnings on implicitdeclarations. Each of these specific warning options also has a negative form beginning -Wno- to turn off warnings; for example,
gcc -Wfatal-errors ...
-pedantic
Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden extensions, and some otherprograms that do not follow ISO C and ISO C++. For ISO C, follows the version of the ISO C standard specified by any -std optionused.Valid ISO C and ISO C++ programs should compile properly with or without this option (though a rare few require -ansi or a -stdoption specifying the required version of ISO C). However, without this option, certain GNU extensions and traditional C and C++features are supported as well. With this option, they are rejected.
gcc -pedantic ...
-pedantic-errors
Give an error whenever the base standard (see -Wpedantic) requires a diagnostic, in some cases where there is undefined behaviorat compile-time and in some other cases that do not prevent compilation of programs that are valid according to the standard.This is not equivalent to -Werror=pedantic, since there are errors enabled by this option and not enabled by the latter and viceversa.
gcc -pedantic-errors ...
-Wall
This enables all the warnings about constructions that some users consider questionable, and that are easy to avoid (or modify toprevent the warning), even in conjunction with macros. This also enables some language-specific warnings described in C++Dialect Options and Objective-C and Objective-C++ Dialect Options.
gcc -Wall ...
-Waddress
-Warray-bounds=1 (only with -O2) -Wbool-compare -Wbool-operation -Wc++11-compat -Wc++14-compat -Wchar-subscripts
gcc -Waddress ...
-Wcomment
-Wduplicate-decl-specifier (C and Objective-C only) -Wenum-compare (in C/ObjC; this is on by default in C++) -Wformat
gcc -Wcomment ...
-Wint-in-bool-context
(C and Objective-C only) -Winit-self (only for C++) -Wlogical-not-parentheses -Wmain (only for C/ObjC and unless -ffreestanding)
gcc -Wint-in-bool-context ...
-Wmaybe-uninitialized
for C/ObjC) -Wnarrowing (only for C++) -Wnonnull -Wnonnull-compare -Wopenmp-simd -Wparentheses -Wpointer-sign -Wreorder
gcc -Wmaybe-uninitialized ...
-Wreturn-type
-Wsequence-point -Wsign-compare (only in C++) -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-overflow=1
gcc -Wreturn-type ...
-Wswitch
-Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value
gcc -Wswitch ...
-Wunused-variable
Note that some warning flags are not implied by -Wall. Some of them warn about constructions that users generally do notconsider questionable, but which occasionally you might wish to check for; others warn about constructions that are necessary orhard to avoid in some cases, and there is no simple way to modify the code to suppress the warning. Some of them are enabled by
gcc -Wunused-variable ...
-Wextra
but many of them must be enabled individually.
gcc -Wextra ...
-Wclobbered
only) -Wold-style-declaration (C only) -Woverride-init -Wsign-compare (C only) -Wtype-limits -Wuninitialized
gcc -Wclobbered ...
-Wshift-negative-value
(in C++03 and in C99 and newer) -Wunused-parameter (only with -Wunused or -Wall)
gcc -Wshift-negative-value ...
-Wchar-subscripts
Warn if an array subscript has type "char". This is a common cause of error, as programmers often forget that this type issigned on some machines. This warning is enabled by -Wall.
gcc -Wchar-subscripts ...
-Wno-coverage-mismatch
Warn if feedback profiles do not match when using the -fprofile-use option. If a source file is changed between compiling with
gcc -Wno-coverage-mismatch ...
-Wno-cpp
(C, Objective-C, C++, Objective-C++ and Fortran only)Suppress warning messages emitted by "#warning" directives.
gcc -Wno-cpp ...
-Wdouble-promotion
Give a warning when a value of type "float" is implicitly promoted to "double". CPUs with a 32-bit "single-precision" floating-point unit implement "float" in hardware, but emulate "double" in software. On such a machine, doing computations using "double"values is much more expensive because of the overhead required for software emulation.It is easy to accidentally do computations with "double" because floating-point literals are implicitly of type "double". Forexample, in:float area(float radius){return 3.14159 * radius * radius;}the compiler performs the entire computation with "double" because the floating-point literal is a "double".
gcc -Wdouble-promotion ...
-Wduplicate-decl-specifier
Warn if a declaration has duplicate "const", "volatile", "restrict" or "_Atomic" specifier. This warning is enabled by -Wall.
gcc -Wduplicate-decl-specifier ...
-Wformat
Check calls to "printf" and "scanf", etc., to make sure that the arguments supplied have types appropriate to the format stringspecified, and that the conversions specified in the format string make sense. This includes standard functions, and othersspecified by format attributes, in the "printf", "scanf", "strftime" and "strfmon" (an X/Open extension, not in the C standard)families (or other target-specific families). Which functions are checked without format attributes having been specifieddepends on the standard version selected, and such checks of functions without the attribute specified are disabled by
gcc -Wformat ...
-Wno-format-contains-nul
If -Wformat is specified, do not warn about format strings that contain NUL bytes.
gcc -Wno-format-contains-nul ...
-Wno-format-extra-args
If -Wformat is specified, do not warn about excess arguments to a "printf" or "scanf" format function. The C standardspecifies that such arguments are ignored.Where the unused arguments lie between used arguments that are specified with $ operand number specifications, normallywarnings are still given, since the implementation could not know what type to pass to "va_arg" to skip the unused arguments.However, in the case of "scanf" formats, this option suppresses the warning if the unused arguments are all pointers, sincethe Single Unix Specification says that such unused arguments are allowed.
gcc -Wno-format-extra-args ...
-Wformat-overflow
Warn about calls to formatted input/output functions such as "sprintf" and "vsprintf" that might overflow the destinationbuffer. When the exact number of bytes written by a format directive cannot be determined at compile-time it is estimatedbased on heuristics that depend on the level argument and on optimization. While enabling optimization will in most casesimprove the accuracy of the warning, it may also result in false positives.
gcc -Wformat-overflow ...
-Wno-format-zero-length
If -Wformat is specified, do not warn about zero-length formats. The C standard specifies that zero-length formats areallowed.
gcc -Wno-format-zero-length ...
-Wformat-nonliteral
If -Wformat is specified, also warn if the format string is not a string literal and so cannot be checked, unless the formatfunction takes its format arguments as a "va_list".
gcc -Wformat-nonliteral ...
-Wformat-signedness
If -Wformat is specified, also warn if the format string requires an unsigned argument and the argument is signed and viceversa.
gcc -Wformat-signedness ...
-Wformat-truncation
Warn about calls to formatted input/output functions such as "snprintf" and "vsnprintf" that might result in outputtruncation. When the exact number of bytes written by a format directive cannot be determined at compile-time it isestimated based on heuristics that depend on the level argument and on optimization. While enabling optimization will inmost cases improve the accuracy of the warning, it may also result in false positives. Except as noted otherwise, the optionuses the same logic -Wformat-overflow.
gcc -Wformat-truncation ...
-Wno-format-security
or disable all format warnings with -Wformat=0. To make format security warnings fatal specify
gcc -Wno-format-security ...
-Wformat-y2k
If -Wformat is specified, also warn about "strftime" formats that may yield only a two-digit year.
gcc -Wformat-y2k ...
-Wnonnull
Warn about passing a null pointer for arguments marked as requiring a non-null value by the "nonnull" function attribute.
gcc -Wnonnull ...
-Wnonnull-compare
Warn when comparing an argument marked with the "nonnull" function attribute against null inside the function.
gcc -Wnonnull-compare ...
-Wnull-dereference
Warn if the compiler detects paths that trigger erroneous or undefined behavior due to dereferencing a null pointer. This optionis only active when -fdelete-null-pointer-checks is active, which is enabled by optimizations in most targets. The precision ofthe warnings depends on the optimization options used.
gcc -Wnull-dereference ...
-Winit-self
Warn about uninitialized variables that are initialized with themselves. Note this option can only be used with the
gcc -Winit-self ...
-Wuninitialized
For example, GCC warns about "i" being uninitialized in the following snippet only when -Winit-self has been specified:int f(){int i = i;return i;}This warning is enabled by -Wall in C++.
gcc -Wuninitialized ...
-Wimplicit-int
Warn when a declaration does not specify a type. This warning is enabled by -Wall.
gcc -Wimplicit-int ...
-Wimplicit-function-declaration
Give a warning whenever a function is used before being declared. In C99 mode (-std=c99 or -std=gnu99), this warning is enabledby default and it is made into an error by -pedantic-errors. This warning is also enabled by -Wall.
gcc -Wimplicit-function-declaration ...
-Wimplicit
Same as -Wimplicit-int and -Wimplicit-function-declaration. This warning is enabled by -Wall.
gcc -Wimplicit ...
-Wignored-qualifiers
Warn if the return type of a function has a type qualifier such as "const". For ISO C such a type qualifier has no effect, sincethe value returned by a function is not an lvalue. For C++, the warning is only emitted for scalar types or "void". ISO Cprohibits qualified "void" return types on function definitions, so such return types always receive a warning even without thisoption.This warning is also enabled by -Wextra.
gcc -Wignored-qualifiers ...
-Wignored-attributes
Warn when an attribute is ignored. This is different from the -Wattributes option in that it warns whenever the compiler decidesto drop an attribute, not that the attribute is either unknown, used in a wrong place, etc. This warning is enabled by default.
gcc -Wignored-attributes ...
-Wmain
Warn if the type of "main" is suspicious. "main" should be a function with external linkage, returning int, taking either zeroarguments, two, or three arguments of appropriate types. This warning is enabled by default in C++ and is enabled by either
gcc -Wmain ...
-Wmisleading-indentation
Warn when the indentation of the code does not reflect the block structure. Specifically, a warning is issued for "if", "else","while", and "for" clauses with a guarded statement that does not use braces, followed by an unguarded statement with the sameindentation.In the following example, the call to "bar" is misleadingly indented as if it were guarded by the "if" conditional.if (some_condition ())foo ();bar (); /* Gotcha: this is not guarded by the "if". */In the case of mixed tabs and spaces, the warning uses the -ftabstop= option to determine if the statements line up (defaultingto 8).The warning is not issued for code involving multiline preprocessor logic such as the following example.if (flagA)foo (0);#if SOME_CONDITION_THAT_DOES_NOT_HOLDif (flagB)#endiffoo (1);The warning is not issued after a "#line" directive, since this typically indicates autogenerated code, and no assumptions can bemade about the layout of the file that the directive references.This warning is enabled by -Wall in C and C++.
gcc -Wmisleading-indentation ...
-Wmissing-braces
Warn if an aggregate or union initializer is not fully bracketed. In the following example, the initializer for "a" is not fullybracketed, but that for "b" is fully bracketed. This warning is enabled by -Wall in C.int a[2][2] = { 0, 1, 2, 3 };int b[2][2] = { { 0, 1 }, { 2, 3 } };This warning is enabled by -Wall.
gcc -Wmissing-braces ...
-Wmissing-include-dirs
Warn if a user-supplied include directory does not exist.
gcc -Wmissing-include-dirs ...
-Wparentheses
Warn if parentheses are omitted in certain contexts, such as when there is an assignment in a context where a truth value isexpected, or when operators are nested whose precedence people often get confused about.Also warn if a comparison like "x<=y<=z" appears; this is equivalent to "(x<=y ? 1 : 0) <= z", which is a differentinterpretation from that of ordinary mathematical notation.Also warn for dangerous uses of the GNU extension to "?:" with omitted middle operand. When the condition in the "?": operator isa boolean expression, the omitted value is always 1. Often programmers expect it to be a value computed inside the conditionalexpression instead.This warning is enabled by -Wall.
gcc -Wparentheses ...
-Wsequence-point
Warn about code that may have undefined semantics because of violations of sequence point rules in the C and C++ standards.The C and C++ standards define the order in which expressions in a C/C++ program are evaluated in terms of sequence points, whichrepresent a partial ordering between the execution of parts of the program: those executed before the sequence point, and thoseexecuted after it. These occur after the evaluation of a full expression (one which is not part of a larger expression), afterthe evaluation of the first operand of a "&&", "||", "? :" or "," (comma) operator, before a function is called (but after theevaluation of its arguments and the expression denoting the called function), and in certain other places. Other than asexpressed by the sequence point rules, the order of evaluation of subexpressions of an expression is not specified. All theserules describe only a partial order rather than a total order, since, for example, if two functions are called within oneexpression with no sequence point between them, the order in which the functions are called is not specified. However, thestandards committee have ruled that function calls do not overlap.It is not specified when between sequence points modifications to the values of objects take effect. Programs whose behaviordepends on this have undefined behavior; the C and C++ standards specify that "Between the previous and next sequence point anobject shall have its stored value modified at most once by the evaluation of an expression. Furthermore, the prior value shallbe read only to determine the value to be stored.". If a program breaks these rules, the results on any particularimplementation are entirely unpredictable.Examples of code with undefined behavior are "a = a++;", "a[n] = b[n++]" and "a[i++] = i;". Some more complicated cases are notdiagnosed by this option, and it may give an occasional false positive result, but in general it has been found fairly effectiveat detecting this sort of problem in programs.The C++17 standard will define the order of evaluation of operands in more cases: in particular it requires that the right-handside of an assignment be evaluated before the left-hand side, so the above examples are no longer undefined. But this warningwill still warn about them, to help people avoid writing code that is undefined in C and earlier revisions of C++.The standard is worded confusingly, therefore there is some debate over the precise meaning of the sequence point rules in subtlecases. Links to discussions of the problem, including proposed formal definitions, may be found on the GCC readings page, at<http://gcc.gnu.org/readings.html>.This warning is enabled by -Wall for C and C++.
gcc -Wsequence-point ...
-Wno-return-local-addr
Do not warn about returning a pointer (or in C++, a reference) to a variable that goes out of scope after the function returns.
gcc -Wno-return-local-addr ...
-Wshift-count-negative
Warn if shift count is negative. This warning is enabled by default.
gcc -Wshift-count-negative ...
-Wshift-overflow
Warn about left shift overflows. This warning is enabled by default in C99 and C++11 modes (and newer).
gcc -Wshift-overflow ...
-Wswitch-default
Warn whenever a "switch" statement does not have a "default" case.
gcc -Wswitch-default ...
-Wswitch-enum
Warn whenever a "switch" statement has an index of enumerated type and lacks a "case" for one or more of the named codes of thatenumeration. "case" labels outside the enumeration range also provoke warnings when this option is used. The only differencebetween -Wswitch and this option is that this option gives a warning about an omitted enumeration code even if there is a"default" label.
gcc -Wswitch-enum ...
-Wswitch-unreachable
Warn whenever a "switch" statement contains statements between the controlling expression and the first case label, which willnever be executed. For example:switch (cond){i = 15;...case 5:...}
gcc -Wswitch-unreachable ...
-Wsync-nand
Warn when "__sync_fetch_and_nand" and "__sync_nand_and_fetch" built-in functions are used. These functions changed semantics inGCC 4.4.
gcc -Wsync-nand ...
-Wunused-but-set-variable
Warn whenever a local variable is assigned to, but otherwise unused (aside from its declaration). This warning is enabled by
gcc -Wunused-but-set-variable ...
-Wall.
To suppress this warning use the "unused" attribute.This warning is also enabled by -Wunused, which is enabled by -Wall.
gcc -Wall. ...
-Wunused-function
Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabledby -Wall.
gcc -Wunused-function ...
-Wunused-label
Warn whenever a label is declared but not used. This warning is enabled by -Wall.To suppress this warning use the "unused" attribute.
gcc -Wunused-label ...
-Wunused-local-typedefs
Warn when a typedef locally defined in a function is not used. This warning is enabled by -Wall.
gcc -Wunused-local-typedefs ...
-Wno-unused-result
Do not warn if a caller of a function marked with attribute "warn_unused_result" does not use its return value. The default is
gcc -Wno-unused-result ...
-Wunused-const-variable
Warn whenever a constant static variable is unused aside from its declaration. -Wunused-const-variable=1 is enabled by
gcc -Wunused-const-variable ...
-Wunused-value
Warn whenever a statement computes a result that is explicitly not used. To suppress this warning cast the unused expression to"void". This includes an expression-statement or the left-hand side of a comma expression that contains no side effects. Forexample, an expression such as "x[i,j]" causes a warning, while "x[(void)i,j]" does not.This warning is enabled by -Wall.
gcc -Wunused-value ...
-Wunused
All the above -Wunused options combined.In order to get a warning about an unused function parameter, you must either specify -Wextra -Wunused (note that -Wall implies
gcc -Wunused ...
-Wunused)
or separately specify -Wunused-parameter.
gcc -Wunused) ...
-Winvalid-memory-model
Warn for invocations of __atomic Builtins, __sync Builtins, and the C11 atomic generic functions with a memory consistencyargument that is either invalid for the operation or outside the range of values of the "memory_order" enumeration. For example,since the "__atomic_store" and "__atomic_store_n" built-ins are only defined for the relaxed, release, and sequentiallyconsistent memory orders the following code is diagnosed:void store (int *i){__atomic_store_n (i, 0, memory_order_consume);}
gcc -Winvalid-memory-model ...
-Wunknown-pragmas
Warn when a "#pragma" directive is encountered that is not understood by GCC. If this command-line option is used, warnings areeven issued for unknown pragmas in system header files. This is not the case if the warnings are only enabled by the -Wallcommand-line option.
gcc -Wunknown-pragmas ...
-Wstrict-aliasing
This option is only active when -fstrict-aliasing is active. It warns about code that might break the strict aliasing rules thatthe compiler is using for optimization. The warning does not catch all cases, but does attempt to catch the more commonpitfalls. It is included in -Wall. It is equivalent to -Wstrict-aliasing=3
gcc -Wstrict-aliasing ...
-Wstringop-overflow
Warn for calls to string manipulation functions such as "memcpy" and "strcpy" that are determined to overflow the destinationbuffer. The optional argument is one greater than the type of Object Size Checking to perform to determine the size of thedestination. The argument is meaningful only for functions that operate on character arrays but not for raw memory functionslike "memcpy" which always make use of Object Size type-0. The option also warns for calls that specify a size in excess of thelargest possible object or at most "SIZE_MAX / 2" bytes. The option produces the best results with optimization enabled but candetect a small subset of simple buffer overflows even without optimization in calls to the GCC built-in functions like"__builtin_memcpy" that correspond to the standard functions. In any case, the option warns about just a subset of bufferoverflows detected by the corresponding overflow checking built-ins. For example, the option will issue a warning for the"strcpy" call below because it copies at least 5 characters (the string "blue" including the terminating NUL) into the buffer ofsize 4.enum Color { blue, purple, yellow };const char* f (enum Color clr){static char buf [4];const char *str;switch (clr){case blue: str = "blue"; break;case purple: str = "purple"; break;case yellow: str = "yellow"; break;}return strcpy (buf, str); // warning here}Option -Wstringop-overflow=2 is enabled by default.
gcc -Wstringop-overflow ...
-Wsuggest-attribute
Warn for cases where adding an attribute may be beneficial. The attributes currently supported are listed below.
gcc -Wsuggest-attribute ...
-Wmissing-format-attribute
Warn about function pointers that might be candidates for "format" attributes. Note these are only possible candidates, notabsolute ones. GCC guesses that function pointers with "format" attributes that are used in assignment, initialization,parameter passing or return statements should have a corresponding "format" attribute in the resulting type. I.e. the left-hand side of the assignment or initialization, the type of the parameter variable, or the return type of the containingfunction respectively should also have a "format" attribute to avoid the warning.GCC also warns about function definitions that might be candidates for "format" attributes. Again, these are only possiblecandidates. GCC guesses that "format" attributes might be appropriate for any function that calls a function like "vprintf"or "vscanf", but this might not always be the case, and some functions for which "format" attributes are appropriate may notbe detected.
gcc -Wmissing-format-attribute ...
-Wsuggest-final-methods
Warn about virtual methods where code quality would be improved if the method were declared with the C++11 "final" specifier, or,if possible, its type were declared in an anonymous namespace or with the "final" specifier. This warning is more effective withlink-time optimization, where the information about the class hierarchy graph is more complete. It is recommended to firstconsider suggestions of -Wsuggest-final-types and then rebuild with new annotations.
gcc -Wsuggest-final-methods ...
-Wsuggest-override
Warn about overriding virtual functions that are not marked with the override keyword.
gcc -Wsuggest-override ...
-Walloc-zero
Warn about calls to allocation functions decorated with attribute "alloc_size" that specify zero bytes, including those to thebuilt-in forms of the functions "aligned_alloc", "alloca", "calloc", "malloc", and "realloc". Because the behavior of thesefunctions when called with a zero size differs among implementations (and in the case of "realloc" has been deprecated) relyingon it may result in subtle portability bugs and should be avoided.
gcc -Walloc-zero ...
-Walloca
This option warns on all uses of "alloca" in the source.
gcc -Walloca ...
-Walloca-larger-than
This option warns on calls to "alloca" that are not bounded by a controlling predicate limiting its argument of integer type toat most n bytes, or calls to "alloca" where the bound is unknown. Arguments of non-integer types are considered unbounded evenif they appear to be constrained to the expected range.For example, a bounded case of "alloca" could be:void func (size_t n){void *p;if (n <= 1000)p = alloca (n);elsep = malloc (n);f (p);}In the above example, passing "-Walloca-larger-than=1000" would not issue a warning because the call to "alloca" is known to beat most 1000 bytes. However, if "-Walloca-larger-than=500" were passed, the compiler would emit a warning.Unbounded uses, on the other hand, are uses of "alloca" with no controlling predicate constraining its integer argument. Forexample:void func (){void *p = alloca (n);f (p);}If "-Walloca-larger-than=500" were passed, the above would trigger a warning, but this time because of the lack of boundschecking.Note, that even seemingly correct code involving signed integers could cause a warning:void func (signed int n){if (n < 500){p = alloca (n);f (p);}}In the above example, n could be negative, causing a larger than expected argument to be implicitly cast into the "alloca" call.This option also warns when "alloca" is used in a loop.This warning is not enabled by -Wall, and is only active when -ftree-vrp is active (default for -O2 and above).See also -Wvla-larger-than=n.
gcc -Walloca-larger-than ...
-Warray-bounds
This option is only active when -ftree-vrp is active (default for -O2 and above). It warns about subscripts to arrays that arealways out of bounds. This warning is enabled by -Wall.
gcc -Warray-bounds ...
-Wbool-compare
Warn about boolean expression compared with an integer value different from "true"/"false". For instance, the followingcomparison is always false:int n = 5;...if ((n > 1) == 2) { ... }This warning is enabled by -Wall.
gcc -Wbool-compare ...
-Wbool-operation
Warn about suspicious operations on expressions of a boolean type. For instance, bitwise negation of a boolean is very likely abug in the program. For C, this warning also warns about incrementing or decrementing a boolean, which rarely makes sense. (InC++, decrementing a boolean is always invalid. Incrementing a boolean is invalid in C++1z, and deprecated otherwise.)This warning is enabled by -Wall.
gcc -Wbool-operation ...
-Wduplicated-branches
Warn when an if-else has identical branches. This warning detects cases likeif (p != NULL)return 0;elsereturn 0;It doesn't warn when both branches contain just a null statement. This warning also warn for conditional operators:int i = x ? *p : *p;
gcc -Wduplicated-branches ...
-Wframe-address
Warn when the __builtin_frame_address or __builtin_return_address is called with an argument greater than 0. Such calls mayreturn indeterminate values or crash the program. The warning is included in -Wall.
gcc -Wframe-address ...
-Wno-discarded-array-qualifiers
Do not warn if type qualifiers on arrays which are pointer targets are being discarded. Typically, the compiler warns if a "constint (*)[]" variable is passed to a function that takes a "int (*)[]" parameter. This option can be used to suppress such awarning.
gcc -Wno-discarded-array-qualifiers ...
-Wno-incompatible-pointer-types
Do not warn when there is a conversion between pointers that have incompatible types. This warning is for cases not covered by
gcc -Wno-incompatible-pointer-types ...
-Wno-pointer-sign
which warns for pointer argument passing or assignment with different signedness.
gcc -Wno-pointer-sign ...
-Wno-div-by-zero
Do not warn about compile-time integer division by zero. Floating-point division by zero is not warned about, as it can be alegitimate way of obtaining infinities and NaNs.
gcc -Wno-div-by-zero ...
-Wsystem-headers
Print warning messages for constructs found in system header files. Warnings from system headers are normally suppressed, on theassumption that they usually do not indicate real problems and would only make the compiler output harder to read. Using thiscommand-line option tells GCC to emit warnings from system headers as if they occurred in user code. However, note that using
gcc -Wsystem-headers ...
-Wtautological-compare
Warn if a self-comparison always evaluates to true or false. This warning detects various mistakes such as:int i = 1;...if (i > i) { ... }This warning is enabled by -Wall.
gcc -Wtautological-compare ...
-Wtraditional
Warn about certain constructs that behave differently in traditional and ISO C. Also warn about ISO C constructs that have notraditional C equivalent, and/or problematic constructs that should be avoided.* Macro parameters that appear within string literals in the macro body. In traditional C macro replacement takes place withinstring literals, but in ISO C it does not.* In traditional C, some preprocessor directives did not exist. Traditional preprocessors only considered a line to be adirective if the # appeared in column 1 on the line. Therefore -Wtraditional warns about directives that traditional Cunderstands but ignores because the # does not appear as the first character on the line. It also suggests you hidedirectives like "#pragma" not understood by traditional C by indenting them. Some traditional implementations do notrecognize "#elif", so this option suggests avoiding it altogether.* A function-like macro that appears without arguments.* The unary plus operator.* The U integer constant suffix, or the F or L floating-point constant suffixes. (Traditional C does support the L suffix oninteger constants.) Note, these suffixes appear in macros defined in the system headers of most modern systems, e.g. the_MIN/_MAX macros in "<limits.h>". Use of these macros in user code might normally lead to spurious warnings, however GCC'sintegrated preprocessor has enough context to avoid warning in these cases.* A function declared external in one block and then used after the end of the block.* A "switch" statement has an operand of type "long".* A non-"static" function declaration follows a "static" one. This construct is not accepted by some traditional C compilers.* The ISO type of an integer constant has a different width or signedness from its traditional type. This warning is onlyissued if the base of the constant is ten. I.e. hexadecimal or octal values, which typically represent bit patterns, are notwarned about.* Usage of ISO string concatenation is detected.* Initialization of automatic aggregates.* Identifier conflicts with labels. Traditional C lacks a separate namespace for labels.* Initialization of unions. If the initializer is zero, the warning is omitted. This is done under the assumption that thezero initializer in user code appears conditioned on e.g. "__STDC__" to avoid missing initializer warnings and relies ondefault initialization to zero in the traditional C case.* Conversions by prototypes between fixed/floating-point values and vice versa. The absence of these prototypes when compilingwith traditional C causes serious problems. This is a subset of the possible conversion warnings; for the full set use
gcc -Wtraditional ...
-Wtraditional-conversion.
* Use of ISO C style function definitions. This warning intentionally is not issued for prototype declarations or variadicfunctions because these ISO C features appear in your code when using libiberty's traditional C compatibility macros,"PARAMS" and "VPARAMS". This warning is also bypassed for nested functions because that feature is already a GCC extensionand thus not relevant to traditional C compatibility.
gcc -Wtraditional-conversion. ...
-Wtraditional-conversion
Warn if a prototype causes a type conversion that is different from what would happen to the same argument in the absence of aprototype. This includes conversions of fixed point to floating and vice versa, and conversions changing the width or signednessof a fixed-point argument except when the same as the default promotion.
gcc -Wtraditional-conversion ...
-Wno-shadow-ivar
Do not warn whenever a local variable shadows an instance variable in an Objective-C method.
gcc -Wno-shadow-ivar ...
-Wframe-larger-than
Warn if the size of a function frame is larger than len bytes. The computation done to determine the stack frame size isapproximate and not conservative. The actual requirements may be somewhat greater than len even if you do not get a warning. Inaddition, any space allocated via "alloca", variable-length arrays, or related constructs is not included by the compiler whendetermining whether or not to issue a warning.
gcc -Wframe-larger-than ...
-Wstack-usage
Warn if the stack usage of a function might be larger than len bytes. The computation done to determine the stack usage isconservative. Any space allocated via "alloca", variable-length arrays, or related constructs is included by the compiler whendetermining whether or not to issue a warning.The message is in keeping with the output of -fstack-usage.* If the stack usage is fully static but exceeds the specified amount, it's:warning: stack usage is 1120 bytes* If the stack usage is (partly) dynamic but bounded, it's:warning: stack usage might be 1648 bytes* If the stack usage is (partly) dynamic and not bounded, it's:warning: stack usage might be unbounded
gcc -Wstack-usage ...
-Wunsafe-loop-optimizations
Warn if the loop cannot be optimized because the compiler cannot assume anything on the bounds of the loop indices. With
gcc -Wunsafe-loop-optimizations ...
-funsafe-loop-optimizations
warn if the compiler makes such assumptions.
gcc -funsafe-loop-optimizations ...
-Waligned-new
Warn about a new-expression of a type that requires greater alignment than the "alignof(std::max_align_t)" but uses an allocationfunction without an explicit alignment parameter. This option is enabled by -Wall.Normally this only warns about global allocation functions, but -Waligned-new=all also warns about class member allocationfunctions.
gcc -Waligned-new ...
-Wplacement-new
Warn about placement new expressions with undefined behavior, such as constructing an object in a buffer that is smaller than thetype of the object. For example, the placement new expression below is diagnosed because it attempts to construct an array of 64integers in a buffer only 64 bytes large.char buf [64];new (buf) int[64];This warning is enabled by default.
gcc -Wplacement-new ...
-Wpointer-arith
Warn about anything that depends on the "size of" a function type or of "void". GNU C assigns these types a size of 1, forconvenience in calculations with "void *" pointers and pointers to functions. In C++, warn also when an arithmetic operationinvolves "NULL". This warning is also enabled by -Wpedantic.
gcc -Wpointer-arith ...
-Wpointer-compare
Warn if a pointer is compared with a zero character constant. This usually means that the pointer was meant to be dereferenced.For example:const char *p = foo ();if (p == '\0')return 42;Note that the code above is invalid in C++11.This warning is enabled by default.
gcc -Wpointer-compare ...
-Wtype-limits
Warn if a comparison is always true or always false due to the limited range of the data type, but do not warn for constantexpressions. For example, warn if an unsigned variable is compared against zero with "<" or ">=". This warning is also enabledby -Wextra.
gcc -Wtype-limits ...
-Wcomments
Warn whenever a comment-start sequence /* appears in a /* comment, or whenever a backslash-newline appears in a // comment. Thiswarning is enabled by -Wall.
gcc -Wcomments ...
-Wtrigraphs
Warn if any trigraphs are encountered that might change the meaning of the program. Trigraphs within comments are not warnedabout, except those that would form escaped newlines.This option is implied by -Wall. If -Wall is not given, this option is still enabled unless trigraphs are enabled. To gettrigraph conversion without warnings, but get the other -Wall warnings, use -trigraphs -Wall -Wno-trigraphs.
gcc -Wtrigraphs ...
-Wundef
Warn if an undefined identifier is evaluated in an "#if" directive. Such identifiers are replaced with zero.
gcc -Wundef ...
-Wexpansion-to-defined
Warn whenever defined is encountered in the expansion of a macro (including the case where the macro is expanded by an #ifdirective). Such usage is not portable. This warning is also enabled by -Wpedantic and -Wextra.
gcc -Wexpansion-to-defined ...
-Wunused-macros
Warn about macros defined in the main file that are unused. A macro is used if it is expanded or tested for existence at leastonce. The preprocessor also warns if the macro has not been used at the time it is redefined or undefined.Built-in macros, macros defined on the command line, and macros defined in include files are not warned about.Note: If a macro is actually used, but only used in skipped conditional blocks, then the preprocessor reports it as unused. Toavoid the warning in such a case, you might improve the scope of the macro's definition by, for example, moving it into the firstskipped block. Alternatively, you could provide a dummy use with something like:#if defined the_macro_causing_the_warning#endif
gcc -Wunused-macros ...
-Wno-endif-labels
Do not warn whenever an "#else" or an "#endif" are followed by text. This sometimes happens in older programs with code of theform#if FOO...#else FOO...#endif FOOThe second and third "FOO" should be in comments. This warning is on by default.
gcc -Wno-endif-labels ...
-Wc99-c11-compat
Warn about features not present in ISO C99, but present in ISO C11. For instance, warn about use of anonymous structures andunions, "_Atomic" type qualifier, "_Thread_local" storage-class specifier, "_Alignas" specifier, "Alignof" operator, "_Generic"keyword, and so on. This option is independent of the standards mode. Warnings are disabled in the expression that follows"__extension__".
gcc -Wc99-c11-compat ...
-Wc++-compat
Warn about ISO C constructs that are outside of the common subset of ISO C and ISO C++, e.g. request for implicit conversion from"void *" to a pointer to non-"void" type.
gcc -Wc++-compat ...
-Wc++11-compat
Warn about C++ constructs whose meaning differs between ISO C++ 1998 and ISO C++ 2011, e.g., identifiers in ISO C++ 1998 that arekeywords in ISO C++ 2011. This warning turns on -Wnarrowing and is enabled by -Wall.
gcc -Wc++11-compat ...
-Wc++14-compat
Warn about C++ constructs whose meaning differs between ISO C++ 2011 and ISO C++ 2014. This warning is enabled by -Wall.
gcc -Wc++14-compat ...
-Wc++1z-compat
Warn about C++ constructs whose meaning differs between ISO C++ 2014 and the forthoming ISO C++ 2017(?). This warning is enabledby -Wall.
gcc -Wc++1z-compat ...
-Wcast-qual
Warn whenever a pointer is cast so as to remove a type qualifier from the target type. For example, warn if a "const char *" iscast to an ordinary "char *".Also warn when making a cast that introduces a type qualifier in an unsafe way. For example, casting "char **" to "const char**" is unsafe, as in this example:/* p is char ** value. */const char **q = (const char **) p;/* Assignment of readonly string to const char * is OK. */*q = "string";/* Now char** pointer points to read-only memory. */**p = 'b';
gcc -Wcast-qual ...
-Wcast-align
Warn whenever a pointer is cast such that the required alignment of the target is increased. For example, warn if a "char *" iscast to an "int *" on machines where integers can only be accessed at two- or four-byte boundaries.
gcc -Wcast-align ...
-Wwrite-strings
When compiling C, give string constants the type "const char[length]" so that copying the address of one into a non-"const" "char*" pointer produces a warning. These warnings help you find at compile time code that can try to write into a string constant,but only if you have been very careful about using "const" in declarations and prototypes. Otherwise, it is just a nuisance.This is why we did not make -Wall request these warnings.When compiling C++, warn about the deprecated conversion from string literals to "char *". This warning is enabled by defaultfor C++ programs.
gcc -Wwrite-strings ...
-Wconditionally-supported
Warn for conditionally-supported (C++11 [intro.defs]) constructs.
gcc -Wconditionally-supported ...
-Wconversion
Warn for implicit conversions that may alter a value. This includes conversions between real and integer, like "abs (x)" when "x"is "double"; conversions between signed and unsigned, like "unsigned ui = -1"; and conversions to smaller types, like "sqrtf(M_PI)". Do not warn for explicit casts like "abs ((int) x)" and "ui = (unsigned) -1", or if the value is not changed by theconversion like in "abs (2.0)". Warnings about conversions between signed and unsigned integers can be disabled by using
gcc -Wconversion ...
-Wno-sign-conversion.
For C++, also warn for confusing overload resolution for user-defined conversions; and conversions that never use a typeconversion operator: conversions to "void", the same type, a base class or a reference to them. Warnings about conversionsbetween signed and unsigned integers are disabled by default in C++ unless -Wsign-conversion is explicitly enabled.
gcc -Wno-sign-conversion. ...
-Wno-conversion-null
Do not warn for conversions between "NULL" and non-pointer types. -Wconversion-null is enabled by default.
gcc -Wno-conversion-null ...
-Wzero-as-null-pointer-constant
Warn when a literal 0 is used as null pointer constant. This can be useful to facilitate the conversion to "nullptr" in C++11.
gcc -Wzero-as-null-pointer-constant ...
-Wsubobject-linkage
Warn if a class type has a base or a field whose type uses the anonymous namespace or depends on a type with no linkage. If atype A depends on a type B with no or internal linkage, defining it in multiple translation units would be an ODR violationbecause the meaning of B is different in each translation unit. If A only appears in a single translation unit, the best way tosilence the warning is to give it internal linkage by putting it in an anonymous namespace as well. The compiler doesn't givethis warning for types defined in the main .C file, as those are unlikely to have multiple definitions. -Wsubobject-linkage isenabled by default.
gcc -Wsubobject-linkage ...
-Wdangling-else
Warn about constructions where there may be confusion to which "if" statement an "else" branch belongs. Here is an example ofsuch a case:{if (a)if (b)foo ();elsebar ();}In C/C++, every "else" branch belongs to the innermost possible "if" statement, which in this example is "if (b)". This is oftennot what the programmer expected, as illustrated in the above example by indentation the programmer chose. When there is thepotential for this confusion, GCC issues a warning when this flag is specified. To eliminate the warning, add explicit bracesaround the innermost "if" statement so there is no way the "else" can belong to the enclosing "if". The resulting code lookslike this:{if (a){if (b)foo ();elsebar ();}}This warning is enabled by -Wparentheses.
gcc -Wdangling-else ...
-Wdelete-incomplete
Warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime. This warning is enabled bydefault.
gcc -Wdelete-incomplete ...
-Wuseless-cast
Warn when an expression is casted to its own type.
gcc -Wuseless-cast ...
-Wempty-body
Warn if an empty body occurs in an "if", "else" or "do while" statement. This warning is also enabled by -Wextra.
gcc -Wempty-body ...
-Wenum-compare
Warn about a comparison between values of different enumerated types. In C++ enumerated type mismatches in conditionalexpressions are also diagnosed and the warning is enabled by default. In C this warning is enabled by -Wall.
gcc -Wenum-compare ...
-Wjump-misses-init
Warn if a "goto" statement or a "switch" statement jumps forward across the initialization of a variable, or jumps backward to alabel after the variable has been initialized. This only warns about variables that are initialized when they are declared.This warning is only supported for C and Objective-C; in C++ this sort of branch is an error in any case.
gcc -Wjump-misses-init ...
-Wsign-compare
Warn when a comparison between signed and unsigned values could produce an incorrect result when the signed value is converted tounsigned. In C++, this warning is also enabled by -Wall. In C, it is also enabled by -Wextra.
gcc -Wsign-compare ...
-Wsign-conversion
Warn for implicit conversions that may change the sign of an integer value, like assigning a signed integer expression to anunsigned integer variable. An explicit cast silences the warning. In C, this option is enabled also by -Wconversion.
gcc -Wsign-conversion ...
-Wfloat-conversion
Warn for implicit conversions that reduce the precision of a real value. This includes conversions from real to integer, andfrom higher precision real to lower precision real values. This option is also enabled by -Wconversion.
gcc -Wfloat-conversion ...
-Wno-scalar-storage-order
Do not warn on suspicious constructs involving reverse scalar storage order.
gcc -Wno-scalar-storage-order ...
-Wsized-deallocation
Warn about a definition of an unsized deallocation functionvoid operator delete (void *) noexcept;void operator delete[] (void *) noexcept;without a definition of the corresponding sized deallocation functionvoid operator delete (void *, std::size_t) noexcept;void operator delete[] (void *, std::size_t) noexcept;or vice versa. Enabled by -Wextra along with -fsized-deallocation.
gcc -Wsized-deallocation ...
-Wsizeof-array-argument
Warn when the "sizeof" operator is applied to a parameter that is declared as an array in a function definition. This warning isenabled by default for C and C++ programs.
gcc -Wsizeof-array-argument ...
-Wmemset-elt-size
Warn for suspicious calls to the "memset" built-in function, if the first argument references an array, and the third argument isa number equal to the number of elements, but not equal to the size of the array in memory. This indicates that the user hasomitted a multiplication by the element size. This warning is enabled by -Wall.
gcc -Wmemset-elt-size ...
-Wlogical-op
Warn about suspicious uses of logical operators in expressions. This includes using logical operators in contexts where a bit-wise operator is likely to be expected. Also warns when the operands of a logical operator are the same:extern int a;if (a < 0 && a < 0) { ... }
gcc -Wlogical-op ...
-Wlogical-not-parentheses
Warn about logical not used on the left hand side operand of a comparison. This option does not warn if the right operand isconsidered to be a boolean expression. Its purpose is to detect suspicious code like the following:int a;...if (!a > 1) { ... }It is possible to suppress the warning by wrapping the LHS into parentheses:if ((!a) > 1) { ... }This warning is enabled by -Wall.
gcc -Wlogical-not-parentheses ...
-Waggregate-return
Warn if any functions that return structures or unions are defined or called. (In languages where you can return an array, thisalso elicits a warning.)
gcc -Waggregate-return ...
-Wno-aggressive-loop-optimizations
Warn if in a loop with constant number of iterations the compiler detects undefined behavior in some statement during one or moreof the iterations.
gcc -Wno-aggressive-loop-optimizations ...
-Wno-builtin-declaration-mismatch
Warn if a built-in function is declared with the wrong signature. This warning is enabled by default.
gcc -Wno-builtin-declaration-mismatch ...
-Wno-builtin-macro-redefined
Do not warn if certain built-in macros are redefined. This suppresses warnings for redefinition of "__TIMESTAMP__", "__TIME__","__DATE__", "__FILE__", and "__BASE_FILE__".
gcc -Wno-builtin-macro-redefined ...
-Wstrict-prototypes
Warn if a function is declared or defined without specifying the argument types. (An old-style function definition is permittedwithout a warning if preceded by a declaration that specifies the argument types.)
gcc -Wstrict-prototypes ...
-Wold-style-definition
Warn if an old-style function definition is used. A warning is given even if there is a previous prototype.
gcc -Wold-style-definition ...
-Wmissing-parameter-type
A function parameter is declared without a type specifier in K&R-style functions:void foo(bar) { }This warning is also enabled by -Wextra.
gcc -Wmissing-parameter-type ...
-Wmissing-prototypes
Warn if a global function is defined without a previous prototype declaration. This warning is issued even if the definitionitself provides a prototype. Use this option to detect global functions that do not have a matching prototype declaration in aheader file. This option is not valid for C++ because all function declarations provide prototypes and a non-matchingdeclaration declares an overload rather than conflict with an earlier declaration. Use -Wmissing-declarations to detect missingdeclarations in C++.
gcc -Wmissing-prototypes ...
-Wmissing-declarations
Warn if a global function is defined without a previous declaration. Do so even if the definition itself provides a prototype.Use this option to detect global functions that are not declared in header files. In C, no warnings are issued for functionswith previous non-prototype declarations; use -Wmissing-prototypes to detect missing prototypes. In C++, no warnings are issuedfor function templates, or for inline functions, or for functions in anonymous namespaces.
gcc -Wmissing-declarations ...
-Wmissing-field-initializers
Warn if a structure's initializer has some fields missing. For example, the following code causes such a warning, because "x.h"is implicitly zero:struct s { int f, g, h; };struct s x = { 3, 4 };This option does not warn about designated initializers, so the following modification does not trigger a warning:struct s { int f, g, h; };struct s x = { .f = 3, .g = 4 };In C++ this option does not warn either about the empty { } initializer, for example:struct s { int f, g, h; };s x = { };This warning is included in -Wextra. To get other -Wextra warnings without this one, use -Wextra
gcc -Wmissing-field-initializers ...
-Wnormalized
In ISO C and ISO C++, two identifiers are different if they are different sequences of characters. However, sometimes whencharacters outside the basic ASCII character set are used, you can have two different character sequences that look the same. Toavoid confusion, the ISO 10646 standard sets out some normalization rules which when applied ensure that two sequences that lookthe same are turned into the same sequence. GCC can warn you if you are using identifiers that have not been normalized; thisoption controls that warning.There are four levels of warning supported by GCC. The default is -Wnormalized=nfc, which warns about any identifier that is notin the ISO 10646 "C" normalized form, NFC. NFC is the recommended form for most uses. It is equivalent to -Wnormalized.Unfortunately, there are some characters allowed in identifiers by ISO C and ISO C++ that, when turned into NFC, are not allowedin identifiers. That is, there's no way to use these symbols in portable ISO C or C++ and have all your identifiers in NFC.
gcc -Wnormalized ...
-Wno-deprecated
Do not warn about usage of deprecated features.
gcc -Wno-deprecated ...
-Wno-deprecated-declarations
Do not warn about uses of functions, variables, and types marked as deprecated by using the "deprecated" attribute.
gcc -Wno-deprecated-declarations ...
-Wno-overflow
Do not warn about compile-time overflow in constant expressions.
gcc -Wno-overflow ...
-Wno-odr
Warn about One Definition Rule violations during link-time optimization. Requires -flto-odr-type-merging to be enabled. Enabledby default.
gcc -Wno-odr ...
-fsimd-cost-model
option can be used to relax the cost model.
gcc -fsimd-cost-model ...
-Woverride-init
Warn if an initialized field without side effects is overridden when using designated initializers.This warning is included in -Wextra. To get other -Wextra warnings without this one, use -Wextra -Wno-override-init.
gcc -Woverride-init ...
-Woverride-init-side-effects
Warn if an initialized field with side effects is overridden when using designated initializers. This warning is enabled bydefault.
gcc -Woverride-init-side-effects ...
-Wpacked
Warn if a structure is given the packed attribute, but the packed attribute has no effect on the layout or size of the structure.Such structures may be mis-aligned for little benefit. For instance, in this code, the variable "f.x" in "struct bar" ismisaligned even though "struct bar" does not itself have the packed attribute:struct foo {int x;char a, b, c, d;} __attribute__((packed));struct bar {char z;struct foo f;};
gcc -Wpacked ...
-Wpacked-bitfield-compat
The 4.1, 4.2 and 4.3 series of GCC ignore the "packed" attribute on bit-fields of type "char". This has been fixed in GCC 4.4but the change can lead to differences in the structure layout. GCC informs you when the offset of such a field has changed inGCC 4.4. For example there is no longer a 4-bit padding between field "a" and "b" in this structure:struct foo{char a:4;char b:8;} __attribute__ ((packed));This warning is enabled by default. Use -Wno-packed-bitfield-compat to disable this warning.
gcc -Wpacked-bitfield-compat ...
-Wpadded
Warn if padding is included in a structure, either to align an element of the structure or to align the whole structure.Sometimes when this happens it is possible to rearrange the fields of the structure to reduce the padding and so make thestructure smaller.
gcc -Wpadded ...
-Wredundant-decls
Warn if anything is declared more than once in the same scope, even in cases where multiple declaration is valid and changesnothing.
gcc -Wredundant-decls ...
-Wrestrict
Warn when an argument passed to a restrict-qualified parameter aliases with another argument.
gcc -Wrestrict ...
-Wnested-externs
Warn if an "extern" declaration is encountered within a function.
gcc -Wnested-externs ...
-Wno-inherited-variadic-ctor
Suppress warnings about use of C++11 inheriting constructors when the base class inherited from has a C variadic constructor; thewarning is on by default because the ellipsis is not inherited.
gcc -Wno-inherited-variadic-ctor ...
-Winline
Warn if a function that is declared as inline cannot be inlined. Even with this option, the compiler does not warn aboutfailures to inline functions declared in system headers.The compiler uses a variety of heuristics to determine whether or not to inline a function. For example, the compiler takes intoaccount the size of the function being inlined and the amount of inlining that has already been done in the current function.Therefore, seemingly insignificant changes in the source program can cause the warnings produced by -Winline to appear ordisappear.
gcc -Winline ...
-Wno-invalid-offsetof
Suppress warnings from applying the "offsetof" macro to a non-POD type. According to the 2014 ISO C++ standard, applying"offsetof" to a non-standard-layout type is undefined. In existing C++ implementations, however, "offsetof" typically givesmeaningful results. This flag is for users who are aware that they are writing nonportable code and who have deliberately chosento ignore the warning about it.The restrictions on "offsetof" may be relaxed in a future version of the C++ standard.
gcc -Wno-invalid-offsetof ...
-Wno-int-to-pointer-cast
Suppress warnings from casts to pointer type of an integer of a different size. In C++, casting to a pointer type of smaller sizeis an error. Wint-to-pointer-cast is enabled by default.
gcc -Wno-int-to-pointer-cast ...
-Wno-pointer-to-int-cast
Suppress warnings from casts from a pointer to an integer type of a different size.
gcc -Wno-pointer-to-int-cast ...
-Winvalid-pch
Warn if a precompiled header is found in the search path but cannot be used.
gcc -Winvalid-pch ...
-Wlong-long
Warn if "long long" type is used. This is enabled by either -Wpedantic or -Wtraditional in ISO C90 and C++98 modes. To inhibitthe warning messages, use -Wno-long-long.
gcc -Wlong-long ...
-Wvariadic-macros
Warn if variadic macros are used in ISO C90 mode, or if the GNU alternate syntax is used in ISO C99 mode. This is enabled byeither -Wpedantic or -Wtraditional. To inhibit the warning messages, use -Wno-variadic-macros.
gcc -Wvariadic-macros ...
-Wvarargs
Warn upon questionable usage of the macros used to handle variable arguments like "va_start". This is default. To inhibit thewarning messages, use -Wno-varargs.
gcc -Wvarargs ...
-Wvector-operation-performance
Warn if vector operation is not implemented via SIMD capabilities of the architecture. Mainly useful for the performance tuning.Vector operation can be implemented "piecewise", which means that the scalar operation is performed on every vector element; "inparallel", which means that the vector operation is implemented using scalars of wider type, which normally is more performanceefficient; and "as a single scalar", which means that vector fits into a scalar type.
gcc -Wvector-operation-performance ...
-Wno-virtual-move-assign
Suppress warnings about inheriting from a virtual base with a non-trivial C++11 move assignment operator. This is dangerousbecause if the virtual base is reachable along more than one path, it is moved multiple times, which can mean both objects end upin the moved-from state. If the move assignment operator is written to avoid moving from a moved-from object, this warning canbe disabled.
gcc -Wno-virtual-move-assign ...
-Wvla
Warn if a variable-length array is used in the code. -Wno-vla prevents the -Wpedantic warning of the variable-length array.
gcc -Wvla ...
-Wvla-larger-than
If this option is used, the compiler will warn on uses of variable-length arrays where the size is either unbounded, or boundedby an argument that can be larger than n bytes. This is similar to how -Walloca-larger-than=n works, but with variable-lengtharrays.Note that GCC may optimize small variable-length arrays of a known value into plain arrays, so this warning may not get triggeredfor such arrays.This warning is not enabled by -Wall, and is only active when -ftree-vrp is active (default for -O2 and above).See also -Walloca-larger-than=n.
gcc -Wvla-larger-than ...
-Wvolatile-register-var
Warn if a register variable is declared volatile. The volatile modifier does not inhibit all optimizations that may eliminatereads and/or writes to register variables. This warning is enabled by -Wall.
gcc -Wvolatile-register-var ...
-Wdisabled-optimization
Warn if a requested optimization pass is disabled. This warning does not generally indicate that there is anything wrong withyour code; it merely indicates that GCC's optimizers are unable to handle the code effectively. Often, the problem is that yourcode is too big or too complex; GCC refuses to optimize programs when the optimization itself is likely to take inordinateamounts of time.
gcc -Wdisabled-optimization ...
-Wpointer-sign
Warn for pointer argument passing or assignment with different signedness. This option is only supported for C and Objective-C.It is implied by -Wall and by -Wpedantic, which can be disabled with -Wno-pointer-sign.
gcc -Wpointer-sign ...
-Wstack-protector
This option is only active when -fstack-protector is active. It warns about functions that are not protected against stacksmashing.
gcc -Wstack-protector ...
-Woverlength-strings
Warn about string constants that are longer than the "minimum maximum" length specified in the C standard. Modern compilersgenerally allow string constants that are much longer than the standard's minimum limit, but very portable programs should avoidusing longer strings.The limit applies after string constant concatenation, and does not count the trailing NUL. In C90, the limit was 509characters; in C99, it was raised to 4095. C++98 does not specify a normative minimum maximum, so we do not diagnose overlengthstrings in C++.This option is implied by -Wpedantic, and can be disabled with -Wno-overlength-strings.
gcc -Woverlength-strings ...
-Wno-designated-init
Suppress warnings when a positional initializer is used to initialize a structure that has been marked with the "designated_init"attribute.
gcc -Wno-designated-init ...
-Whsa
Issue a warning when HSAIL cannot be emitted for the compiled function or OpenMP construct.Options for Debugging Your ProgramTo tell GCC to emit extra information for use by a debugger, in almost all cases you need only to add -g to your other options.GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally be surprising: some variables you declaredmay not exist at all; flow of control may briefly move where you did not expect it; some statements may not be executed because theycompute constant results or their values are already at hand; some statements may execute in different places because they have beenmoved out of loops. Nevertheless it is possible to debug optimized output. This makes it reasonable to use the optimizer forprograms that might have bugs.If you are not using some other optimization option, consider using -Og with -g. With no -O option at all, some compiler passes thatcollect information useful for debugging do not run at all, so that -Og may result in a better debugging experience.
gcc -Whsa ...
-ggdb
Produce debugging information for use by GDB. This means to use the most expressive format available (DWARF, stabs, or thenative format if neither of those are supported), including GDB extensions if at all possible.
gcc -ggdb ...
-gdwarf-version
Produce debugging information in DWARF format (if that is supported). The value of version may be either 2, 3, 4 or 5; thedefault version for most targets is 4. DWARF Version 5 is only experimental.Note that with DWARF Version 2, some ports require and always use some non-conflicting DWARF 3 extensions in the unwind tables.Version 4 may require GDB 7.0 and -fvar-tracking-assignments for maximum benefit.GCC no longer supports DWARF Version 1, which is substantially different than Version 2 and later. For historical reasons, someother DWARF-related options (including -feliminate-dwarf2-dups and -fno-dwarf2-cfi-asm) retain a reference to DWARF Version 2 intheir names, but apply to all currently-supported versions of DWARF.
gcc -gdwarf-version ...
-gstabs
Produce debugging information in stabs format (if that is supported), without GDB extensions. This is the format used by DBX onmost BSD systems. On MIPS, Alpha and System V Release 4 systems this option produces stabs debugging output that is notunderstood by DBX or SDB. On System V Release 4 systems this option requires the GNU assembler.
gcc -gstabs ...
-gstabs+
Produce debugging information in stabs format (if that is supported), using GNU extensions understood only by the GNU debugger(GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program.
gcc -gstabs+ ...
-gcoff
Produce debugging information in COFF format (if that is supported). This is the format used by SDB on most System V systemsprior to System V Release 4.
gcc -gcoff ...
-gxcoff
Produce debugging information in XCOFF format (if that is supported). This is the format used by the DBX debugger on IBM RS/6000systems.
gcc -gxcoff ...
-gxcoff+
Produce debugging information in XCOFF format (if that is supported), using GNU extensions understood only by the GNU debugger(GDB). The use of these extensions is likely to make other debuggers crash or refuse to read the program, and may causeassemblers other than the GNU assembler (GAS) to fail with an error.
gcc -gxcoff+ ...
-gvms
Produce debugging information in Alpha/VMS debug format (if that is supported). This is the format used by DEBUG on Alpha/VMSsystems.
gcc -gvms ...
-gvmslevel
Request debugging information and also use level to specify how much information. The default level is 2.Level 0 produces no debug information at all. Thus, -g0 negates -g.Level 1 produces minimal information, enough for making backtraces in parts of the program that you don't plan to debug. Thisincludes descriptions of functions and external variables, and line number tables, but no information about local variables.Level 3 includes extra information, such as all the macro definitions present in the program. Some debuggers support macroexpansion when you use -g3.
gcc -gvmslevel ...
-feliminate-unused-debug-symbols
Produce debugging information in stabs format (if that is supported), for only symbols that are actually used.
gcc -feliminate-unused-debug-symbols ...
-femit-class-debug-always
Instead of emitting debugging information for a C++ class in only one object file, emit it in all object files using the class.This option should be used only with debuggers that are unable to handle the way GCC normally emits debugging information forclasses because using this option increases the size of debugging information by as much as a factor of two.
gcc -femit-class-debug-always ...
-fdebug-prefix-map
When compiling files in directory old, record debugging information describing them as in new instead.
gcc -fdebug-prefix-map ...
-fvar-tracking
Run variable tracking pass. It computes where variables are stored at each position in code. Better debugging information isthen generated (if the debugging information format supports this information).It is enabled by default when compiling with optimization (-Os, -O, -O2, ...), debugging information (-g) and the debug infoformat supports it.
gcc -fvar-tracking ...
-fvar-tracking-assignments
Annotate assignments to user variables early in the compilation and attempt to carry the annotations over throughout thecompilation all the way to the end, in an attempt to improve debug information while optimizing. Use of -gdwarf-4 is recommendedalong with it.It can be enabled even if var-tracking is disabled, in which case annotations are created and maintained, but discarded at theend. By default, this flag is enabled together with -fvar-tracking, except when selective scheduling is enabled.
gcc -fvar-tracking-assignments ...
-gsplit-dwarf
Separate as much DWARF debugging information as possible into a separate output file with the extension .dwo. This option allowsthe build system to avoid linking files with debug information. To be useful, this option requires a debugger capable of reading.dwo files.
gcc -gsplit-dwarf ...
-gpubnames
Generate DWARF ".debug_pubnames" and ".debug_pubtypes" sections.
gcc -gpubnames ...
-ggnu-pubnames
Generate ".debug_pubnames" and ".debug_pubtypes" sections in a format suitable for conversion into a GDB index. This option isonly useful with a linker that can produce GDB index version 7.
gcc -ggnu-pubnames ...
-gno-record-gcc-switches
This switch causes the command-line options used to invoke the compiler that may affect code generation to be appended to theDW_AT_producer attribute in DWARF debugging information. The options are concatenated with spaces separating them from eachother and from the compiler version. It is enabled by default. See also -frecord-gcc-switches for another way of storingcompiler options into the object file.
gcc -gno-record-gcc-switches ...
-gno-strict-dwarf
Allow using extensions of later DWARF standard version than selected with -gdwarf-version.
gcc -gno-strict-dwarf ...
-gno-column-info
Emit location column information into DWARF debugging information, rather than just file and line. This option is disabled bydefault.
gcc -gno-column-info ...
-gz[
Produce compressed debug sections in DWARF format, if that is supported. If type is not given, the default type depends on thecapabilities of the assembler and linker used. type may be one of none (don't compress debug sections), zlib (use zlibcompression in ELF gABI format), or zlib-gnu (use zlib compression in traditional GNU format). If the linker doesn't supportwriting compressed debug sections, the option is rejected. Otherwise, if the assembler does not support them, -gz is silentlyignored when producing object files.
gcc -gz[ ...
-feliminate-dwarf2-dups
Compress DWARF debugging information by eliminating duplicated information about each symbol. This option only makes sense whengenerating DWARF debugging information.
gcc -feliminate-dwarf2-dups ...
-femit-struct-debug-baseonly
Emit debug information for struct-like types only when the base name of the compilation source file matches the base name of filein which the struct is defined.This option substantially reduces the size of debugging information, but at significant potential loss in type information to thedebugger. See -femit-struct-debug-reduced for a less aggressive option. See -femit-struct-debug-detailed for more detailedcontrol.This option works only with DWARF debug output.
gcc -femit-struct-debug-baseonly ...
-femit-struct-debug-detailed[
Specify the struct-like types for which the compiler generates debug information. The intent is to reduce duplicate struct debuginformation between different object files within the same program.This option is a detailed version of -femit-struct-debug-reduced and -femit-struct-debug-baseonly, which serves for most needs.A specification has the syntax[dir:|ind:][ord:|gen:](any|sys|base|none)The optional first word limits the specification to structs that are used directly (dir:) or used indirectly (ind:). A structtype is used directly when it is the type of a variable, member. Indirect uses arise through pointers to structs. That is, whenuse of an incomplete struct is valid, the use is indirect. An example is struct one direct; struct two * indirect;.The optional second word limits the specification to ordinary structs (ord:) or generic structs (gen:). Generic structs are abit complicated to explain. For C++, these are non-explicit specializations of template classes, or non-template classes withinthe above. Other programming languages have generics, but -femit-struct-debug-detailed does not yet implement them.The third word specifies the source files for those structs for which the compiler should emit debug information. The valuesnone and any have the normal meaning. The value base means that the base of name of the file in which the type declarationappears must match the base of the name of the main compilation file. In practice, this means that when compiling foo.c, debuginformation is generated for types declared in that file and foo.h, but not other header files. The value sys means those typessatisfying base or declared in system or compiler headers.You may need to experiment to determine the best settings for your application.The default is -femit-struct-debug-detailed=all.This option works only with DWARF debug output.
gcc -femit-struct-debug-detailed[ ...
-fno-dwarf2-cfi-asm
Emit DWARF unwind info as compiler generated ".eh_frame" section instead of using GAS ".cfi_*" directives.
gcc -fno-dwarf2-cfi-asm ...
-fno-eliminate-unused-debug-types
Normally, when producing DWARF output, GCC avoids producing debug symbol output for types that are nowhere used in the sourcefile being compiled. Sometimes it is useful to have GCC emit debugging information for all types declared in a compilation unit,regardless of whether or not they are actually used in that compilation unit, for example if, in the debugger, you want to cast avalue to a type that is not actually used in your program (but is declared). More often, however, this results in a significantamount of wasted space.Options That Control OptimizationThese options control various sorts of optimizations.Without any optimization option, the compiler's goal is to reduce the cost of compilation and to make debugging produce the expectedresults. Statements are independent: if you stop the program with a breakpoint between statements, you can then assign a new valueto any variable or change the program counter to any other statement in the function and get exactly the results you expect from thesource code.Turning on optimization flags makes the compiler attempt to improve the performance and/or code size at the expense of compilationtime and possibly the ability to debug the program.The compiler performs optimization based on the knowledge it has of the program. Compiling multiple files at once to a single outputfile mode allows the compiler to use information gained from all of the files when compiling each of them.Not all optimizations are controlled directly by a flag. Only optimizations that have a flag are listed in this section.Most optimizations are only enabled if an -O level is set on the command line. Otherwise they are disabled, even if individualoptimization flags are specified.Depending on the target and how GCC was configured, a slightly different set of optimizations may be enabled at each -O level thanthose listed here. You can invoke GCC with -Q --help=optimizers to find out the exact set of optimizations that are enabled at eachlevel.
gcc -fno-eliminate-unused-debug-types ...
-O
turns on the following optimization flags:
gcc -O ...
-fauto-inc-dec
-fbranch-count-reg -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch
gcc -fauto-inc-dec ...
-fipa-pure-const
-fipa-profile -fipa-reference -fmerge-constants -fmove-loop-invariants -freorder-blocks -fshrink-wrap
gcc -fipa-pure-const ...
-ftree-copy-prop
-ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-sink -ftree-slsr
gcc -ftree-copy-prop ...
-ftree-sra
-ftree-pta -ftree-ter -funit-at-a-time
gcc -ftree-sra ...
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to
gcc -O2 ...
-falign-functions
-falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps
gcc -falign-functions ...
-fcse-skip-blocks
-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fexpensive-optimizations -fgcse
gcc -fcse-skip-blocks ...
-freorder-blocks-algorithm
-freorder-blocks-and-partition -freorder-functions -frerun-cse-after-loop -fsched-interblock
gcc -freorder-blocks-algorithm ...
-fsched-spec
-fschedule-insns -fschedule-insns2 -fstore-merging -fstrict-aliasing -fstrict-overflow -ftree-builtin-call-dce
gcc -fsched-spec ...
-ftree-switch-conversion
Please note the warning under -fgcse about invoking -O2 on programs that use computed gotos.NOTE: In Ubuntu 8.10 and later versions, -D_FORTIFY_SOURCE=2 is set by default, and is activated when -O is set to 2 or higher.This enables additional compile-time and run-time checks for several libc functions. To disable, specify either
gcc -ftree-switch-conversion ...
-U_FORTIFY_SOURCE
or -D_FORTIFY_SOURCE=0.
gcc -U_FORTIFY_SOURCE ...
-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops,
gcc -O3 ...
-fpredictive-commoning
-fgcse-after-reload -ftree-loop-vectorize -ftree-loop-distribute-patterns -fsplit-paths
gcc -fpredictive-commoning ...
-ftree-slp-vectorize
-fvect-cost-model -ftree-partial-pre -fpeel-loops and -fipa-cp-clone options.
gcc -ftree-slp-vectorize ...
-O0
Reduce compilation time and make debugging produce the expected results. This is the default.
gcc -O0 ...
-Os
disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks
gcc -Os ...
-Ofast
Disregard strict standards compliance. -Ofast enables all -O3 optimizations. It also enables optimizations that are not validfor all standard-compliant programs. It turns on -ffast-math and the Fortran-specific -fno-protect-parens and -fstack-arrays.
gcc -Ofast ...
-fno-defer-pop
Always pop the arguments to each function call as soon as that function returns. For machines that must pop arguments after afunction call, the compiler normally lets arguments accumulate on the stack for several function calls and pops them all at once.Disabled at levels -O, -O2, -O3, -Os.
gcc -fno-defer-pop ...
-fforward-propagate
Perform a forward propagation pass on RTL. The pass tries to combine two instructions and checks if the result can besimplified. If loop unrolling is active, two passes are performed and the second is scheduled after loop unrolling.This option is enabled by default at optimization levels -O, -O2, -O3, -Os.
gcc -fforward-propagate ...
-foptimize-sibling-calls
Optimize sibling and tail recursive calls.Enabled at levels -O2, -O3, -Os.
gcc -foptimize-sibling-calls ...
-foptimize-strlen
Optimize various standard C string functions (e.g. "strlen", "strchr" or "strcpy") and their "_FORTIFY_SOURCE" counterparts intofaster alternatives.Enabled at levels -O2, -O3.
gcc -foptimize-strlen ...
-fno-inline
Do not expand any functions inline apart from those marked with the "always_inline" attribute. This is the default when notoptimizing.Single functions can be exempted from inlining by marking them with the "noinline" attribute.
gcc -fno-inline ...
-finline-small-functions
Integrate functions into their callers when their body is smaller than expected function call code (so overall size of programgets smaller). The compiler heuristically decides which functions are simple enough to be worth integrating in this way. Thisinlining applies to all functions, even those not declared inline.Enabled at level -O2.
gcc -finline-small-functions ...
-findirect-inlining
Inline also indirect calls that are discovered to be known at compile time thanks to previous inlining. This option has anyeffect only when inlining itself is turned on by the -finline-functions or -finline-small-functions options.Enabled at level -O2.
gcc -findirect-inlining ...
-finline-functions-called-once
Consider all "static" functions called once for inlining into their caller even if they are not marked "inline". If a call to agiven function is integrated, then the function is not output as assembler code in its own right.Enabled at levels -O1, -O2, -O3 and -Os.
gcc -finline-functions-called-once ...
-fearly-inlining
Inline functions marked by "always_inline" and functions whose body seems smaller than the function call overhead early beforedoing -fprofile-generate instrumentation and real inlining pass. Doing so makes profiling significantly cheaper and usuallyinlining faster on programs having large chains of nested wrapper functions.Enabled by default.
gcc -fearly-inlining ...
-fipa-sra
Perform interprocedural scalar replacement of aggregates, removal of unused parameters and replacement of parameters passed byreference by parameters passed by value.Enabled at levels -O2, -O3 and -Os.
gcc -fipa-sra ...
-finline-limit
By default, GCC limits the size of functions that can be inlined. This flag allows coarse control of this limit. n is the sizeof functions that can be inlined in number of pseudo instructions.Inlining is actually controlled by a number of parameters, which may be specified individually by using --param name=value. The
gcc -finline-limit ...
-finline-limit=n
max-inline-insns-singleis set to n/2.max-inline-insns-autois set to n/2.See below for a documentation of the individual parameters controlling inlining and for the defaults of these parameters.Note: there may be no value to -finline-limit that results in default behavior.Note: pseudo instruction represents, in this particular context, an abstract measurement of function's size. In no way does itrepresent a count of assembly instructions and as such its exact meaning might change from one release to an another.
gcc -finline-limit=n ...
-fno-keep-inline-dllexport
This is a more fine-grained version of -fkeep-inline-functions, which applies only to functions that are declared using the"dllexport" attribute or declspec.
gcc -fno-keep-inline-dllexport ...
-fkeep-inline-functions
In C, emit "static" functions that are declared "inline" into the object file, even if the function has been inlined into all ofits callers. This switch does not affect functions using the "extern inline" extension in GNU C90. In C++, emit any and allinline functions into the object file.
gcc -fkeep-inline-functions ...
-fkeep-static-consts
Emit variables declared "static const" when optimization isn't turned on, even if the variables aren't referenced.GCC enables this option by default. If you want to force the compiler to check if a variable is referenced, regardless ofwhether or not optimization is turned on, use the -fno-keep-static-consts option.
gcc -fkeep-static-consts ...
-fmerge-constants
Attempt to merge identical constants (string constants and floating-point constants) across compilation units.This option is the default for optimized compilation if the assembler and linker support it. Use -fno-merge-constants to inhibitthis behavior.Enabled at levels -O, -O2, -O3, -Os.
gcc -fmerge-constants ...
-fmerge-all-constants
Attempt to merge identical constants and identical variables.This option implies -fmerge-constants. In addition to -fmerge-constants this considers e.g. even constant initialized arrays orinitialized constant variables with integral or floating-point types. Languages like C or C++ require each variable, includingmultiple instances of the same variable in recursive calls, to have distinct locations, so using this option results in non-conforming behavior.
gcc -fmerge-all-constants ...
-fmodulo-sched
Perform swing modulo scheduling immediately before the first scheduling pass. This pass looks at innermost loops and reorderstheir instructions by overlapping different iterations.
gcc -fmodulo-sched ...
-fmodulo-sched-allow-regmoves
Perform more aggressive SMS-based modulo scheduling with register moves allowed. By setting this flag certain anti-dependencesedges are deleted, which triggers the generation of reg-moves based on the life-range analysis. This option is effective onlywith -fmodulo-sched enabled.
gcc -fmodulo-sched-allow-regmoves ...
-fno-branch-count-reg
Avoid running a pass scanning for opportunities to use "decrement and branch" instructions on a count register instead ofgenerating sequences of instructions that decrement a register, compare it against zero, and then branch based upon the result.This option is only meaningful on architectures that support such instructions, which include x86, PowerPC, IA-64 and S/390.Note that the -fno-branch-count-reg option doesn't remove the decrement and branch instructions from the generated instructionstream introduced by other optimization passes.Enabled by default at -O1 and higher.The default is -fbranch-count-reg.
gcc -fno-branch-count-reg ...
-fno-function-cse
Do not put function addresses in registers; make each instruction that calls a constant function contain the function's addressexplicitly.This option results in less efficient code, but some strange hacks that alter the assembler output may be confused by theoptimizations performed when this option is not used.The default is -ffunction-cse
gcc -fno-function-cse ...
-fno-zero-initialized-in-bss
If the target supports a BSS section, GCC by default puts variables that are initialized to zero into BSS. This can save spacein the resulting code.This option turns off this behavior because some programs explicitly rely on variables going to the data section---e.g., so thatthe resulting executable can find the beginning of that section and/or make assumptions based on that.The default is -fzero-initialized-in-bss.
gcc -fno-zero-initialized-in-bss ...
-fcse-follow-jumps
In common subexpression elimination (CSE), scan through jump instructions when the target of the jump is not reached by any otherpath. For example, when CSE encounters an "if" statement with an "else" clause, CSE follows the jump when the condition testedis false.Enabled at levels -O2, -O3, -Os.
gcc -fcse-follow-jumps ...
-fgcse
Perform a global common subexpression elimination pass. This pass also performs global constant and copy propagation.Note: When compiling a program using computed gotos, a GCC extension, you may get better run-time performance if you disable theglobal common subexpression elimination pass by adding -fno-gcse to the command line.Enabled at levels -O2, -O3, -Os.
gcc -fgcse ...
-fgcse-sm
When -fgcse-sm is enabled, a store motion pass is run after global common subexpression elimination. This pass attempts to movestores out of loops. When used in conjunction with -fgcse-lm, loops containing a load/store sequence can be changed to a loadbefore the loop and a store after the loop.Not enabled at any optimization level.
gcc -fgcse-sm ...
-fgcse-las
When -fgcse-las is enabled, the global common subexpression elimination pass eliminates redundant loads that come after stores tothe same memory location (both partial and full redundancies).Not enabled at any optimization level.
gcc -fgcse-las ...
-fgcse-after-reload
When -fgcse-after-reload is enabled, a redundant load elimination pass is performed after reload. The purpose of this pass is toclean up redundant spilling.
gcc -fgcse-after-reload ...
-fcrossjumping
Perform cross-jumping transformation. This transformation unifies equivalent code and saves code size. The resulting code mayor may not perform better than without cross-jumping.Enabled at levels -O2, -O3, -Os.
gcc -fcrossjumping ...
-fif-conversion
Attempt to transform conditional jumps into branch-less equivalents. This includes use of conditional moves, min, max, set flagsand abs instructions, and some tricks doable by standard arithmetics. The use of conditional execution on chips where it isavailable is controlled by -fif-conversion2.Enabled at levels -O, -O2, -O3, -Os.
gcc -fif-conversion ...
-fif-conversion2
Use conditional execution (where available) to transform conditional jumps into branch-less equivalents.Enabled at levels -O, -O2, -O3, -Os.
gcc -fif-conversion2 ...
-fdeclone-ctor-dtor
The C++ ABI requires multiple entry points for constructors and destructors: one for a base subobject, one for a complete object,and one for a virtual destructor that calls operator delete afterwards. For a hierarchy with virtual bases, the base andcomplete variants are clones, which means two copies of the function. With this option, the base and complete variants arechanged to be thunks that call a common implementation.Enabled by -Os.
gcc -fdeclone-ctor-dtor ...
-fdelete-null-pointer-checks
Assume that programs cannot safely dereference null pointers, and that no code or data element resides at address zero. Thisoption enables simple constant folding optimizations at all optimization levels. In addition, other optimization passes in GCCuse this flag to control global dataflow analyses that eliminate useless checks for null pointers; these assume that a memoryaccess to address zero always results in a trap, so that if a pointer is checked after it has already been dereferenced, itcannot be null.Note however that in some environments this assumption is not true. Use -fno-delete-null-pointer-checks to disable thisoptimization for programs that depend on that behavior.This option is enabled by default on most targets. On Nios II ELF, it defaults to off. On AVR and CR16, this option iscompletely disabled.Passes that use the dataflow information are enabled independently at different optimization levels.
gcc -fdelete-null-pointer-checks ...
-fdevirtualize
Attempt to convert calls to virtual functions to direct calls. This is done both within a procedure and interprocedurally aspart of indirect inlining (-findirect-inlining) and interprocedural constant propagation (-fipa-cp). Enabled at levels -O2, -O3,
gcc -fdevirtualize ...
-fdevirtualize-speculatively
Attempt to convert calls to virtual functions to speculative direct calls. Based on the analysis of the type inheritance graph,determine for a given call the set of likely targets. If the set is small, preferably of size 1, change the call into aconditional deciding between direct and indirect calls. The speculative calls enable more optimizations, such as inlining. Whenthey seem useless after further optimization, they are converted back into original form.
gcc -fdevirtualize-speculatively ...
-fdevirtualize-at-ltrans
Stream extra information needed for aggressive devirtualization when running the link-time optimizer in local transformationmode. This option enables more devirtualization but significantly increases the size of streamed data. For this reason it isdisabled by default.
gcc -fdevirtualize-at-ltrans ...
-fexpensive-optimizations
Perform a number of minor optimizations that are relatively expensive.Enabled at levels -O2, -O3, -Os.
gcc -fexpensive-optimizations ...
-free
Attempt to remove redundant extension instructions. This is especially helpful for the x86-64 architecture, which implicitlyzero-extends in 64-bit registers after writing to their lower 32-bit half.Enabled for Alpha, AArch64 and x86 at levels -O2, -O3, -Os.
gcc -free ...
-fno-lifetime-dse
In C++ the value of an object is only affected by changes within its lifetime: when the constructor begins, the object has anindeterminate value, and any changes during the lifetime of the object are dead when the object is destroyed. Normally deadstore elimination will take advantage of this; if your code relies on the value of the object storage persisting beyond thelifetime of the object, you can use this flag to disable this optimization. To preserve stores before the constructor starts(e.g. because your operator new clears the object storage) but still treat the object as dead after the destructor you, can use
gcc -fno-lifetime-dse ...
-flifetime-dse
The default behavior can be explicitly selected with -flifetime-dse=2. -flifetime-dse=0 is equivalent to
gcc -flifetime-dse ...
-flive-range-shrinkage
Attempt to decrease register pressure through register live range shrinkage. This is helpful for fast processors with small ormoderate size register sets.
gcc -flive-range-shrinkage ...
-fira-algorithm
Use the specified coloring algorithm for the integrated register allocator. The algorithm argument can be priority, whichspecifies Chow's priority coloring, or CB, which specifies Chaitin-Briggs coloring. Chaitin-Briggs coloring is not implementedfor all architectures, but for those targets that do support it, it is the default because it generates better code.
gcc -fira-algorithm ...
-fira-hoist-pressure
Use IRA to evaluate register pressure in the code hoisting pass for decisions to hoist expressions. This option usually resultsin smaller code, but it can slow the compiler down.This option is enabled at level -Os for all targets.
gcc -fira-hoist-pressure ...
-fira-loop-pressure
Use IRA to evaluate register pressure in loops for decisions to move loop invariants. This option usually results in generationof faster and smaller code on machines with large register files (>= 32 registers), but it can slow the compiler down.This option is enabled at level -O3 for some targets.
gcc -fira-loop-pressure ...
-fno-ira-share-save-slots
Disable sharing of stack slots used for saving call-used hard registers living through a call. Each hard register gets aseparate stack slot, and as a result function stack frames are larger.
gcc -fno-ira-share-save-slots ...
-fno-ira-share-spill-slots
Disable sharing of stack slots allocated for pseudo-registers. Each pseudo-register that does not get a hard register gets aseparate stack slot, and as a result function stack frames are larger.
gcc -fno-ira-share-spill-slots ...
-flra-remat
Enable CFG-sensitive rematerialization in LRA. Instead of loading values of spilled pseudos, LRA tries to rematerialize(recalculate) values if it is profitable.Enabled at levels -O2, -O3, -Os.
gcc -flra-remat ...
-fdelayed-branch
If supported for the target machine, attempt to reorder instructions to exploit instruction slots available after delayed branchinstructions.Enabled at levels -O, -O2, -O3, -Os.
gcc -fdelayed-branch ...
-fschedule-insns
If supported for the target machine, attempt to reorder instructions to eliminate execution stalls due to required data beingunavailable. This helps machines that have slow floating point or memory load instructions by allowing other instructions to beissued until the result of the load or floating-point instruction is required.Enabled at levels -O2, -O3.
gcc -fschedule-insns ...
-fschedule-insns2
Similar to -fschedule-insns, but requests an additional pass of instruction scheduling after register allocation has been done.This is especially useful on machines with a relatively small number of registers and where memory load instructions take morethan one cycle.Enabled at levels -O2, -O3, -Os.
gcc -fschedule-insns2 ...
-fno-sched-spec
Don't allow speculative motion of non-load instructions. This is normally enabled by default when scheduling before registerallocation, i.e. with -fschedule-insns or at -O2 or higher.
gcc -fno-sched-spec ...
-fsched-pressure
Enable register pressure sensitive insn scheduling before register allocation. This only makes sense when scheduling beforeregister allocation is enabled, i.e. with -fschedule-insns or at -O2 or higher. Usage of this option can improve the generatedcode and decrease its size by preventing register pressure increase above the number of available hard registers and subsequentspills in register allocation.
gcc -fsched-pressure ...
-fsched-spec-load-dangerous
Allow speculative motion of more load instructions. This only makes sense when scheduling before register allocation, i.e. with
gcc -fsched-spec-load-dangerous ...
-fsched-stalled-insns
Define how many insns (if any) can be moved prematurely from the queue of stalled insns into the ready list during the secondscheduling pass. -fno-sched-stalled-insns means that no insns are moved prematurely, -fsched-stalled-insns=0 means there is nolimit on how many queued insns can be moved prematurely. -fsched-stalled-insns without a value is equivalent to
gcc -fsched-stalled-insns ...
-fsched-stalled-insns-dep
Define how many insn groups (cycles) are examined for a dependency on a stalled insn that is a candidate for premature removalfrom the queue of stalled insns. This has an effect only during the second scheduling pass, and only if -fsched-stalled-insns isused. -fno-sched-stalled-insns-dep is equivalent to -fsched-stalled-insns-dep=0. -fsched-stalled-insns-dep without a value isequivalent to -fsched-stalled-insns-dep=1.
gcc -fsched-stalled-insns-dep ...
-fsched2-use-superblocks
When scheduling after register allocation, use superblock scheduling. This allows motion across basic block boundaries,resulting in faster schedules. This option is experimental, as not all machine descriptions used by GCC model the CPU closelyenough to avoid unreliable results from the algorithm.This only makes sense when scheduling after register allocation, i.e. with -fschedule-insns2 or at -O2 or higher.
gcc -fsched2-use-superblocks ...
-fsched-group-heuristic
Enable the group heuristic in the scheduler. This heuristic favors the instruction that belongs to a schedule group. This isenabled by default when scheduling is enabled, i.e. with -fschedule-insns or -fschedule-insns2 or at -O2 or higher.
gcc -fsched-group-heuristic ...
-fsched-spec-insn-heuristic
Enable the speculative instruction heuristic in the scheduler. This heuristic favors speculative instructions with greaterdependency weakness. This is enabled by default when scheduling is enabled, i.e. with -fschedule-insns or -fschedule-insns2 orat -O2 or higher.
gcc -fsched-spec-insn-heuristic ...
-fsched-rank-heuristic
Enable the rank heuristic in the scheduler. This heuristic favors the instruction belonging to a basic block with greater sizeor frequency. This is enabled by default when scheduling is enabled, i.e. with -fschedule-insns or -fschedule-insns2 or at -O2or higher.
gcc -fsched-rank-heuristic ...
-fsched-last-insn-heuristic
Enable the last-instruction heuristic in the scheduler. This heuristic favors the instruction that is less dependent on the lastinstruction scheduled. This is enabled by default when scheduling is enabled, i.e. with -fschedule-insns or -fschedule-insns2 orat -O2 or higher.
gcc -fsched-last-insn-heuristic ...
-freschedule-modulo-scheduled-loops
Modulo scheduling is performed before traditional scheduling. If a loop is modulo scheduled, later scheduling passes may changeits schedule. Use this option to control that behavior.
gcc -freschedule-modulo-scheduled-loops ...
-fselective-scheduling
Schedule instructions using selective scheduling algorithm. Selective scheduling runs instead of the first scheduler pass.
gcc -fselective-scheduling ...
-fsel-sched-pipelining
Enable software pipelining of innermost loops during selective scheduling. This option has no effect unless one of
gcc -fsel-sched-pipelining ...
-fsel-sched-pipelining-outer-loops
When pipelining loops during selective scheduling, also pipeline outer loops. This option has no effect unless
gcc -fsel-sched-pipelining-outer-loops ...
-fsemantic-interposition
Some object formats, like ELF, allow interposing of symbols by the dynamic linker. This means that for symbols exported from theDSO, the compiler cannot perform interprocedural propagation, inlining and other optimizations in anticipation that the functionor variable in question may change. While this feature is useful, for example, to rewrite memory allocation functions by adebugging implementation, it is expensive in the terms of code quality. With -fno-semantic-interposition the compiler assumesthat if interposition happens for functions the overwriting function will have precisely the same semantics (and side effects).Similarly if interposition happens for variables, the constructor of the variable will be the same. The flag has no effect forfunctions explicitly declared inline (where it is never allowed for interposition to change semantics) and for symbols explicitlydeclared weak.
gcc -fsemantic-interposition ...
-fshrink-wrap
Emit function prologues only before parts of the function that need it, rather than at the top of the function. This flag isenabled by default at -O and higher.
gcc -fshrink-wrap ...
-fcaller-saves
Enable allocation of values to registers that are clobbered by function calls, by emitting extra instructions to save and restorethe registers around such calls. Such allocation is done only when it seems to result in better code.This option is always enabled by default on certain machines, usually those which have no call-preserved registers to useinstead.Enabled at levels -O2, -O3, -Os.
gcc -fcaller-saves ...
-fcombine-stack-adjustments
Tracks stack adjustments (pushes and pops) and stack memory references and then tries to find ways to combine them.Enabled by default at -O1 and higher.
gcc -fcombine-stack-adjustments ...
-fipa-ra
Use caller save registers for allocation if those registers are not used by any called function. In that case it is notnecessary to save and restore them around calls. This is only possible if called functions are part of same compilation unit ascurrent function and they are compiled before it.Enabled at levels -O2, -O3, -Os, however the option is disabled if generated code will be instrumented for profiling (-p, or -pg)or if callee's register usage cannot be known exactly (this happens on targets that do not expose prologues and epilogues inRTL).
gcc -fipa-ra ...
-fconserve-stack
Attempt to minimize stack usage. The compiler attempts to use less stack space, even if that makes the program slower. Thisoption implies setting the large-stack-frame parameter to 100 and the large-stack-frame-growth parameter to 400.
gcc -fconserve-stack ...
-ftree-reassoc
Perform reassociation on trees. This flag is enabled by default at -O and higher.
gcc -ftree-reassoc ...
-fcode-hoisting
Perform code hoisting. Code hoisting tries to move the evaluation of expressions executed on all paths to the function exit asearly as possible. This is especially useful as a code size optimization, but it often helps for code speed as well. This flagis enabled by default at -O2 and higher.
gcc -fcode-hoisting ...
-ftree-pre
Perform partial redundancy elimination (PRE) on trees. This flag is enabled by default at -O2 and -O3.
gcc -ftree-pre ...
-ftree-partial-pre
Make partial redundancy elimination (PRE) more aggressive. This flag is enabled by default at -O3.
gcc -ftree-partial-pre ...
-ftree-forwprop
Perform forward propagation on trees. This flag is enabled by default at -O and higher.
gcc -ftree-forwprop ...
-ftree-fre
Perform full redundancy elimination (FRE) on trees. The difference between FRE and PRE is that FRE only considers expressionsthat are computed on all paths leading to the redundant computation. This analysis is faster than PRE, though it exposes fewerredundancies. This flag is enabled by default at -O and higher.
gcc -ftree-fre ...
-fhoist-adjacent-loads
Speculatively hoist loads from both branches of an if-then-else if the loads are from adjacent locations in the same structureand the target architecture has a conditional move instruction. This flag is enabled by default at -O2 and higher.
gcc -fhoist-adjacent-loads ...
-fipa-reference
Discover which static variables do not escape the compilation unit. Enabled by default at -O and higher.
gcc -fipa-reference ...
-fipa-pta
Perform interprocedural pointer analysis and interprocedural modification and reference analysis. This option can causeexcessive memory and compile-time usage on large compilation units. It is not enabled by default at any optimization level.
gcc -fipa-pta ...
-fipa-profile
Perform interprocedural profile propagation. The functions called only from cold functions are marked as cold. Also functionsexecuted once (such as "cold", "noreturn", static constructors or destructors) are identified. Cold functions and loop less partsof functions executed once are then optimized for size. Enabled by default at -O and higher.
gcc -fipa-profile ...
-fipa-cp
Perform interprocedural constant propagation. This optimization analyzes the program to determine when values passed tofunctions are constants and then optimizes accordingly. This optimization can substantially increase performance if theapplication has constants passed to functions. This flag is enabled by default at -O2, -Os and -O3.
gcc -fipa-cp ...
-fipa-cp-clone
Perform function cloning to make interprocedural constant propagation stronger. When enabled, interprocedural constantpropagation performs function cloning when externally visible function can be called with constant arguments. Because thisoptimization can create multiple copies of functions, it may significantly increase code size (see --paramipcp-unit-growth=value). This flag is enabled by default at -O3.
gcc -fipa-cp-clone ...
-fipa-vrp
When enabled, perform interprocedural propagation of value ranges. This flag is enabled by default at -O2. It requires that
gcc -fipa-vrp ...
-fipa-icf
Perform Identical Code Folding for functions and read-only variables. The optimization reduces code size and may disturb unwindstacks by replacing a function by equivalent one with a different name. The optimization works more effectively with link-timeoptimization enabled.Nevertheless the behavior is similar to Gold Linker ICF optimization, GCC ICF works on different levels and thus theoptimizations are not same - there are equivalences that are found only by GCC and equivalences found only by Gold.This flag is enabled by default at -O2 and -Os.
gcc -fipa-icf ...
-fisolate-erroneous-paths-attribute
Detect paths that trigger erroneous or undefined behavior due to a null value being used in a way forbidden by a"returns_nonnull" or "nonnull" attribute. Isolate those paths from the main control flow and turn the statement with erroneousor undefined behavior into a trap. This is not currently enabled, but may be enabled by -O2 in the future.
gcc -fisolate-erroneous-paths-attribute ...
-ftree-bit-ccp
Perform sparse conditional bit constant propagation on trees and propagate pointer alignment information. This pass onlyoperates on local scalar variables and is enabled by default at -O and higher. It requires that -ftree-ccp is enabled.
gcc -ftree-bit-ccp ...
-ftree-ccp
Perform sparse conditional constant propagation (CCP) on trees. This pass only operates on local scalar variables and is enabledby default at -O and higher.
gcc -ftree-ccp ...
-fssa-backprop
Propagate information about uses of a value up the definition chain in order to simplify the definitions. For example, this passstrips sign operations if the sign of a value never matters. The flag is enabled by default at -O and higher.
gcc -fssa-backprop ...
-fssa-phiopt
Perform pattern matching on SSA PHI nodes to optimize conditional code. This pass is enabled by default at -O and higher.
gcc -fssa-phiopt ...
-ftree-tail-merge
Look for identical code sequences. When found, replace one with a jump to the other. This optimization is known as tail mergingor cross jumping. This flag is enabled by default at -O2 and higher. The compilation time in this pass can be limited usingmax-tail-merge-comparisons parameter and max-tail-merge-iterations parameter.
gcc -ftree-tail-merge ...
-ftree-builtin-call-dce
Perform conditional dead code elimination (DCE) for calls to built-in functions that may set "errno" but are otherwise side-effect free. This flag is enabled by default at -O2 and higher if -Os is not also specified.
gcc -ftree-builtin-call-dce ...
-ftree-dominator-opts
Perform a variety of simple scalar cleanups (constant/copy propagation, redundancy elimination, range propagation and expressionsimplification) based on a dominator tree traversal. This also performs jump threading (to reduce jumps to jumps). This flag isenabled by default at -O and higher.
gcc -ftree-dominator-opts ...
-ftree-dse
Perform dead store elimination (DSE) on trees. A dead store is a store into a memory location that is later overwritten byanother store without any intervening loads. In this case the earlier store can be deleted. This flag is enabled by default at
gcc -ftree-dse ...
-ftree-ch
Perform loop header copying on trees. This is beneficial since it increases effectiveness of code motion optimizations. It alsosaves one jump. This flag is enabled by default at -O and higher. It is not enabled for -Os, since it usually increases codesize.
gcc -ftree-ch ...
-floop-unroll-and-jam
Perform loop nest optimizations. Same as -floop-nest-optimize. To use this code transformation, GCC has to be configured with
gcc -floop-unroll-and-jam ...
--with-isl
to enable the Graphite loop transformation infrastructure.
gcc --with-isl ...
-fgraphite-identity
Enable the identity transformation for graphite. For every SCoP we generate the polyhedral representation and transform it backto gimple. Using -fgraphite-identity we can check the costs or benefits of the GIMPLE -> GRAPHITE -> GIMPLE transformation.Some minimal optimizations are also performed by the code generator isl, like index splitting and dead code elimination in loops.
gcc -fgraphite-identity ...
-floop-nest-optimize
Enable the isl based loop nest optimizer. This is a generic loop nest optimizer based on the Pluto optimization algorithms. Itcalculates a loop structure optimized for data-locality and parallelism. This option is experimental.
gcc -floop-nest-optimize ...
-floop-parallelize-all
Use the Graphite data dependence analysis to identify loops that can be parallelized. Parallelize all the loops that can beanalyzed to not contain loop carried dependences without checking that it is profitable to parallelize the loops.
gcc -floop-parallelize-all ...
-ftree-coalesce-vars
While transforming the program out of the SSA representation, attempt to reduce copying by coalescing versions of different user-defined variables, instead of just compiler temporaries. This may severely limit the ability to debug an optimized programcompiled with -fno-var-tracking-assignments. In the negated form, this flag prevents SSA coalescing of user variables. Thisoption is enabled by default if optimization is enabled, and it does very little otherwise.
gcc -ftree-coalesce-vars ...
-ftree-loop-if-convert
Attempt to transform conditional jumps in the innermost loops to branch-less equivalents. The intent is to remove control-flowfrom the innermost loops in order to improve the ability of the vectorization pass to handle these loops. This is enabled bydefault if vectorization is enabled.
gcc -ftree-loop-if-convert ...
-ftree-loop-distribution
Perform loop distribution. This flag can improve cache performance on big loop bodies and allow further loop optimizations, likeparallelization or vectorization, to take place. For example, the loopDO I = 1, NA(I) = B(I) + CD(I) = E(I) * FENDDOis transformed toDO I = 1, NA(I) = B(I) + CENDDODO I = 1, ND(I) = E(I) * FENDDO
gcc -ftree-loop-distribution ...
-ftree-loop-distribute-patterns
Perform loop distribution of patterns that can be code generated with calls to a library. This flag is enabled by default at
gcc -ftree-loop-distribute-patterns ...
-O3.
This pass distributes the initialization loops and generates a call to memset zero. For example, the loopDO I = 1, NA(I) = 0B(I) = A(I) + IENDDOis transformed toDO I = 1, NA(I) = 0ENDDODO I = 1, NB(I) = A(I) + IENDDOand the initialization loop is transformed into a call to memset zero.
gcc -O3. ...
-ftree-loop-im
Perform loop invariant motion on trees. This pass moves only invariants that are hard to handle at RTL level (function calls,operations that expand to nontrivial sequences of insns). With -funswitch-loops it also moves operands of conditions that areinvariant out of the loop, so that we can use just trivial invariantness analysis in loop unswitching. The pass also includesstore motion.
gcc -ftree-loop-im ...
-ftree-loop-ivcanon
Create a canonical counter for number of iterations in loops for which determining number of iterations requires complicatedanalysis. Later optimizations then may determine the number easily. Useful especially in connection with unrolling.
gcc -ftree-loop-ivcanon ...
-fivopts
Perform induction variable optimizations (strength reduction, induction variable merging and induction variable elimination) ontrees.
gcc -fivopts ...
-ftree-parallelize-loops
Parallelize loops, i.e., split their iteration space to run in n threads. This is only possible for loops whose iterations areindependent and can be arbitrarily reordered. The optimization is only profitable on multiprocessor machines, for loops that areCPU-intensive, rather than constrained e.g. by memory bandwidth. This option implies -pthread, and thus is only supported ontargets that have support for -pthread.
gcc -ftree-parallelize-loops ...
-ftree-pta
Perform function-local points-to analysis on trees. This flag is enabled by default at -O and higher.
gcc -ftree-pta ...
-fstore-merging
Perform merging of narrow stores to consecutive memory addresses. This pass merges contiguous stores of immediate valuesnarrower than a word into fewer wider stores to reduce the number of instructions. This is enabled by default at -O2 and higheras well as -Os.
gcc -fstore-merging ...
-ftree-ter
Perform temporary expression replacement during the SSA->normal phase. Single use/single def temporaries are replaced at theiruse location with their defining expression. This results in non-GIMPLE code, but gives the expanders much more complex trees towork on resulting in better RTL generation. This is enabled by default at -O and higher.
gcc -ftree-ter ...
-ftree-slsr
Perform straight-line strength reduction on trees. This recognizes related expressions involving multiplications and replacesthem by less expensive calculations when possible. This is enabled by default at -O and higher.
gcc -ftree-slsr ...
-ftree-vectorize
Perform vectorization on trees. This flag enables -ftree-loop-vectorize and -ftree-slp-vectorize if not explicitly specified.
gcc -ftree-vectorize ...
-ftree-loop-vectorize
Perform loop vectorization on trees. This flag is enabled by default at -O3 and when -ftree-vectorize is enabled.
gcc -ftree-loop-vectorize ...
-fvect-cost-model
Alter the cost model used for vectorization. The model argument should be one of unlimited, dynamic or cheap. With theunlimited model the vectorized code-path is assumed to be profitable while with the dynamic model a runtime check guards thevectorized code-path to enable it only for iteration counts that will likely execute faster than when executing the originalscalar loop. The cheap model disables vectorization of loops where doing so would be cost prohibitive for example due torequired runtime checks for data dependence or alignment but otherwise is equal to the dynamic model. The default cost modeldepends on other optimization flags and is either dynamic or cheap.
gcc -fvect-cost-model ...
-ftree-vrp
Perform Value Range Propagation on trees. This is similar to the constant propagation pass, but instead of values, ranges ofvalues are propagated. This allows the optimizers to remove unnecessary range checks like array bound checks and null pointerchecks. This is enabled by default at -O2 and higher. Null pointer check elimination is only done if
gcc -ftree-vrp ...
-fsplit-paths
Split paths leading to loop backedges. This can improve dead code elimination and common subexpression elimination. This isenabled by default at -O2 and above.
gcc -fsplit-paths ...
-fsplit-ivs-in-unroller
Enables expression of values of induction variables in later iterations of the unrolled loop using the value in the firstiteration. This breaks long dependency chains, thus improving efficiency of the scheduling passes.A combination of -fweb and CSE is often sufficient to obtain the same effect. However, that is not reliable in cases where theloop body is more complicated than a single basic block. It also does not work at all on some architectures due to restrictionsin the CSE pass.This optimization is enabled by default.
gcc -fsplit-ivs-in-unroller ...
-fvariable-expansion-in-unroller
With this option, the compiler creates multiple copies of some local variables when unrolling a loop, which can result insuperior code.
gcc -fvariable-expansion-in-unroller ...
-fpartial-inlining
Inline parts of functions. This option has any effect only when inlining itself is turned on by the -finline-functions or
gcc -fpartial-inlining ...
-fprefetch-loop-arrays
If supported by the target machine, generate instructions to prefetch memory to improve the performance of loops that accesslarge arrays.This option may generate better or worse code; results are highly dependent on the structure of loops within the source code.Disabled at level -Os.
gcc -fprefetch-loop-arrays ...
-fno-printf-return-value
Do not substitute constants for known return value of formatted output functions such as "sprintf", "snprintf", "vsprintf", and"vsnprintf" (but not "printf" of "fprintf"). This transformation allows GCC to optimize or even eliminate branches based on theknown return value of these functions called with arguments that are either constant, or whose values are known to be in a rangethat makes determining the exact return value possible. For example, when -fprintf-return-value is in effect, both the branchand the body of the "if" statement (but not the call to "snprint") can be optimized away when "i" is a 32-bit or smaller integerbecause the return value is guaranteed to be at most 8.char buf[9];if (snprintf (buf, "%08x", i) >= sizeof buf)...The -fprintf-return-value option relies on other optimizations and yields best results with -O2. It works in tandem with the
gcc -fno-printf-return-value ...
-fno-peephole2
Disable any machine-specific peephole optimizations. The difference between -fno-peephole and -fno-peephole2 is in how they areimplemented in the compiler; some targets use one, some use the other, a few use both.
gcc -fno-peephole2 ...
-fpeephole
is enabled by default. -fpeephole2 enabled at levels -O2, -O3, -Os.
gcc -fpeephole ...
-freorder-blocks
Reorder basic blocks in the compiled function in order to reduce number of taken branches and improve code locality.Enabled at levels -O, -O2, -O3, -Os.
gcc -freorder-blocks ...
-freorder-blocks-and-partition
In addition to reordering basic blocks in the compiled function, in order to reduce number of taken branches, partitions hot andcold basic blocks into separate sections of the assembly and .o files, to improve paging and cache locality performance.This optimization is automatically turned off in the presence of exception handling, for linkonce sections, for functions with auser-defined section attribute and on any architecture that does not support named sections.Enabled for x86 at levels -O2, -O3.
gcc -freorder-blocks-and-partition ...
-freorder-functions
Reorder functions in the object file in order to improve code locality. This is implemented by using special subsections".text.hot" for most frequently executed functions and ".text.unlikely" for unlikely executed functions. Reordering is done bythe linker so object file format must support named sections and linker must place them in a reasonable way.Also profile feedback must be available to make this option effective. See -fprofile-arcs for details.Enabled at levels -O2, -O3, -Os.
gcc -freorder-functions ...
-fstrict-aliasing
Allow the compiler to assume the strictest aliasing rules applicable to the language being compiled. For C (and C++), thisactivates optimizations based on the type of expressions. In particular, an object of one type is assumed never to reside at thesame address as an object of a different type, unless the types are almost the same. For example, an "unsigned int" can alias an"int", but not a "void*" or a "double". A character type may alias any other type.Pay special attention to code like this:union a_union {int i;double d;};int f() {union a_union t;t.d = 3.0;return t.i;}The practice of reading from a different union member than the one most recently written to (called "type-punning") is common.Even with -fstrict-aliasing, type-punning is allowed, provided the memory is accessed through the union type. So, the code aboveworks as expected. However, this code might not:int f() {union a_union t;int* ip;t.d = 3.0;ip = &t.i;return *ip;}Similarly, access by taking the address, casting the resulting pointer and dereferencing the result has undefined behavior, evenif the cast uses a union type, e.g.:int f() {double d = 3.0;return ((union a_union *) &d)->i;}The -fstrict-aliasing option is enabled at levels -O2, -O3, -Os.
gcc -fstrict-aliasing ...
-fstrict-overflow
Allow the compiler to assume strict signed overflow rules, depending on the language being compiled. For C (and C++) this meansthat overflow when doing arithmetic with signed numbers is undefined, which means that the compiler may assume that it does nothappen. This permits various optimizations. For example, the compiler assumes that an expression like "i + 10 > i" is alwaystrue for signed "i". This assumption is only valid if signed overflow is undefined, as the expression is false if "i + 10"overflows when using twos complement arithmetic. When this option is in effect any attempt to determine whether an operation onsigned numbers overflows must be written carefully to not actually involve overflow.This option also allows the compiler to assume strict pointer semantics: given a pointer to an object, if adding an offset tothat pointer does not produce a pointer to the same object, the addition is undefined. This permits the compiler to concludethat "p + u > p" is always true for a pointer "p" and unsigned integer "u". This assumption is only valid because pointerwraparound is undefined, as the expression is false if "p + u" overflows using twos complement arithmetic.See also the -fwrapv option. Using -fwrapv means that integer signed overflow is fully defined: it wraps. When -fwrapv is used,there is no difference between -fstrict-overflow and -fno-strict-overflow for integers. With -fwrapv certain types of overfloware permitted. For example, if the compiler gets an overflow when doing arithmetic on constants, the overflowed value can stillbe used with -fwrapv, but not otherwise.The -fstrict-overflow option is enabled at levels -O2, -O3, -Os.
gcc -fstrict-overflow ...
-flimit-function-alignment
If this option is enabled, the compiler tries to avoid unnecessarily overaligning functions. It attempts to instruct theassembler to align by the amount specified by -falign-functions, but not to skip more bytes than the size of the function.
gcc -flimit-function-alignment ...
-falign-labels
Align all branch targets to a power-of-two boundary, skipping up to n bytes like -falign-functions. This option can easily makecode slower, because it must insert dummy operations for when the branch target is reached in the usual flow of the code.
gcc -falign-labels ...
-fno-align-labels
If -falign-loops or -falign-jumps are applicable and are greater than this value, then their values are used instead.If n is not specified or is zero, use a machine-dependent default which is very likely to be 1, meaning no alignment. Themaximum allowed n option value is 65536.Enabled at levels -O2, -O3.
gcc -fno-align-labels ...
-falign-loops
Align loops to a power-of-two boundary, skipping up to n bytes like -falign-functions. If the loops are executed many times,this makes up for any execution of the dummy operations.
gcc -falign-loops ...
-falign-jumps
Align branch targets to a power-of-two boundary, for branch targets where the targets can only be reached by jumping, skipping upto n bytes like -falign-functions. In this case, no dummy operations need be executed.
gcc -falign-jumps ...
-fno-align-jumps
If n is not specified or is zero, use a machine-dependent default. The maximum allowed n option value is 65536.Enabled at levels -O2, -O3.
gcc -fno-align-jumps ...
-funit-at-a-time
This option is left for compatibility reasons. -funit-at-a-time has no effect, while -fno-unit-at-a-time implies
gcc -funit-at-a-time ...
-fno-toplevel-reorder
Enabled by default.
gcc -fno-toplevel-reorder ...
-fweb
Constructs webs as commonly used for register allocation purposes and assign each web individual pseudo register. This allowsthe register allocation pass to operate on pseudos directly, but also strengthens several other optimization passes, such as CSE,loop optimizer and trivial dead code remover. It can, however, make debugging impossible, since variables no longer stay in a"home register".Enabled by default with -funroll-loops.
gcc -fweb ...
-fwhole-program
Assume that the current compilation unit represents the whole program being compiled. All public functions and variables withthe exception of "main" and those merged by attribute "externally_visible" become static functions and in effect are optimizedmore aggressively by interprocedural optimizers.This option should not be used in combination with -flto. Instead relying on a linker plugin should provide safer and moreprecise information.
gcc -fwhole-program ...
-flto[
This option runs the standard link-time optimizer. When invoked with source code, it generates GIMPLE (one of GCC's internalrepresentations) and writes it to special ELF sections in the object file. When the object files are linked together, all thefunction bodies are read from these ELF sections and instantiated as if they had been part of the same translation unit.To use the link-time optimizer, -flto and optimization options should be specified at compile time and during the final link. Itis recommended that you compile all the files participating in the same link with the same options and also specify those optionsat link time. For example:gcc -c -O2 -flto foo.cgcc -c -O2 -flto bar.cgcc -o myprog -flto -O2 foo.o bar.oThe first two invocations to GCC save a bytecode representation of GIMPLE into special ELF sections inside foo.o and bar.o. Thefinal invocation reads the GIMPLE bytecode from foo.o and bar.o, merges the two files into a single internal image, and compilesthe result as usual. Since both foo.o and bar.o are merged into a single image, this causes all the interprocedural analyses andoptimizations in GCC to work across the two files as if they were a single one. This means, for example, that the inliner isable to inline functions in bar.o into functions in foo.o and vice-versa.Another (simpler) way to enable link-time optimization is:gcc -o myprog -flto -O2 foo.c bar.cThe above generates bytecode for foo.c and bar.c, merges them together into a single GIMPLE representation and optimizes them asusual to produce myprog.The only important thing to keep in mind is that to enable link-time optimizations you need to use the GCC driver to perform thelink step. GCC then automatically performs link-time optimization if any of the objects involved were compiled with the -fltocommand-line option. You generally should specify the optimization options to be used for link-time optimization though GCCtries to be clever at guessing an optimization level to use from the options used at compile time if you fail to specify one atlink time. You can always override the automatic decision to do link-time optimization by passing -fno-lto to the link command.To make whole program optimization effective, it is necessary to make certain whole program assumptions. The compiler needs toknow what functions and variables can be accessed by libraries and runtime outside of the link-time optimized unit. Whensupported by the linker, the linker plugin (see -fuse-linker-plugin) passes information to the compiler about used and externallyvisible symbols. When the linker plugin is not available, -fwhole-program should be used to allow the compiler to make theseassumptions, which leads to more aggressive optimization decisions.When -fuse-linker-plugin is not enabled, when a file is compiled with -flto, the generated object file is larger than a regularobject file because it contains GIMPLE bytecodes and the usual final code (see -ffat-lto-objects. This means that object fileswith LTO information can be linked as normal object files; if -fno-lto is passed to the linker, no interprocedural optimizationsare applied. Note that when -fno-fat-lto-objects is enabled the compile stage is faster but you cannot perform a regular, non-LTO link on them.Additionally, the optimization flags used to compile individual files are not necessarily related to those used at link time.For instance,gcc -c -O0 -ffat-lto-objects -flto foo.cgcc -c -O0 -ffat-lto-objects -flto bar.cgcc -o myprog -O3 foo.o bar.oThis produces individual object files with unoptimized assembler code, but the resulting binary myprog is optimized at -O3. If,instead, the final binary is generated with -fno-lto, then myprog is not optimized.When producing the final binary, GCC only applies link-time optimizations to those files that contain bytecode. Therefore, youcan mix and match object files and libraries with GIMPLE bytecodes and final object code. GCC automatically selects which filesto optimize in LTO mode and which files to link without further processing.There are some code generation flags preserved by GCC when generating bytecodes, as they need to be used during the final linkstage. Generally options specified at link time override those specified at compile time.If you do not specify an optimization level option -O at link time, then GCC uses the highest optimization level used whencompiling the object files.Currently, the following options and their settings are taken from the first object file that explicitly specifies them: -fPIC,
gcc -flto[ ...
-fpic
Certain ABI-changing flags are required to match in all compilation units, and trying to override this at link time with aconflicting value is ignored. This includes options such as -freg-struct-return and -fpcc-struct-return.Other options such as -ffp-contract, -fno-strict-overflow, -fwrapv, -fno-trapv or -fno-strict-aliasing are passed through to thelink stage and merged conservatively for conflicting translation units. Specifically -fno-strict-overflow, -fwrapv and
gcc -fpic ...
-flto-odr-type-merging
Enable streaming of mangled types names of C++ types and their unification at link time. This increases size of LTO objectfiles, but enables diagnostics about One Definition Rule violations.
gcc -flto-odr-type-merging ...
-flto-compression-level
This option specifies the level of compression used for intermediate language written to LTO object files, and is only meaningfulin conjunction with LTO mode (-flto). Valid values are 0 (no compression) to 9 (maximum compression). Values outside this rangeare clamped to either 0 or 9. If the option is not given, a default balanced compression setting is used.
gcc -flto-compression-level ...
-fuse-linker-plugin
Enables the use of a linker plugin during link-time optimization. This option relies on plugin support in the linker, which isavailable in gold or in GNU ld 2.21 or newer.This option enables the extraction of object files with GIMPLE bytecode out of library archives. This improves the quality ofoptimization by exposing more code to the link-time optimizer. This information specifies what symbols can be accessedexternally (by non-LTO object or during dynamic linking). Resulting code quality improvements on binaries (and shared librariesthat use hidden visibility) are similar to -fwhole-program. See -flto for a description of the effect of this flag and how touse it.This option is enabled by default when LTO support in GCC is enabled and GCC was configured for use with a linker supportingplugins (GNU ld 2.21 or newer or gold).
gcc -fuse-linker-plugin ...
-ffat-lto-objects
Fat LTO objects are object files that contain both the intermediate language and the object code. This makes them usable for bothLTO linking and normal linking. This option is effective only when compiling with -flto and is ignored at link time.
gcc -ffat-lto-objects ...
-fcompare-elim
After register allocation and post-register allocation instruction splitting, identify arithmetic instructions that computeprocessor flags similar to a comparison operation based on that arithmetic. If possible, eliminate the explicit comparisonoperation.This pass only applies to certain targets that cannot explicitly represent the comparison operation before register allocation iscomplete.Enabled at levels -O, -O2, -O3, -Os.
gcc -fcompare-elim ...
-fprofile-use
Enable profile feedback-directed optimizations, and the following optimizations which are generally profitable only with profilefeedback available: -fbranch-probabilities, -fvpt, -funroll-loops, -fpeel-loops, -ftracer, -ftree-vectorize, and ftree-loop-distribute-patterns.Before you can use this option, you must first generate profiling information.By default, GCC emits an error message if the feedback profiles do not match the source code. This error can be turned into awarning by using -Wcoverage-mismatch. Note this may result in poorly optimized code.If path is specified, GCC looks at the path to find the profile feedback data files. See -fprofile-dir.
gcc -fprofile-use ...
-ftree-loop-distribute-patterns.
path is the name of a file containing AutoFDO profile information. If omitted, it defaults to fbdata.afdo in the currentdirectory.Producing an AutoFDO profile data file requires running your program with the perf utility on a supported GNU/Linux targetsystem. For more information, see <https://perf.wiki.kernel.org/>.E.g.perf record -e br_inst_retired:near_taken -b -o perf.data \
gcc -ftree-loop-distribute-patterns. ...
--
Then use the create_gcov tool to convert the raw profile data to a format that can be used by GCC. You must also supply theunstripped binary for your program to this tool. See <https://github.com/google/autofdo>.E.g.create_gcov --binary=your_program.unstripped --profile=perf.data \
gcc -- ...
--gcov
The following options control compiler behavior regarding floating-point arithmetic. These options trade off between speed andcorrectness. All must be specifically enabled.
gcc --gcov ...
-ffloat-store
Do not store floating-point variables in registers, and inhibit other options that might change whether a floating-point value istaken from a register or memory.This option prevents undesirable excess precision on machines such as the 68000 where the floating registers (of the 68881) keepmore precision than a "double" is supposed to have. Similarly for the x86 architecture. For most programs, the excess precisiondoes only good, but a few programs rely on the precise definition of IEEE floating point. Use -ffloat-store for such programs,after modifying them to store all pertinent intermediate computations into variables.
gcc -ffloat-store ...
-ffast-math
Sets the options -fno-math-errno, -funsafe-math-optimizations, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans,
gcc -ffast-math ...
-fcx-limited-range
This option causes the preprocessor macro "__FAST_MATH__" to be defined.This option is not turned on by any -O option besides -Ofast since it can result in incorrect output for programs that depend onan exact implementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programsthat do not require the guarantees of these specifications.
gcc -fcx-limited-range ...
-fno-math-errno
Do not set "errno" after calling math functions that are executed with a single instruction, e.g., "sqrt". A program that relieson IEEE exceptions for math error handling may want to use this flag for speed while maintaining IEEE arithmetic compatibility.This option is not turned on by any -O option since it can result in incorrect output for programs that depend on an exactimplementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programs that donot require the guarantees of these specifications.The default is -fmath-errno.On Darwin systems, the math library never sets "errno". There is therefore no reason for the compiler to consider thepossibility that it might, and -fno-math-errno is the default.
gcc -fno-math-errno ...
-funsafe-math-optimizations
Allow optimizations for floating-point arithmetic that (a) assume that arguments and results are valid and (b) may violate IEEEor ANSI standards. When used at link time, it may include libraries or startup files that change the default FPU control word orother similar optimizations.This option is not turned on by any -O option since it can result in incorrect output for programs that depend on an exactimplementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programs that donot require the guarantees of these specifications. Enables -fno-signed-zeros, -fno-trapping-math, -fassociative-math and
gcc -funsafe-math-optimizations ...
-freciprocal-math.
The default is -fno-unsafe-math-optimizations.
gcc -freciprocal-math. ...
-fassociative-math
Allow re-association of operands in series of floating-point operations. This violates the ISO C and C++ language standard bypossibly changing computation result. NOTE: re-ordering may change the sign of zero as well as ignore NaNs and inhibit or createunderflow or overflow (and thus cannot be used on code that relies on rounding behavior like "(x + 2**52) - 2**52". May alsoreorder floating-point comparisons and thus may not be used when ordered comparisons are required. This option requires thatboth -fno-signed-zeros and -fno-trapping-math be in effect. Moreover, it doesn't make much sense with -frounding-math. ForFortran the option is automatically enabled when both -fno-signed-zeros and -fno-trapping-math are in effect.The default is -fno-associative-math.
gcc -fassociative-math ...
-freciprocal-math
Allow the reciprocal of a value to be used instead of dividing by the value if this enables optimizations. For example "x / y"can be replaced with "x * (1/y)", which is useful if "(1/y)" is subject to common subexpression elimination. Note that thisloses precision and increases the number of flops operating on the value.The default is -fno-reciprocal-math.
gcc -freciprocal-math ...
-ffinite-math-only
Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs.This option is not turned on by any -O option since it can result in incorrect output for programs that depend on an exactimplementation of IEEE or ISO rules/specifications for math functions. It may, however, yield faster code for programs that donot require the guarantees of these specifications.The default is -fno-finite-math-only.
gcc -ffinite-math-only ...
-fno-signed-zeros
Allow optimizations for floating-point arithmetic that ignore the signedness of zero. IEEE arithmetic specifies the behavior ofdistinct +0.0 and -0.0 values, which then prohibits simplification of expressions such as x+0.0 or 0.0*x (even with
gcc -fno-signed-zeros ...
-ffinite-math-only).
The default is -fsigned-zeros.
gcc -ffinite-math-only). ...
-fno-trapping-math
Compile code assuming that floating-point operations cannot generate user-visible traps. These traps include division by zero,overflow, underflow, inexact result and invalid operation. This option requires that -fno-signaling-nans be in effect. Settingthis option may allow faster code if one relies on "non-stop" IEEE arithmetic, for example.This option should never be turned on by any -O option since it can result in incorrect output for programs that depend on anexact implementation of IEEE or ISO rules/specifications for math functions.The default is -ftrapping-math.
gcc -fno-trapping-math ...
-frounding-math
Disable transformations and optimizations that assume default floating-point rounding behavior. This is round-to-zero for allfloating point to integer conversions, and round-to-nearest for all other arithmetic truncations. This option should bespecified for programs that change the FP rounding mode dynamically, or that may be executed with a non-default rounding mode.This option disables constant folding of floating-point expressions at compile time (which may be affected by rounding mode) andarithmetic transformations that are unsafe in the presence of sign-dependent rounding modes.The default is -fno-rounding-math.This option is experimental and does not currently guarantee to disable all GCC optimizations that are affected by rounding mode.Future versions of GCC may provide finer control of this setting using C99's "FENV_ACCESS" pragma. This command-line option willbe used to specify the default state for "FENV_ACCESS".
gcc -frounding-math ...
-fsignaling-nans
Compile code assuming that IEEE signaling NaNs may generate user-visible traps during floating-point operations. Setting thisoption disables optimizations that may change the number of exceptions visible with signaling NaNs. This option implies
gcc -fsignaling-nans ...
-ftrapping-math.
This option causes the preprocessor macro "__SUPPORT_SNAN__" to be defined.The default is -fno-signaling-nans.This option is experimental and does not currently guarantee to disable all GCC optimizations that affect signaling NaN behavior.
gcc -ftrapping-math. ...
-fno-fp-int-builtin-inexact
Do not allow the built-in functions "ceil", "floor", "round" and "trunc", and their "float" and "long double" variants, togenerate code that raises the "inexact" floating-point exception for noninteger arguments. ISO C99 and C11 allow these functionsto raise the "inexact" exception, but ISO/IEC TS 18661-1:2014, the C bindings to IEEE 754-2008, does not allow these functions todo so.The default is -ffp-int-builtin-inexact, allowing the exception to be raised. This option does nothing unless -ftrapping-math isin effect.Even if -fno-fp-int-builtin-inexact is used, if the functions generate a call to a library function then the "inexact" exceptionmay be raised if the library implementation does not follow TS 18661.
gcc -fno-fp-int-builtin-inexact ...
-fsingle-precision-constant
Treat floating-point constants as single precision instead of implicitly converting them to double-precision constants.
gcc -fsingle-precision-constant ...
-fcx-fortran-rules
Complex multiplication and division follow Fortran rules. Range reduction is done as part of complex division, but there is nochecking whether the result of a complex multiplication or division is "NaN + I*NaN", with an attempt to rescue the situation inthat case.The default is -fno-cx-fortran-rules.The following options control optimizations that may improve performance, but are not enabled by any -O options. This sectionincludes experimental options that may produce broken code.
gcc -fcx-fortran-rules ...
-fbranch-probabilities
After running a program compiled with -fprofile-arcs, you can compile it a second time using -fbranch-probabilities, to improveoptimizations based on the number of times each branch was taken. When a program compiled with -fprofile-arcs exits, it savesarc execution counts to a file called sourcename.gcda for each source file. The information in this data file is very dependenton the structure of the generated code, so you must use the same source code and the same optimization options for bothcompilations.With -fbranch-probabilities, GCC puts a REG_BR_PROB note on each JUMP_INSN and CALL_INSN. These can be used to improveoptimization. Currently, they are only used in one place: in reorg.c, instead of guessing which path a branch is most likely totake, the REG_BR_PROB values are used to exactly determine which path is taken more often.
gcc -fbranch-probabilities ...
-fprofile-values
If combined with -fprofile-arcs, it adds code so that some data about values of expressions in the program is gathered.With -fbranch-probabilities, it reads back the data gathered from profiling values of expressions for usage in optimizations.Enabled with -fprofile-generate and -fprofile-use.
gcc -fprofile-values ...
-fprofile-reorder-functions
Function reordering based on profile instrumentation collects first time of execution of a function and orders these functions inascending order.Enabled with -fprofile-use.
gcc -fprofile-reorder-functions ...
-fvpt
If combined with -fprofile-arcs, this option instructs the compiler to add code to gather information about values ofexpressions.With -fbranch-probabilities, it reads back the data gathered and actually performs the optimizations based on them. Currentlythe optimizations include specialization of division operations using the knowledge about the value of the denominator.
gcc -fvpt ...
-fschedule-fusion
Performs a target dependent pass over the instruction stream to schedule instructions of same type together because targetmachine can execute them more efficiently if they are adjacent to each other in the instruction flow.Enabled at levels -O2, -O3, -Os.
gcc -fschedule-fusion ...
-ftracer
Perform tail duplication to enlarge superblock size. This transformation simplifies the control flow of the function allowingother optimizations to do a better job.Enabled with -fprofile-use.
gcc -ftracer ...
-funroll-loops
Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies
gcc -funroll-loops ...
-funroll-all-loops
Unroll all loops, even if their number of iterations is uncertain when the loop is entered. This usually makes programs run moreslowly. -funroll-all-loops implies the same options as -funroll-loops.
gcc -funroll-all-loops ...
-fpeel-loops
Peels loops for which there is enough information that they do not roll much (from profile feedback or static analysis). It alsoturns on complete loop peeling (i.e. complete removal of loops with small constant number of iterations).Enabled with -O3 and/or -fprofile-use.
gcc -fpeel-loops ...
-fsplit-loops
Split a loop into two if it contains a condition that's always true for one side of the iteration space and false for the other.
gcc -fsplit-loops ...
-funswitch-loops
Move branches with loop invariant conditions out of the loop, with duplicates of the loop on both branches (modified according toresult of the condition).
gcc -funswitch-loops ...
-fdata-sections
Place each function or data item into its own section in the output file if the target supports arbitrary sections. The name ofthe function or the name of the data item determines the section's name in the output file.Use these options on systems where the linker can perform optimizations to improve locality of reference in the instructionspace. Most systems using the ELF object format and SPARC processors running Solaris 2 have linkers with such optimizations.AIX may have these optimizations in the future.Only use these options when there are significant benefits from doing so. When you specify these options, the assembler andlinker create larger object and executable files and are also slower. You cannot use gprof on all systems if you specify thisoption, and you may have problems with debugging if you specify both this option and -g.
gcc -fdata-sections ...
-fbranch-target-load-optimize
Perform branch target register load optimization before prologue / epilogue threading. The use of target registers can typicallybe exposed only during reload, thus hoisting loads out of loops and doing inter-block scheduling needs a separate optimizationpass.
gcc -fbranch-target-load-optimize ...
-fbtr-bb-exclusive
When performing branch target register load optimization, don't reuse branch target registers within any basic block.
gcc -fbtr-bb-exclusive ...
-fstdarg-opt
Optimize the prologue of variadic argument functions with respect to usage of those arguments.NOTE: In Ubuntu 14.10 and later versions, -fstack-protector-strong is enabled by default for C, C++, ObjC, ObjC++, if none of
gcc -fstdarg-opt ...
-fno-stack-protector
-nostdlib nor -ffreestanding are found.
gcc -fno-stack-protector ...
-fsection-anchors
Try to reduce the number of symbolic address calculations by using shared "anchor" symbols to address nearby objects. Thistransformation can help to reduce the number of GOT entries and GOT accesses on some targets.For example, the implementation of the following function "foo":static int a, b, c;int foo (void) { return a + b + c; }usually calculates the addresses of all three variables, but if you compile it with -fsection-anchors, it accesses the variablesfrom a common anchor point instead. The effect is similar to the following pseudocode (which isn't valid C):int foo (void){register int *xr = &x;return xr[&a - &x] + xr[&b - &x] + xr[&c - &x];}Not all targets support this option.
gcc -fsection-anchors ...
--param
In some places, GCC uses various constants to control the amount of optimization that is done. For example, GCC does not inlinefunctions that contain more than a certain number of instructions. You can control some of these constants on the command lineusing the --param option.The names of specific parameters, and the meaning of the values, are tied to the internals of the compiler, and are subject tochange without notice in future releases.In each case, the value is an integer. The allowable choices for name are:predictable-branch-outcomeWhen branch is predicted to be taken with probability lower than this threshold (in percent), then it is considered wellpredictable. The default is 10.max-rtl-if-conversion-insnsRTL if-conversion tries to remove conditional branches around a block and replace them with conditionally executedinstructions. This parameter gives the maximum number of instructions in a block which should be considered for if-conversion. The default is 10, though the compiler will also use other heuristics to decide whether if-conversion is likelyto be profitable.max-rtl-if-conversion-predictable-costmax-rtl-if-conversion-unpredictable-costRTL if-conversion will try to remove conditional branches around a block and replace them with conditionally executedinstructions. These parameters give the maximum permissible cost for the sequence that would be generated by if-conversiondepending on whether the branch is statically determined to be predictable or not. The units for this parameter are the sameas those for the GCC internal seq_cost metric. The compiler will try to provide a reasonable default for this parameterusing the BRANCH_COST target macro.max-crossjump-edgesThe maximum number of incoming edges to consider for cross-jumping. The algorithm used by -fcrossjumping is O(N^2) in thenumber of edges incoming to each block. Increasing values mean more aggressive optimization, making the compilation timeincrease with probably small improvement in executable size.min-crossjump-insnsThe minimum number of instructions that must be matched at the end of two blocks before cross-jumping is performed on them.This value is ignored in the case where all instructions in the block being cross-jumped from are matched. The default valueis 5.max-grow-copy-bb-insnsThe maximum code size expansion factor when copying basic blocks instead of jumping. The expansion is relative to a jumpinstruction. The default value is 8.max-goto-duplication-insnsThe maximum number of instructions to duplicate to a block that jumps to a computed goto. To avoid O(N^2) behavior in anumber of passes, GCC factors computed gotos early in the compilation process, and unfactors them as late as possible. Onlycomputed jumps at the end of a basic blocks with no more than max-goto-duplication-insns are unfactored. The default valueis 8.max-delay-slot-insn-searchThe maximum number of instructions to consider when looking for an instruction to fill a delay slot. If more than thisarbitrary number of instructions are searched, the time savings from filling the delay slot are minimal, so stop searching.Increasing values mean more aggressive optimization, making the compilation time increase with probably small improvement inexecution time.max-delay-slot-live-searchWhen trying to fill delay slots, the maximum number of instructions to consider when searching for a block with valid liveregister information. Increasing this arbitrarily chosen value means more aggressive optimization, increasing thecompilation time. This parameter should be removed when the delay slot code is rewritten to maintain the control-flow graph.max-gcse-memoryThe approximate maximum amount of memory that can be allocated in order to perform the global common subexpressionelimination optimization. If more memory than specified is required, the optimization is not done.max-gcse-insertion-ratioIf the ratio of expression insertions to deletions is larger than this value for any expression, then RTL PRE inserts orremoves the expression and thus leaves partially redundant computations in the instruction stream. The default value is 20.max-pending-list-lengthThe maximum number of pending dependencies scheduling allows before flushing the current state and starting over. Largefunctions with few branches or calls can create excessively large lists which needlessly consume memory and resources.max-modulo-backtrack-attemptsThe maximum number of backtrack attempts the scheduler should make when modulo scheduling a loop. Larger values canexponentially increase compilation time.max-inline-insns-singleSeveral parameters control the tree inliner used in GCC. This number sets the maximum number of instructions (counted inGCC's internal representation) in a single function that the tree inliner considers for inlining. This only affectsfunctions declared inline and methods implemented in a class declaration (C++). The default value is 400.max-inline-insns-autoWhen you use -finline-functions (included in -O3), a lot of functions that would otherwise not be considered for inlining bythe compiler are investigated. To those functions, a different (more restrictive) limit compared to functions declaredinline can be applied. The default value is 40.inline-min-speedupWhen estimated performance improvement of caller + callee runtime exceeds this threshold (in percent), the function can beinlined regardless of the limit on --param max-inline-insns-single and --param max-inline-insns-auto.large-function-insnsThe limit specifying really large functions. For functions larger than this limit after inlining, inlining is constrained by
gcc --param ...
-fsanitize=address
asan-stackEnable buffer overflow detection for stack objects. This kind of protection is enabled by default when using
gcc -fsanitize=address ...
-fsanitize=address.
asan-instrument-readsEnable buffer overflow detection for memory reads. This kind of protection is enabled by default when using
gcc -fsanitize=address. ...
-fprofile-arcs
Add code so that program flow arcs are instrumented. During execution the program records how many times each branch and call isexecuted and how many times it is taken or returns. On targets that support constructors with priority support, profilingproperly handles constructors, destructors and C++ constructors (and destructors) of classes which are used as a type of a globalvariable.When the compiled program exits it saves this data to a file called auxname.gcda for each source file. The data may be used forprofile-directed optimizations (-fbranch-probabilities), or for test coverage analysis (-ftest-coverage). Each object file'sauxname is generated from the name of the output file, if explicitly specified and it is not the final executable, otherwise itis the basename of the source file. In both cases any suffix is removed (e.g. foo.gcda for input file dir/foo.c, or dir/foo.gcdafor output file specified as -o dir/foo.o).
gcc -fprofile-arcs ...
--coverage
This option is used to compile and link code instrumented for coverage analysis. The option is a synonym for -fprofile-arcs
gcc --coverage ...
-ftest-coverage
Produce a notes file that the gcov code-coverage utility can use to show program coverage. Each source file's note file iscalled auxname.gcno. Refer to the -fprofile-arcs option above for a description of auxname and instructions on how to generatetest coverage data. Coverage data matches the source files more closely if you do not optimize.
gcc -ftest-coverage ...
-fprofile-dir
Set the directory to search for the profile data files in to path. This option affects only the profile data generated by
gcc -fprofile-dir ...
-fprofile-generate
Both absolute and relative paths can be used. By default, GCC uses the current directory as path, thus the profile data fileappears in the same directory as the object file.
gcc -fprofile-generate ...
-fprofile-update
Alter the update method for an application instrumented for profile feedback based optimization. The method argument should beone of single, atomic or prefer-atomic. The first one is useful for single-threaded applications, while the second one preventsprofile corruption by emitting thread-safe code.Warning: When an application does not properly join all threads (or creates an detached thread), a profile file can be stillcorrupted.Using prefer-atomic would be transformed either to atomic, when supported by a target, or to single otherwise. The GCC driverautomatically selects prefer-atomic when -pthread is present in the command line.
gcc -fprofile-update ...
-fno-sanitize
This option disables all previously enabled sanitizers. -fsanitize=all is not allowed, as some sanitizers cannot be usedtogether.
gcc -fno-sanitize ...
-fasan-shadow-offset
This option forces GCC to use custom shadow offset in AddressSanitizer checks. It is useful for experimenting with differentshadow memory layouts in Kernel AddressSanitizer.
gcc -fasan-shadow-offset ...
-fsanitize-sections
Sanitize global variables in selected user-defined sections. si may contain wildcards.
gcc -fsanitize-sections ...
-fsanitize-address-use-after-scope
Enable sanitization of local variables to detect use-after-scope bugs. The option sets -fstack-reuse to none.
gcc -fsanitize-address-use-after-scope ...
-fsanitize-coverage
Enable coverage-guided fuzzing code instrumentation. Inserts a call to "__sanitizer_cov_trace_pc" into every basic block.
gcc -fsanitize-coverage ...
-fbounds-check
For front ends that support it, generate additional code to check that indices used to access arrays are within the declaredrange. This is currently only supported by the Fortran front end, where this option defaults to false.
gcc -fbounds-check ...
-fcheck-pointer-bounds
Enable Pointer Bounds Checker instrumentation. Each memory reference is instrumented with checks of the pointer used for memoryaccess against bounds associated with that pointer.Currently there is only an implementation for Intel MPX available, thus x86 GNU/Linux target and -mmpx are required to enablethis feature. MPX-based instrumentation requires a runtime library to enable MPX in hardware and handle bounds violationsignals. By default when -fcheck-pointer-bounds and -mmpx options are used to link a program, the GCC driver links against thelibmpx and libmpxwrappers libraries. Bounds checking on calls to dynamic libraries requires a linker with -z bndplt support; ifGCC was configured with a linker without support for this option (including the Gold linker and older versions of ld), a warningis given if you link with -mmpx without also specifying -static, since the overall effectiveness of the bounds checkingprotection is reduced. See also -static-libmpxwrappers.MPX-based instrumentation may be used for debugging and also may be included in production code to increase program security.Depending on usage, you may have different requirements for the runtime library. The current version of the MPX runtime libraryis more oriented for use as a debugging tool. MPX runtime library usage implies -lpthread. See also -static-libmpx. Theruntime library behavior can be influenced using various CHKP_RT_* environment variables. See<https://gcc.gnu.org/wiki/Intel%20MPX%20support%20in%20the%20GCC%20compiler> for more details.Generated instrumentation may be controlled by various -fchkp-* options and by the "bnd_variable_size" structure field attributeand "bnd_legacy", and "bnd_instrument" function attributes. GCC also provides a number of built-in functions for controlling thePointer Bounds Checker.
gcc -fcheck-pointer-bounds ...
-fchkp-check-incomplete-type
Generate pointer bounds checks for variables with incomplete type. Enabled by default.
gcc -fchkp-check-incomplete-type ...
-fchkp-narrow-bounds
Controls bounds used by Pointer Bounds Checker for pointers to object fields. If narrowing is enabled then field bounds areused. Otherwise object bounds are used. See also -fchkp-narrow-to-innermost-array and -fchkp-first-field-has-own-bounds.Enabled by default.
gcc -fchkp-narrow-bounds ...
-fchkp-flexible-struct-trailing-arrays
Forces Pointer Bounds Checker to treat all trailing arrays in structures as possibly flexible. By default only array fields withzero length or that are marked with attribute bnd_variable_size are treated as flexible.
gcc -fchkp-flexible-struct-trailing-arrays ...
-fchkp-narrow-to-innermost-array
Forces Pointer Bounds Checker to use bounds of the innermost arrays in case of nested static array access. By default thisoption is disabled and bounds of the outermost array are used.
gcc -fchkp-narrow-to-innermost-array ...
-fchkp-optimize
Enables Pointer Bounds Checker optimizations. Enabled by default at optimization levels -O, -O2, -O3.
gcc -fchkp-optimize ...
-fchkp-use-nochk-string-functions
Enables use of *_nochk versions of string functions (not checking bounds) by Pointer Bounds Checker. Disabled by default.
gcc -fchkp-use-nochk-string-functions ...
-fchkp-use-static-bounds
Allow Pointer Bounds Checker to generate static bounds holding bounds of static variables. Enabled by default.
gcc -fchkp-use-static-bounds ...
-fchkp-use-static-const-bounds
Use statically-initialized bounds for constant bounds instead of generating them each time they are required. By default enabledwhen -fchkp-use-static-bounds is enabled.
gcc -fchkp-use-static-const-bounds ...
-fchkp-check-read
Instructs Pointer Bounds Checker to generate checks for all read accesses to memory. Enabled by default.
gcc -fchkp-check-read ...
-fchkp-check-write
Instructs Pointer Bounds Checker to generate checks for all write accesses to memory. Enabled by default.
gcc -fchkp-check-write ...
-fchkp-store-bounds
Instructs Pointer Bounds Checker to generate bounds stores for pointer writes. Enabled by default.
gcc -fchkp-store-bounds ...
-fchkp-instrument-marked-only
Instructs Pointer Bounds Checker to instrument only functions marked with the "bnd_instrument" attribute. Disabled by default.
gcc -fchkp-instrument-marked-only ...
-fchkp-use-wrappers
Allows Pointer Bounds Checker to replace calls to built-in functions with calls to wrapper functions. When -fchkp-use-wrappersis used to link a program, the GCC driver automatically links against libmpxwrappers. See also -static-libmpxwrappers. Enabledby default.
gcc -fchkp-use-wrappers ...
-fstack-protector-all
Like -fstack-protector except that all functions are protected.
gcc -fstack-protector-all ...
-fstack-protector-strong
Like -fstack-protector but includes additional functions to be protected --- those that have local array definitions, or havereferences to local frame addresses.
gcc -fstack-protector-strong ...
-fstack-protector-explicit
Like -fstack-protector but only protects those functions which have the "stack_protect" attribute.
gcc -fstack-protector-explicit ...
-fstack-check
Generate code to verify that you do not go beyond the boundary of the stack. You should specify this flag if you are running inan environment with multiple threads, but you only rarely need to specify it in a single-threaded environment since stackoverflow is automatically detected on nearly all systems if there is only one stack.Note that this switch does not actually cause checking to be done; the operating system or the language runtime must do that.The switch causes generation of code to ensure that they see the stack being extended.You can additionally specify a string parameter: no means no checking, generic means force the use of old-style checking,specific means use the best checking method and is equivalent to bare -fstack-check.Old-style checking is a generic mechanism that requires no specific target support in the compiler but comes with the followingdrawbacks:1. Modified allocation strategy for large objects: they are always allocated dynamically if their size exceeds a fixedthreshold.2. Fixed limit on the size of the static frame of functions: when it is topped by a particular function, stack checking is notreliable and a warning is issued by the compiler.3. Inefficiency: because of both the modified allocation strategy and the generic implementation, code performance is hampered.Note that old-style stack checking is also the fallback method for specific if no target support has been added in the compiler.
gcc -fstack-check ...
-fno-stack-limit
Generate code to ensure that the stack does not grow beyond a certain value, either the value of a register or the address of asymbol. If a larger stack is required, a signal is raised at run time. For most targets, the signal is raised before the stackoverruns the boundary, so it is possible to catch the signal without taking special precautions.For instance, if the stack starts at absolute address 0x80000000 and grows downwards, you can use the flags
gcc -fno-stack-limit ...
-fsplit-stack
Generate code to automatically split the stack before it overflows. The resulting program has a discontiguous stack which canonly overflow if the program is unable to allocate any more memory. This is most useful when running threaded programs, as it isno longer necessary to calculate a good stack size to use for each thread. This is currently only implemented for the x86targets running GNU/Linux.When code compiled with -fsplit-stack calls code compiled without -fsplit-stack, there may not be much stack space available forthe latter code to run. If compiling all code, including library code, with -fsplit-stack is not an option, then the linker canfix up these calls so that the code compiled without -fsplit-stack always has a large stack. Support for this is implemented inthe gold linker in GNU binutils release 2.21 and later.
gcc -fsplit-stack ...
-fvtable-verify
This option is only available when compiling C++ code. It turns on (or off, if using -fvtable-verify=none) the security featurethat verifies at run time, for every virtual call, that the vtable pointer through which the call is made is valid for the typeof the object, and has not been corrupted or overwritten. If an invalid vtable pointer is detected at run time, an error isreported and execution of the program is immediately halted.This option causes run-time data structures to be built at program startup, which are used for verifying the vtable pointers.The options std and preinit control the timing of when these data structures are built. In both cases the data structures arebuilt before execution reaches "main". Using -fvtable-verify=std causes the data structures to be built after shared librarieshave been loaded and initialized. -fvtable-verify=preinit causes them to be built before shared libraries have been loaded andinitialized.If this option appears multiple times in the command line with different values specified, none takes highest priority over bothstd and preinit; preinit takes priority over std.
gcc -fvtable-verify ...
-fvtv-debug
When used in conjunction with -fvtable-verify=std or -fvtable-verify=preinit, causes debug versions of the runtime functions forthe vtable verification feature to be called. This flag also causes the compiler to log information about which vtable pointersit finds for each class. This information is written to a file named vtv_set_ptr_data.log in the directory named by theenvironment variable VTV_LOGS_DIR if that is defined or the current working directory otherwise.Note: This feature appends data to the log file. If you want a fresh log file, be sure to delete any existing one.
gcc -fvtv-debug ...
-finstrument-functions
Generate instrumentation calls for entry and exit to functions. Just after function entry and just before function exit, thefollowing profiling functions are called with the address of the current function and its call site. (On some platforms,"__builtin_return_address" does not work beyond the current function, so the call site information may not be available to theprofiling functions otherwise.)void __cyg_profile_func_enter (void *this_fn,void *call_site);void __cyg_profile_func_exit (void *this_fn,void *call_site);The first argument is the address of the start of the current function, which may be looked up exactly in the symbol table.This instrumentation is also done for functions expanded inline in other functions. The profiling calls indicate where,conceptually, the inline function is entered and exited. This means that addressable versions of such functions must beavailable. If all your uses of a function are expanded inline, this may mean an additional expansion of code size. If you use"extern inline" in your C code, an addressable version of such functions must be provided. (This is normally the case anyway,but if you get lucky and the optimizer always expands the functions inline, you might have gotten away without providing staticcopies.)A function may be given the attribute "no_instrument_function", in which case this instrumentation is not done. This can beused, for example, for the profiling functions listed above, high-priority interrupt routines, and any functions from which theprofiling functions cannot safely be called (perhaps signal handlers, if the profiling routines generate output or allocatememory).
gcc -finstrument-functions ...
-finstrument-functions-exclude-function-list
This is similar to -finstrument-functions-exclude-file-list, but this option sets the list of function names to be excluded frominstrumentation. The function name to be matched is its user-visible name, such as "vector<int> blah(const vector<int> &)", notthe internal mangled name (e.g., "_Z4blahRSt6vectorIiSaIiEE"). The match is done on substrings: if the sym parameter is asubstring of the function name, it is considered to be a match. For C99 and C++ extended identifiers, the function name must begiven in UTF-8, not using universal character names.Options Controlling the PreprocessorThese options control the C preprocessor, which is run on each C source file before actual compilation.If you use the -E option, nothing is done except preprocessing. Some of these options make sense only together with -E because theycause the preprocessor output to be unsuitable for actual compilation.In addition to the options listed here, there are a number of options to control search paths for include files documented inDirectory Options. Options to control preprocessor diagnostics are listed in Warning Options.
gcc -finstrument-functions-exclude-function-list ...
-D
Predefine name as a macro, with definition 1.
gcc -D ...
-U
Cancel any previous definition of name, either built in or provided with a -D option.
gcc -U ...
-include
Process file as if "#include "file"" appeared as the first line of the primary source file. However, the first directorysearched for file is the preprocessor's working directory instead of the directory containing the main source file. If not foundthere, it is searched for in the remainder of the "#include "..."" search chain as normal.If multiple -include options are given, the files are included in the order they appear on the command line.
gcc -include ...
-imacros
Exactly like -include, except that any output produced by scanning file is thrown away. Macros it defines remain defined. Thisallows you to acquire all the macros from a header without also processing its declarations.All files specified by -imacros are processed before all files specified by -include.
gcc -imacros ...
-undef
Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.
gcc -undef ...
-MF
When used with -M or -MM, specifies a file to write the dependencies to. If no -MF switch is given the preprocessor sends therules to the same place it would send preprocessed output.When used with the driver options -MD or -MMD, -MF overrides the default dependency output file.
gcc -MF ...
-MT
Change the target of the rule emitted by dependency generation. By default CPP takes the name of the main input file, deletesany directory components and any file suffix such as .c, and appends the platform's usual object suffix. The result is thetarget.An -MT option sets the target to be exactly the string you specify. If you want multiple targets, you can specify them as asingle argument to -MT, or use multiple -MT options.For example, -MT '$(objpfx)foo.o' might give$(objpfx)foo.o: foo.c
gcc -MT ...
-MQ
Same as -MT, but it quotes any characters which are special to Make. -MQ '$(objpfx)foo.o' gives$$(objpfx)foo.o: foo.cThe default target is automatically quoted, as if it were given with -MQ.
gcc -MQ ...
-MD
given. If it is, the driver uses its argument but with a suffix of .d, otherwise it takes the name of the input file, removesany directory components and suffix, and applies a .d suffix.If -MD is used in conjunction with -E, any -o switch is understood to specify the dependency output file, but if used without -E,each -o is understood to specify a target object file.Since -E is not implied, -MD can be used to generate a dependency output file as a side-effect of the compilation process.
gcc -MD ...
-MMD
Like -MD except mention only user header files, not system header files.
gcc -MMD ...
-fpreprocessed
Indicate to the preprocessor that the input file has already been preprocessed. This suppresses things like macro expansion,trigraph conversion, escaped newline splicing, and processing of most directives. The preprocessor still recognizes and removescomments, so that you can pass a file preprocessed with -C to the compiler without problems. In this mode the integratedpreprocessor is little more than a tokenizer for the front ends.
gcc -fpreprocessed ...
-fdirectives-only
When preprocessing, handle directives, but do not expand macros.The option's behavior depends on the -E and -fpreprocessed options.With -E, preprocessing is limited to the handling of directives such as "#define", "#ifdef", and "#error". Other preprocessoroperations, such as macro expansion and trigraph conversion are not performed. In addition, the -dD option is implicitlyenabled.With -fpreprocessed, predefinition of command line and most builtin macros is disabled. Macros such as "__LINE__", which arecontextually dependent, are handled normally. This enables compilation of files previously preprocessed with "-E
gcc -fdirectives-only ...
-fdirectives-only".
With both -E and -fpreprocessed, the rules for -fpreprocessed take precedence. This enables full preprocessing of filespreviously preprocessed with "-E -fdirectives-only".
gcc -fdirectives-only". ...
-fextended-identifiers
Accept universal character names in identifiers. This option is enabled by default for C99 (and later C standard versions) andC++.
gcc -fextended-identifiers ...
-fno-canonical-system-headers
When preprocessing, do not shorten system header paths with canonicalization.
gcc -fno-canonical-system-headers ...
-ftabstop
Set the distance between tab stops. This helps the preprocessor report correct column numbers in warnings or errors, even iftabs appear on the line. If the value is less than 1 or greater than 100, the option is ignored. The default is 8.
gcc -ftabstop ...
-ftrack-macro-expansion[
Track locations of tokens across macro expansions. This allows the compiler to emit diagnostic about the current macro expansionstack when a compilation error occurs in a macro expansion. Using this option makes the preprocessor and the compiler consumemore memory. The level parameter can be used to choose the level of precision of token location tracking thus decreasing thememory consumption if necessary. Value 0 of level de-activates this option. Value 1 tracks tokens locations in a degraded modefor the sake of minimal memory overhead. In this mode all tokens resulting from the expansion of an argument of a function-likemacro have the same location. Value 2 tracks tokens locations completely. This value is the most memory hungry. When this optionis given no argument, the default parameter value is 2.Note that "-ftrack-macro-expansion=2" is activated by default.
gcc -ftrack-macro-expansion[ ...
-fexec-charset
Set the execution character set, used for string and character constants. The default is UTF-8. charset can be any encodingsupported by the system's "iconv" library routine.
gcc -fexec-charset ...
-fwide-exec-charset
Set the wide execution character set, used for wide string and character constants. The default is UTF-32 or UTF-16, whichevercorresponds to the width of "wchar_t". As with -fexec-charset, charset can be any encoding supported by the system's "iconv"library routine; however, you will have problems with encodings that do not fit exactly in "wchar_t".
gcc -fwide-exec-charset ...
-finput-charset
Set the input character set, used for translation from the character set of the input file to the source character set used byGCC. If the locale does not specify, or GCC cannot get this information from the locale, the default is UTF-8. This can beoverridden by either the locale or this command-line option. Currently the command-line option takes precedence if there's aconflict. charset can be any encoding supported by the system's "iconv" library routine.
gcc -finput-charset ...
-fpch-preprocess
This option allows use of a precompiled header together with -E. It inserts a special "#pragma", "#pragma GCC pch_preprocess"filename"" in the output to mark the place where the precompiled header was found, and its filename. When -fpreprocessed is inuse, GCC recognizes this "#pragma" and loads the PCH.This option is off by default, because the resulting preprocessed output is only really suitable as input to GCC. It is switchedon by -save-temps.You should not write this "#pragma" in your own code, but it is safe to edit the filename if the PCH file is available in adifferent location. The filename may be absolute or it may be relative to GCC's current directory.
gcc -fpch-preprocess ...
-A
Make an assertion with the predicate predicate and answer answer. This form is preferred to the older form -A predicate(answer),which is still supported, because it does not use shell special characters.
gcc -A ...
-traditional-cpp
Try to imitate the behavior of pre-standard C preprocessors, as opposed to ISO C preprocessors. See the GNU CPP manual fordetails.Note that GCC does not otherwise attempt to emulate a pre-standard C compiler, and these options are only supported with the -Eswitch, or when invoking CPP explicitly.
gcc -traditional-cpp ...
-trigraphs
Support ISO C trigraphs. These are three-character sequences, all starting with ??, that are defined by ISO C to stand forsingle characters. For example, ??/ stands for \, so '??/n' is a character constant for a newline.The nine trigraphs and their replacements areTrigraph: ??( ??) ??< ??> ??= ??/ ??' ??! ??-Replacement: [ ] { } # \ ^ | ~By default, GCC ignores trigraphs, but in standard-conforming modes it converts them. See the -std and -ansi options.
gcc -trigraphs ...
-dletters
Says to make debugging dumps during compilation as specified by letters. The flags documented here are those relevant to thepreprocessor. Other letters are interpreted by the compiler proper, or reserved for future versions of GCC, and so are silentlyignored. If you specify letters whose behavior conflicts, the result is undefined.
gcc -dletters ...
-dN
but emit only the macro names not their expansions.
gcc -dN ...
-dI
Output #include directives in addition to the result of preprocessing.
gcc -dI ...
-fdebug-cpp
This option is only useful for debugging GCC. When used from CPP or with -E, it dumps debugging information about location maps.Every token in the output is preceded by the dump of the map its location belongs to.When used from GCC without -E, this option has no effect.
gcc -fdebug-cpp ...
-Wp,option
You can use -Wp,option to bypass the compiler driver and pass option directly through to the preprocessor. If option containscommas, it is split into multiple options at the commas. However, many options are modified, translated or interpreted by thecompiler driver before being passed to the preprocessor, and -Wp forcibly bypasses this phase. The preprocessor's directinterface is undocumented and subject to change, so whenever possible you should avoid using -Wp and let the driver handle theoptions instead.
gcc -Wp,option ...
-Xpreprocessor
Pass option as an option to the preprocessor. You can use this to supply system-specific preprocessor options that GCC does notrecognize.If you want to pass an option that takes an argument, you must use -Xpreprocessor twice, once for the option and once for theargument.
gcc -Xpreprocessor ...
-no-integrated-cpp
Perform preprocessing as a separate pass before compilation. By default, GCC performs preprocessing as an integrated part ofinput tokenization and parsing. If this option is provided, the appropriate language front end (cc1, cc1plus, or cc1obj for C,C++, and Objective-C, respectively) is instead invoked twice, once for preprocessing only and once for actual compilation of thepreprocessed input. This option may be useful in conjunction with the -B or -wrapper options to specify an alternatepreprocessor or perform additional processing of the program source between normal preprocessing and compilation.Passing Options to the AssemblerYou can pass options to the assembler.
gcc -no-integrated-cpp ...
-Xassembler
Pass option as an option to the assembler. You can use this to supply system-specific assembler options that GCC does notrecognize.If you want to pass an option that takes an argument, you must use -Xassembler twice, once for the option and once for theargument.Options for LinkingThese options come into play when the compiler links object files into an executable output file. They are meaningless if thecompiler is not doing a link step.object-file-nameA file name that does not end in a special recognized suffix is considered to name an object file or library. (Object files aredistinguished from libraries by the linker according to the file contents.) If linking is done, these object files are used asinput to the linker.
gcc -Xassembler ...
-E
If any of these options is used, then the linker is not run, and object file names should not be used as arguments.
gcc -E ...
-fuse-ld
Use the bfd linker instead of the default linker.
gcc -fuse-ld ...
-l
Search the library named library when linking. (The second alternative with the library as a separate argument is only for POSIXcompliance and is not recommended.)It makes a difference where in the command you write this option; the linker searches and processes libraries and object files inthe order they are specified. Thus, foo.o -lz bar.o searches library z after file foo.o but before bar.o. If bar.o refers tofunctions in z, those functions may not be loaded.The linker searches a standard list of directories for the library, which is actually a file named liblibrary.a. The linker thenuses this file as if it had been specified precisely by name.The directories searched include several standard system directories plus any that you specify with -L.Normally the files found this way are library files---archive files whose members are object files. The linker handles anarchive file by scanning through it for members which define symbols that have so far been referenced but not defined. But ifthe file that is found is an ordinary object file, it is linked in the usual fashion. The only difference between using an -loption and specifying a file name is that -l surrounds library with lib and .a and searches several directories.
gcc -l ...
-lobjc
You need this special case of the -l option in order to link an Objective-C or Objective-C++ program.
gcc -lobjc ...
-nostartfiles
Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or
gcc -nostartfiles ...
-nodefaultlibs
Do not use the standard system libraries when linking. Only the libraries you specify are passed to the linker, and optionsspecifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, are ignored. The standard startup filesare used normally, unless -nostartfiles is used.The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries inlibc. These entry points should be supplied through some other mechanism when this option is specified.
gcc -nodefaultlibs ...
-nostdlib
Do not use the standard system startup files or libraries when linking. No startup files and only the libraries you specify arepassed to the linker, and options specifying linkage of the system libraries, such as -static-libgcc or -shared-libgcc, areignored.The compiler may generate calls to "memcmp", "memset", "memcpy" and "memmove". These entries are usually resolved by entries inlibc. These entry points should be supplied through some other mechanism when this option is specified.One of the standard libraries bypassed by -nostdlib and -nodefaultlibs is libgcc.a, a library of internal subroutines which GCCuses to overcome shortcomings of particular machines, or special needs for some languages.In most cases, you need libgcc.a even when you want to avoid other standard libraries. In other words, when you specify
gcc -nostdlib ...
-pie
Produce a position independent executable on targets that support it. For predictable results, you must also specify the sameset of options used for compilation (-fpie, -fPIE, or model suboptions) when you specify this linker option.
gcc -pie ...
-no-pie
Don't produce a position independent executable.
gcc -no-pie ...
-rdynamic
Pass the flag -export-dynamic to the ELF linker, on targets that support it. This instructs the linker to add all symbols, notonly used ones, to the dynamic symbol table. This option is needed for some uses of "dlopen" or to allow obtaining backtracesfrom within a program.
gcc -rdynamic ...
-s
Remove all symbol table and relocation information from the executable.
gcc -s ...
-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has noeffect.
gcc -static ...
-shared
Produce a shared object which can then be linked with other objects to form an executable. Not all systems support this option.For predictable results, you must also specify the same set of options used for compilation (-fpic, -fPIC, or model suboptions)when you specify this linker option.[1]
gcc -shared ...
-static-libasan
When the -fsanitize=address option is used to link a program, the GCC driver automatically links against libasan. If libasan isavailable as a shared library, and the -static option is not used, then this links against the shared version of libasan. The
gcc -static-libasan ...
-static-libtsan
When the -fsanitize=thread option is used to link a program, the GCC driver automatically links against libtsan. If libtsan isavailable as a shared library, and the -static option is not used, then this links against the shared version of libtsan. The
gcc -static-libtsan ...
-static-liblsan
When the -fsanitize=leak option is used to link a program, the GCC driver automatically links against liblsan. If liblsan isavailable as a shared library, and the -static option is not used, then this links against the shared version of liblsan. The
gcc -static-liblsan ...
-static-libubsan
When the -fsanitize=undefined option is used to link a program, the GCC driver automatically links against libubsan. If libubsanis available as a shared library, and the -static option is not used, then this links against the shared version of libubsan.The -static-libubsan option directs the GCC driver to link libubsan statically, without necessarily linking other librariesstatically.
gcc -static-libubsan ...
-static-libmpx
When the -fcheck-pointer bounds and -mmpx options are used to link a program, the GCC driver automatically links against libmpx.If libmpx is available as a shared library, and the -static option is not used, then this links against the shared version oflibmpx. The -static-libmpx option directs the GCC driver to link libmpx statically, without necessarily linking other librariesstatically.
gcc -static-libmpx ...
-static-libstdc++
When the g++ program is used to link a C++ program, it normally automatically links against libstdc++. If libstdc++ is availableas a shared library, and the -static option is not used, then this links against the shared version of libstdc++. That isnormally fine. However, it is sometimes useful to freeze the version of libstdc++ used by the program without going all the wayto a fully static link. The -static-libstdc++ option directs the g++ driver to link libstdc++ statically, without necessarilylinking other libraries statically.
gcc -static-libstdc++ ...
-symbolic
Bind references to global symbols when building a shared object. Warn about any unresolved references (unless overridden by thelink editor option -Xlinker -z -Xlinker defs). Only a few systems support this option.
gcc -symbolic ...
-T
Use script as the linker script. This option is supported by most systems using the GNU linker. On some targets, such as bare-board targets without an operating system, the -T option may be required when linking to avoid references to undefined symbols.
gcc -T ...
-Xlinker
Pass option as an option to the linker. You can use this to supply system-specific linker options that GCC does not recognize.If you want to pass an option that takes a separate argument, you must use -Xlinker twice, once for the option and once for theargument. For example, to pass -assert definitions, you must write -Xlinker -assert -Xlinker definitions. It does not work towrite -Xlinker "-assert definitions", because this passes the entire string as a single argument, which is not what the linkerexpects.When using the GNU linker, it is usually more convenient to pass arguments to linker options using the option=value syntax thanas separate arguments. For example, you can specify -Xlinker -Map=output.map rather than -Xlinker -Map -Xlinker output.map.Other linkers may not support this syntax for command-line options.
gcc -Xlinker ...
-Wl,option
Pass option as an option to the linker. If option contains commas, it is split into multiple options at the commas. You can usethis syntax to pass an argument to the option. For example, -Wl,-Map,output.map passes -Map output.map to the linker. Whenusing the GNU linker, you can also get the same effect with -Wl,-Map=output.map.NOTE: In Ubuntu 8.10 and later versions, for LDFLAGS, the option -Wl,-z,relro is used. To disable, use -Wl,-z,norelro.
gcc -Wl,option ...
-u
Pretend the symbol symbol is undefined, to force linking of library modules to define it. You can use -u multiple times withdifferent symbols to force loading of additional library modules.
gcc -u ...
-idirafter
Add the directory dir to the list of directories to be searched for header files during preprocessing. If dir begins with =,then the = is replaced by the sysroot prefix; see --sysroot and -isysroot.Directories specified with -iquote apply only to the quote form of the directive, "#include "file"". Directories specified with
gcc -idirafter ...
-I
You can specify any number or combination of these options on the command line to search for header files in several directories.The lookup order is as follows:1. For the quote form of the include directive, the directory of the current file is searched first.2. For the quote form of the include directive, the directories specified by -iquote options are searched in left-to-rightorder, as they appear on the command line.3. Directories specified with -I options are scanned in left-to-right order.4. Directories specified with -isystem options are scanned in left-to-right order.5. Standard system directories are scanned.6. Directories specified with -idirafter options are scanned in left-to-right order.You can use -I to override a system header file, substituting your own version, since these directories are searched before thestandard system header file directories. However, you should not use this option to add directories that contain vendor-suppliedsystem header files; use -isystem for that.The -isystem and -idirafter options also mark the directory as a system directory, so that it gets the same special treatmentthat is applied to the standard system directories.If a standard system include directory, or a directory specified with -isystem, is also specified with -I, the -I option isignored. The directory is still searched but as a system directory at its normal position in the system include chain. This isto ensure that GCC's procedure to fix buggy system headers and the ordering for the "#include_next" directive are notinadvertently changed. If you really need to change the search order for system directories, use the -nostdinc and/or -isystemoptions.
gcc -I ...
-iprefix
Specify prefix as the prefix for subsequent -iwithprefix options. If the prefix represents a directory, you should include thefinal /.
gcc -iprefix ...
-iwithprefixbefore
Append dir to the prefix specified previously with -iprefix, and add the resulting directory to the include search path.
gcc -iwithprefixbefore ...
-isysroot
This option is like the --sysroot option, but applies only to header files (except for Darwin targets, where it applies to bothheader files and libraries). See the --sysroot option for more information.
gcc -isysroot ...
-imultilib
Use dir as a subdirectory of the directory containing target-specific C++ headers.
gcc -imultilib ...
-nostdinc
Do not search the standard system directories for header files. Only the directories explicitly specified with -I, -iquote,
gcc -nostdinc ...
-iplugindir
Set the directory to search for plugins that are passed by -fplugin=name instead of -fplugin=path/name.so. This option is notmeant to be used by the user, but only passed by the driver.
gcc -iplugindir ...
-Ldir
Add directory dir to the list of directories to be searched for -l.
gcc -Ldir ...
-no-canonical-prefixes
Do not expand any symbolic links, resolve references to /../ or /./, or make the path absolute when generating a relative prefix.
gcc -no-canonical-prefixes ...
--no-sysroot-suffix
For some targets, a suffix is added to the root directory specified with --sysroot, depending on the other options used, so thatheaders may for example be found in dir/suffix/usr/include instead of dir/usr/include. This option disables the addition of sucha suffix.Options for Code Generation ConventionsThese machine-independent options control the interface conventions used in code generation.Most of them have both positive and negative forms; the negative form of -ffoo is -fno-foo. In the table below, only one of theforms is listed---the one that is not the default. You can figure out the other form by either removing no- or adding it.
gcc --no-sysroot-suffix ...
-fstack-reuse
This option controls stack space reuse for user declared local/auto variables and compiler generated temporaries. reuse_levelcan be all, named_vars, or none. all enables stack reuse for all local variables and temporaries, named_vars enables the reuseonly for user defined local variables with names, and none disables stack reuse completely. The default value is all. The optionis needed when the program extends the lifetime of a scoped local variable or a compiler generated temporary beyond the end pointdefined by the language. When a lifetime of a variable ends, and if the variable lives in memory, the optimizing compiler hasthe freedom to reuse its stack space with other temporaries or scoped local variables whose live range does not overlap with it.Legacy code extending local lifetime is likely to break with the stack reuse optimization.For example,int *p;{int local1;p = &local1;local1 = 10;....}{int local2;local2 = 20;...}if (*p == 10) // out of scope use of local1{}Another example:struct A{A(int k) : i(k), j(k) { }int i;int j;};A *ap;void foo(const A& ar){ap = &ar;}void bar(){foo(A(10)); // temp object's lifetime ends when foo returns{A a(20);....}ap->i+= 10; // ap references out of scope temp whose space// is reused with a. What is the value of ap->i?}The lifetime of a compiler generated temporary is well defined by the C++ standard. When a lifetime of a temporary ends, and ifthe temporary lives in memory, the optimizing compiler has the freedom to reuse its stack space with other temporaries or scopedlocal variables whose live range does not overlap with it. However some of the legacy code relies on the behavior of oldercompilers in which temporaries' stack space is not reused, the aggressive stack reuse can lead to runtime errors. This option isused to control the temporary stack reuse optimization.
gcc -fstack-reuse ...
-ftrapv
This option generates traps for signed overflow on addition, subtraction, multiplication operations. The options -ftrapv and
gcc -ftrapv ...
-fwrapv
This option instructs the compiler to assume that signed arithmetic overflow of addition, subtraction and multiplication wrapsaround using twos-complement representation. This flag enables some optimizations and disables others. The options -ftrapv and
gcc -fwrapv ...
-fexceptions
Enable exception handling. Generates extra code needed to propagate exceptions. For some targets, this implies GCC generatesframe unwind information for all functions, which can produce significant data size overhead, although it does not affectexecution. If you do not specify this option, GCC enables it by default for languages like C++ that normally require exceptionhandling, and disables it for languages like C that do not normally require it. However, you may need to enable this option whencompiling C code that needs to interoperate properly with exception handlers written in C++. You may also wish to disable thisoption if you are compiling older C++ programs that don't use exception handling.
gcc -fexceptions ...
-fnon-call-exceptions
Generate code that allows trapping instructions to throw exceptions. Note that this requires platform-specific runtime supportthat does not exist everywhere. Moreover, it only allows trapping instructions to throw exceptions, i.e. memory references orfloating-point instructions. It does not allow exceptions to be thrown from arbitrary signal handlers such as "SIGALRM".
gcc -fnon-call-exceptions ...
-fdelete-dead-exceptions
Consider that instructions that may throw exceptions but don't otherwise contribute to the execution of the program can beoptimized away. This option is enabled by default for the Ada front end, as permitted by the Ada language specification.Optimization passes that cause dead exceptions to be removed are enabled independently at different optimization levels.
gcc -fdelete-dead-exceptions ...
-funwind-tables
Similar to -fexceptions, except that it just generates any needed static data, but does not affect the generated code in anyother way. You normally do not need to enable this option; instead, a language processor that needs this handling enables it onyour behalf.
gcc -funwind-tables ...
-fno-gnu-unique
On systems with recent GNU assembler and C library, the C++ compiler uses the "STB_GNU_UNIQUE" binding to make sure thatdefinitions of template static data members and static local variables in inline functions are unique even in the presence of"RTLD_LOCAL"; this is necessary to avoid problems with a library used by two different "RTLD_LOCAL" plugins depending on adefinition in one of them and therefore disagreeing with the other one about the binding of the symbol. But this causes"dlclose" to be ignored for affected DSOs; if your program relies on reinitialization of a DSO via "dlclose" and "dlopen", youcan use -fno-gnu-unique.
gcc -fno-gnu-unique ...
-fpcc-struct-return
Return "short" "struct" and "union" values in memory like longer ones, rather than in registers. This convention is lessefficient, but it has the advantage of allowing intercallability between GCC-compiled files and files compiled with othercompilers, particularly the Portable C Compiler (pcc).The precise convention for returning structures in memory depends on the target configuration macros.Short structures and unions are those whose size and alignment match that of some integer type.Warning: code compiled with the -fpcc-struct-return switch is not binary compatible with code compiled with the
gcc -fpcc-struct-return ...
-freg-struct-return
switch. Use it to conform to a non-default application binary interface.
gcc -freg-struct-return ...
-fpcc-struct-return.
If you specify neither -fpcc-struct-return nor -freg-struct-return, GCC defaults to whichever convention is standard for thetarget. If there is no standard convention, GCC defaults to -fpcc-struct-return, except on targets where GCC is the principalcompiler. In those cases, we can choose the standard, and we chose the more efficient register return alternative.Warning: code compiled with the -freg-struct-return switch is not binary compatible with code compiled with the
gcc -fpcc-struct-return. ...
-fshort-enums
Allocate to an "enum" type only as many bytes as it needs for the declared range of possible values. Specifically, the "enum"type is equivalent to the smallest integer type that has enough room.Warning: the -fshort-enums switch causes GCC to generate code that is not binary compatible with code generated without thatswitch. Use it to conform to a non-default application binary interface.
gcc -fshort-enums ...
-fshort-wchar
Override the underlying type for "wchar_t" to be "short unsigned int" instead of the default for the target. This option isuseful for building programs to run under WINE.Warning: the -fshort-wchar switch causes GCC to generate code that is not binary compatible with code generated without thatswitch. Use it to conform to a non-default application binary interface.
gcc -fshort-wchar ...
-fno-common
In C code, this option controls the placement of global variables defined without an initializer, known as tentative definitionsin the C standard. Tentative definitions are distinct from declarations of a variable with the "extern" keyword, which do notallocate storage.Unix C compilers have traditionally allocated storage for uninitialized global variables in a common block. This allows thelinker to resolve all tentative definitions of the same variable in different compilation units to the same object, or to a non-tentative definition. This is the behavior specified by -fcommon, and is the default for GCC on most targets. On the otherhand, this behavior is not required by ISO C, and on some targets may carry a speed or code size penalty on variable references.The -fno-common option specifies that the compiler should instead place uninitialized global variables in the data section of theobject file. This inhibits the merging of tentative definitions by the linker so you get a multiple-definition error if the samevariable is defined in more than one compilation unit. Compiling with -fno-common is useful on targets for which it providesbetter performance, or if you wish to verify that the program will work on other systems that always treat uninitialized variabledefinitions this way.
gcc -fno-common ...
-fno-ident
Ignore the "#ident" directive.
gcc -fno-ident ...
-finhibit-size-directive
Don't output a ".size" assembler directive, or anything else that would cause trouble if the function is split in the middle, andthe two halves are placed at locations far apart in memory. This option is used when compiling crtstuff.c; you should not needto use it for anything else.
gcc -finhibit-size-directive ...
-fverbose-asm
Put extra commentary information in the generated assembly code to make it more readable. This option is generally only of useto those who actually need to read the generated assembly code (perhaps while debugging the compiler itself).
gcc -fverbose-asm ...