Linux "cc" 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
cc -c ...
-ansi
-std=standard -fgnu89-inline -fpermitted-flt-eval-methods=standard -aux-info filename
cc -ansi ...
-fallow-parameterless-variadic-functions
-fno-asm -fno-builtin -fno-builtin-function -fgimple -fhosted -ffreestanding
cc -fallow-parameterless-variadic-functions ...
-fopenacc
-fopenmp -fopenmp-simd -fms-extensions -fplan9-extensions -fsso-struct=endianness -fallow-single-precision
cc -fopenacc ...
-fabi-version
-fno-access-control -faligned-new=n -fargs-in-order=n -fcheck-new -fconstexpr-depth=n
cc -fabi-version ...
-fconstexpr-loop-limit
-ffriend-injection -fno-elide-constructors -fno-enforce-eh-specs -ffor-scope -fno-for-scope
cc -fconstexpr-loop-limit ...
-fno-gnu-keywords
-fno-implicit-templates -fno-implicit-inline-templates -fno-implement-inlines -fms-extensions
cc -fno-gnu-keywords ...
-fnew-inheriting-ctors
-fnew-ttp-matching -fno-nonansi-builtins -fnothrow-opt -fno-operator-names -fno-optional-diags
cc -fnew-inheriting-ctors ...
-fpermissive
-fno-pretty-templates -frepo -fno-rtti -fsized-deallocation -ftemplate-backtrace-limit=n -ftemplate-depth=n
cc -fpermissive ...
-fno-threadsafe-statics
-fuse-cxa-atexit -fno-weak -nostdinc++ -fvisibility-inlines-hidden -fvisibility-ms-compat
cc -fno-threadsafe-statics ...
-fext-numeric-literals
-Wabi=n -Wabi-tag -Wconversion-null -Wctor-dtor-privacy -Wdelete-non-virtual-dtor -Wliteral-suffix
cc -fext-numeric-literals ...
-Wmultiple-inheritance
-Wnamespaces -Wnarrowing -Wnoexcept -Wnoexcept-type -Wnon-virtual-dtor -Wreorder -Wregister -Weffc++
cc -Wmultiple-inheritance ...
-Wstrict-null-sentinel
-Wtemplates -Wno-non-template-friend -Wold-style-cast -Woverloaded-virtual -Wno-pmf-conversions
cc -Wstrict-null-sentinel ...
-Wsign-promo
Objective-C and Objective-C++ Language Options
cc -Wsign-promo ...
-fconstant-string-class
-fgnu-runtime -fnext-runtime -fno-nil-receivers -fobjc-abi-version=n -fobjc-call-cxx-cdtors
cc -fconstant-string-class ...
-fobjc-direct-dispatch
-fobjc-exceptions -fobjc-gc -fobjc-nilcheck -fobjc-std=objc1 -fno-local-ivars
cc -fobjc-direct-dispatch ...
-fivar-visibility
-freplace-objc-classes -fzero-link -gen-decls -Wassign-intercept
cc -fivar-visibility ...
-Wno-protocol
Diagnostic Message Formatting Options
cc -Wno-protocol ...
-fmessage-length
-fdiagnostics-show-location=[once|every-line] -fdiagnostics-color=[auto|never|always]
cc -fmessage-length ...
-fno-diagnostics-show-option
-fno-diagnostics-show-caret -fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
cc -fno-diagnostics-show-option ...
-fsyntax-only
-fmax-errors=n -Wpedantic -pedantic-errors -w -Wextra -Wall -Waddress -Waggregate-return -Walloc-zero
cc -fsyntax-only ...
-Walloc-size-larger-than
-Walloca -Walloca-larger-than=n -Wno-aggressive-loop-optimizations -Warray-bounds -Warray-bounds=n
cc -Walloc-size-larger-than ...
-Wno-attributes
-Wbool-compare -Wbool-operation -Wno-builtin-declaration-mismatch -Wno-builtin-macro-redefined
cc -Wno-attributes ...
-Wc90-c99-compat
-Wc99-c11-compat -Wc++-compat -Wc++11-compat -Wc++14-compat -Wcast-align -Wcast-qual -Wchar-subscripts
cc -Wc90-c99-compat ...
-Wchkp
-Wclobbered -Wcomment -Wconditionally-supported -Wconversion -Wcoverage-mismatch -Wno-cpp -Wdangling-else
cc -Wchkp ...
-Wdate-time
-Wdelete-incomplete -Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init -Wdisabled-optimization
cc -Wdate-time ...
-Wno-discarded-qualifiers
-Wno-discarded-array-qualifiers -Wno-div-by-zero -Wdouble-promotion -Wduplicated-branches
cc -Wno-discarded-qualifiers ...
-Wduplicated-cond
-Wempty-body -Wenum-compare -Wno-endif-labels -Wexpansion-to-defined -Werror -Werror=* -Wfatal-errors
cc -Wduplicated-cond ...
-Wfloat-equal
-Wformat -Wformat=2 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral -Wformat-overflow=n
cc -Wfloat-equal ...
-Wformat-security
-Wformat-signedness -Wformat-truncation=n -Wformat-y2k -Wframe-address -Wframe-larger-than=len
cc -Wformat-security ...
-Wno-free-nonheap-object
-Wjump-misses-init -Wignored-qualifiers -Wignored-attributes -Wincompatible-pointer-types -Wimplicit
cc -Wno-free-nonheap-object ...
-Wimplicit-fallthrough
-Wimplicit-fallthrough=n -Wimplicit-function-declaration -Wimplicit-int -Winit-self -Winline
cc -Wimplicit-fallthrough ...
-Wno-int-conversion
-Wint-in-bool-context -Wno-int-to-pointer-cast -Winvalid-memory-model -Wno-invalid-offsetof -Winvalid-pch
cc -Wno-int-conversion ...
-Wlarger-than
-Wlogical-op -Wlogical-not-parentheses -Wlong-long -Wmain -Wmaybe-uninitialized -Wmemset-elt-size
cc -Wlarger-than ...
-Wmemset-transposed-args
-Wmisleading-indentation -Wmissing-braces -Wmissing-field-initializers -Wmissing-include-dirs
cc -Wmemset-transposed-args ...
-Wno-multichar
-Wnonnull -Wnonnull-compare -Wnormalized=[none|id|nfc|nfkc] -Wnull-dereference -Wodr -Wno-overflow
cc -Wno-multichar ...
-Wopenmp-simd
-Woverride-init-side-effects -Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded -Wparentheses
cc -Wopenmp-simd ...
-Wno-pedantic-ms-format
-Wplacement-new -Wplacement-new=n -Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast
cc -Wno-pedantic-ms-format ...
-Wno-pragmas
-Wredundant-decls -Wrestrict -Wno-return-local-addr -Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar
cc -Wno-pragmas ...
-Wshadow
-Wshadow=local -Wshadow=compatible-local -Wshift-overflow -Wshift-overflow=n -Wshift-count-negative
cc -Wshadow ...
-Wshift-count-overflow
-Wshift-negative-value -Wsign-compare -Wsign-conversion -Wfloat-conversion -Wno-scalar-storage-order
cc -Wshift-count-overflow ...
-Wsizeof-pointer-memaccess
-Wsizeof-array-argument -Wstack-protector -Wstack-usage=len -Wstrict-aliasing -Wstrict-aliasing=n
cc -Wsizeof-pointer-memaccess ...
-Wstrict-overflow
-Wstrict-overflow=n -Wstringop-overflow=n -Wsuggest-attribute=[pure|const|noreturn|format]
cc -Wstrict-overflow ...
-Wsuggest-final-types
-Wsuggest-final-methods -Wsuggest-override -Wmissing-format-attribute -Wsubobject-linkage -Wswitch
cc -Wsuggest-final-types ...
-Wswitch-bool
-Wswitch-default -Wswitch-enum -Wswitch-unreachable -Wsync-nand -Wsystem-headers -Wtautological-compare
cc -Wswitch-bool ...
-Wtrampolines
-Wtrigraphs -Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations
cc -Wtrampolines ...
-Wunsuffixed-float-constants
-Wunused -Wunused-function -Wunused-label -Wunused-local-typedefs -Wunused-macros
cc -Wunsuffixed-float-constants ...
-Wunused-parameter
-Wno-unused-result -Wunused-value -Wunused-variable -Wunused-const-variable -Wunused-const-variable=n
cc -Wunused-parameter ...
-Wunused-but-set-parameter
-Wunused-but-set-variable -Wuseless-cast -Wvariadic-macros -Wvector-operation-performance -Wvla
cc -Wunused-but-set-parameter ...
-Wbad-function-cast
-Wmissing-declarations -Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs
cc -Wbad-function-cast ...
-Wold-style-declaration
-Wold-style-definition -Wstrict-prototypes -Wtraditional -Wtraditional-conversion
cc -Wold-style-declaration ...
-Wdeclaration-after-statement
Debugging Options
cc -Wdeclaration-after-statement ...
-g
-glevel -gcoff -gdwarf -gdwarf-version -ggdb -grecord-gcc-switches -gno-record-gcc-switches -gstabs -gstabs+
cc -g ...
-gstrict-dwarf
-gno-strict-dwarf -gcolumn-info -gno-column-info -gvms -gxcoff -gxcoff+ -gz[=type] -fdebug-prefix-map=old=new
cc -gstrict-dwarf ...
-fdebug-types-section
-feliminate-dwarf2-dups -fno-eliminate-unused-debug-types -femit-struct-debug-baseonly
cc -fdebug-types-section ...
-femit-struct-debug-reduced
-femit-struct-debug-detailed[=spec-list] -feliminate-unused-debug-symbols -femit-class-debug-always
cc -femit-struct-debug-reduced ...
-fno-merge-debug-strings
Optimization Options
cc -fno-merge-debug-strings ...
-faggressive-loop-optimizations
-falign-functions[=n] -falign-jumps[=n] -falign-labels[=n] -falign-loops[=n] -fassociative-math
cc -faggressive-loop-optimizations ...
-fauto-profile
-fauto-profile[=path] -fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize
cc -fauto-profile ...
-fbranch-target-load-optimize2
-fbtr-bb-exclusive -fcaller-saves -fcombine-stack-adjustments -fconserve-stack -fcompare-elim
cc -fbranch-target-load-optimize2 ...
-fcprop-registers
-fcrossjumping -fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules -fcx-limited-range -fdata-sections
cc -fcprop-registers ...
-fdce
-fdelayed-branch -fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fdevirtualize-at-ltrans
cc -fdce ...
-fdse
-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects -ffast-math -ffinite-math-only -ffloat-store
cc -fdse ...
-fexcess-precision
-fforward-propagate -ffp-contract=style -ffunction-sections -fgcse -fgcse-after-reload -fgcse-las
cc -fexcess-precision ...
-fgcse-lm
-fgraphite-identity -fgcse-sm -fhoist-adjacent-loads -fif-conversion -fif-conversion2 -findirect-inlining
cc -fgcse-lm ...
-finline-functions
-finline-functions-called-once -finline-limit=n -finline-small-functions -fipa-cp -fipa-cp-clone
cc -finline-functions ...
-fipa-bit-cp
-fipa-vrp -fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf -fira-algorithm=algorithm
cc -fipa-bit-cp ...
-fira-region
-fira-hoist-pressure -fira-loop-pressure -fno-ira-share-save-slots -fno-ira-share-spill-slots
cc -fira-region ...
-fisolate-erroneous-paths-dereference
-fisolate-erroneous-paths-attribute -fivopts -fkeep-inline-functions
cc -fisolate-erroneous-paths-dereference ...
-fkeep-static-functions
-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage -floop-block -floop-interchange
cc -fkeep-static-functions ...
-floop-strip-mine
-floop-unroll-and-jam -floop-nest-optimize -floop-parallelize-all -flra-remat -flto -flto-compression-level
cc -floop-strip-mine ...
-flto-partition
-fmerge-all-constants -fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
cc -flto-partition ...
-fmove-loop-invariants
-fno-branch-count-reg -fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
cc -fmove-loop-invariants ...
-fno-guess-branch-probability
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2 -fno-printf-return-value
cc -fno-guess-branch-probability ...
-fno-sched-interblock
-fno-sched-spec -fno-signed-zeros -fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
cc -fno-sched-interblock ...
-fomit-frame-pointer
-foptimize-sibling-calls -fpartial-inlining -fpeel-loops -fpredictive-commoning -fprefetch-loop-arrays
cc -fomit-frame-pointer ...
-fprofile-correction
-fprofile-use -fprofile-use=path -fprofile-values -fprofile-reorder-functions -freciprocal-math -free
cc -fprofile-correction ...
-frename-registers
-freorder-blocks -freorder-blocks-algorithm=algorithm -freorder-blocks-and-partition -freorder-functions
cc -frename-registers ...
-frerun-cse-after-loop
-freschedule-modulo-scheduled-loops -frounding-math -fsched2-use-superblocks -fsched-pressure
cc -frerun-cse-after-loop ...
-fsched-spec-load
-fsched-spec-load-dangerous -fsched-stalled-insns-dep[=n] -fsched-stalled-insns[=n] -fsched-group-heuristic
cc -fsched-spec-load ...
-fsched-critical-path-heuristic
-fsched-spec-insn-heuristic -fsched-rank-heuristic -fsched-last-insn-heuristic
cc -fsched-critical-path-heuristic ...
-fsched-dep-count-heuristic
-fschedule-fusion -fschedule-insns -fschedule-insns2 -fsection-anchors -fselective-scheduling
cc -fsched-dep-count-heuristic ...
-fselective-scheduling2
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops -fsemantic-interposition -fshrink-wrap
cc -fselective-scheduling2 ...
-fshrink-wrap-separate
-fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops -fsplit-paths
cc -fshrink-wrap-separate ...
-fsplit-wide-types
-fssa-backprop -fssa-phiopt -fstdarg-opt -fstore-merging -fstrict-aliasing -fstrict-overflow
cc -fsplit-wide-types ...
-fthread-jumps
-ftracer -ftree-bit-ccp -ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-coalesce-vars -ftree-copy-prop
cc -fthread-jumps ...
-ftree-dce
-ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting -ftree-loop-if-convert -ftree-loop-im
cc -ftree-dce ...
-ftree-phiprop
-ftree-loop-distribution -ftree-loop-distribute-patterns -ftree-loop-ivcanon -ftree-loop-linear
cc -ftree-phiprop ...
-ftree-loop-optimize
-ftree-loop-vectorize -ftree-parallelize-loops=n -ftree-pre -ftree-partial-pre -ftree-pta -ftree-reassoc
cc -ftree-loop-optimize ...
-ftree-sink
-ftree-slsr -ftree-sra -ftree-switch-conversion -ftree-tail-merge -ftree-ter -ftree-vectorize -ftree-vrp
cc -ftree-sink ...
-funconstrained-commons
-funit-at-a-time -funroll-all-loops -funroll-loops -funsafe-math-optimizations -funswitch-loops
cc -funconstrained-commons ...
-p
-pg -fprofile-arcs --coverage -ftest-coverage -fprofile-dir=path -fprofile-generate -fprofile-generate=path
cc -p ...
-fsanitize
-fsanitize-recover -fsanitize-recover=style -fasan-shadow-offset=number -fsanitize-sections=s1,s2,...
cc -fsanitize ...
-fsanitize-undefined-trap-on-error
-fbounds-check -fcheck-pointer-bounds -fchkp-check-incomplete-type
cc -fsanitize-undefined-trap-on-error ...
-fchkp-first-field-has-own-bounds
-fchkp-narrow-bounds -fchkp-narrow-to-innermost-array -fchkp-optimize
cc -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
cc -fchkp-use-fast-string-functions ...
-fchkp-treat-zero-dynamic-size-as-infinite
-fchkp-check-read -fchkp-check-read -fchkp-check-write -fchkp-store-bounds
cc -fchkp-treat-zero-dynamic-size-as-infinite ...
-fchkp-instrument-calls
-fchkp-instrument-marked-only -fchkp-use-wrappers -fchkp-flexible-struct-trailing-arrays
cc -fchkp-instrument-calls ...
-fstack-protector
-fstack-protector-all -fstack-protector-strong -fstack-protector-explicit -fstack-check
cc -fstack-protector ...
-fstack-limit-register
-fstack-limit-symbol=sym -fno-stack-limit -fsplit-stack -fvtable-verify=[std|preinit|none]
cc -fstack-limit-register ...
-fvtv-counts
-fvtv-debug -finstrument-functions -finstrument-functions-exclude-function-list=sym,sym,...
cc -fvtv-counts ...
-finstrument-functions-exclude-file-list
Preprocessor Options
cc -finstrument-functions-exclude-file-list ...
-Aquestion
-A-question[=answer] -C -CC -Dmacro[=defn] -dD -dI -dM -dN -dU -fdebug-cpp -fdirectives-only
cc -Aquestion ...
-fdollars-in-identifiers
-fexec-charset=charset -fextended-identifiers -finput-charset=charset -fno-canonical-system-headers
cc -fdollars-in-identifiers ...
-fpch-deps
-fpch-preprocess -fpreprocessed -ftabstop=width -ftrack-macro-expansion -fwide-exec-charset=charset
cc -fpch-deps ...
-fworking-directory
-H -imacros file -include file -M -MD -MF -MG -MM -MMD -MP -MQ -MT -no-integrated-cpp -P -pthread
cc -fworking-directory ...
-remap
Assembler Options
cc -remap ...
-Wa,option
Linker Optionsobject-file-name -fuse-ld=linker -llibrary -nostartfiles -nodefaultlibs -nostdlib -pie -pthread -rdynamic -s -static
cc -Wa,option ...
-static-libgcc
-static-libstdc++ -static-libasan -static-libtsan -static-liblsan -static-libubsan -static-libmpx
cc -static-libgcc ...
-static-libmpxwrappers
Directory Options
cc -static-libmpxwrappers ...
-Bprefix
-Idir -I- -idirafter dir -imacros file -imultilib dir -iplugindir=dir -iprefix file -iquote dir -isysroot dir
cc -Bprefix ...
-isystem
dir -iwithprefix dir -iwithprefixbefore dir -Ldir -no-canonical-prefixes --no-sysroot-suffix -nostdinc -nostdinc++
cc -isystem ...
--sysroot
Code Generation Options
cc --sysroot ...
-fcall-saved-reg
-fcall-used-reg -ffixed-reg -fexceptions -fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
cc -fcall-saved-reg ...
-fasynchronous-unwind-tables
-fno-gnu-unique -finhibit-size-directive -fno-common -fno-ident -fpcc-struct-return -fpic -fPIC
cc -fasynchronous-unwind-tables ...
-fpie
-fPIE -fno-plt -fno-jump-tables -frecord-gcc-switches -freg-struct-return -fshort-enums -fshort-wchar -fverbose-asm
cc -fpie ...
-fpack-struct[
-fleading-underscore -ftls-model=model -fstack-reuse=reuse_level -ftrampolines -ftrapv -fwrapv
cc -fpack-struct[ ...
-fvisibility
Developer Options
cc -fvisibility ...
-fdisable-tree-pass-name
-fdump-noaddr -fdump-unnumbered -fdump-unnumbered-links -fdump-translation-unit[-n]
cc -fdisable-tree-pass-name ...
-fdump-class-hierarchy[-n]
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline -fdump-passes -fdump-rtl-pass
cc -fdump-class-hierarchy[-n] ...
-fdump-rtl-pass
-fdump-statistics -fdump-final-insns[=file] -fdump-tree-all -fdump-tree-switch
cc -fdump-rtl-pass ...
-fdump-tree-switch-options
-fdump-tree-switch-options=filename -fcompare-debug[=opts] -fcompare-debug-second -fenable-kind-pass
cc -fdump-tree-switch-options ...
-fenable-kind-pass
-fira-verbose=n -flto-report -flto-report-wpa -fmem-report-wpa -fmem-report -fpre-ipa-mem-report
cc -fenable-kind-pass ...
-fpost-ipa-mem-report
-fopt-info -fopt-info-options[=file] -fprofile-report -frandom-seed=string -fsched-verbose=n
cc -fpost-ipa-mem-report ...
-fsel-sched-verbose
-fsel-sched-dump-cfg -fsel-sched-pipelining-verbose -fstats -fstack-usage -ftime-report
cc -fsel-sched-verbose ...
-ftime-report-details
-fvar-tracking-assignments-toggle -gtoggle -print-file-name=library -print-libgcc-file-name
cc -ftime-report-details ...
-print-multi-directory
-print-multi-lib -print-multi-os-directory -print-prog-name=program -print-search-dirs -Q
cc -print-multi-directory ...
-mstrict-align
-momit-leaf-frame-pointer -mno-omit-leaf-frame-pointer -mtls-dialect=desc -mtls-dialect=traditional
cc -mstrict-align ...
-mtls-size
-mfix-cortex-a53-835769 -mno-fix-cortex-a53-835769 -mfix-cortex-a53-843419 -mno-fix-cortex-a53-843419
cc -mtls-size ...
-mlow-precision-recip-sqrt
-mno-low-precision-recip-sqrt -mlow-precision-sqrt -mno-low-precision-sqrt -mlow-precision-div
cc -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
cc -mno-low-precision-div ...
-msplit-lohi
-mpost-inc -mpost-modify -mstack-offset=num -mround-nearest -mlong-calls -mshort-calls -msmall16
cc -msplit-lohi ...
-mfp-mode=mode
ARC Options -mbarrel-shifter -mcpu=cpu -mA6 -mARC600 -mA7 -mARC700 -mdpfp -mdpfp-compact -mdpfp-fast -mno-dpfp-lrsr -mea
cc -mfp-mode=mode ...
-mno-mpy
-mmul32x16 -mmul64 -matomic -mnorm -mspfp -mspfp-compact -mspfp-fast -msimd -msoft-float -mswap -mcrc
cc -mno-mpy ...
-mdsp-packa
-mdvbf -mlock -mmac-d16 -mmac-24 -mrtsc -mswape -mtelephony -mxy -misize -mannotate-align -marclinux
cc -mdsp-packa ...
-marclinux_prof
-mlong-calls -mmedium-calls -msdata -mvolatile-cache -mtp-regno=regno -malign-call -mauto-modify-reg
cc -marclinux_prof ...
-mbbit-peephole
-mno-brcc -mcase-vector-pcrel -mcompact-casesi -mno-cond-exec -mearly-cbranchsi -mexpand-adddi
cc -mbbit-peephole ...
-mindexed-loads
-mlra -mlra-priority-none -mlra-priority-compact mlra-priority-noncompact -mno-millicode -mmixed-code
cc -mindexed-loads ...
-mq-class
-mRcq -mRcw -msize-level=level -mtune=cpu -mmultcost=num -munalign-prob-threshold=probability -mmpy-option=multo
cc -mq-class ...
-mdiv-rem
ARM Options -mapcs-frame -mno-apcs-frame -mabi=name -mapcs-stack-check -mno-apcs-stack-check -mapcs-reentrant
cc -mdiv-rem ...
-mno-apcs-reentrant
-msched-prolog -mno-sched-prolog -mlittle-endian -mbig-endian -mfloat-abi=name -mfp16-format=name
cc -mno-apcs-reentrant ...
-mthumb-interwork
-mno-thumb-interwork -mcpu=name -march=name -mfpu=name -mtune=name -mprint-tune-info
cc -mthumb-interwork ...
-mstructure-size-boundary
-mabort-on-noreturn -mlong-calls -mno-long-calls -msingle-pic-base -mno-single-pic-base
cc -mstructure-size-boundary ...
-mpic-register
-mnop-fun-dllimport -mpoke-function-name -mthumb -marm -mtpcs-frame -mtpcs-leaf-frame
cc -mpic-register ...
-mcaller-super-interworking
-mcallee-super-interworking -mtp=name -mtls-dialect=dialect -mword-relocations -mfix-cortex-m3-ldrd
cc -mcaller-super-interworking ...
-munaligned-access
AVR Options -mmcu=mcu -mabsdata -maccumulate-args -mbranch-cost=cost -mcall-prologues -mint8 -mn_flash=size -mno-interrupts
cc -munaligned-access ...
-mno-specld-anomaly
-mcsync-anomaly -mno-csync-anomaly -mlow-64k -mno-low64k -mstack-check-l1 -mid-shared-library
cc -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
cc -mno-id-shared-library ...
-mcc-init
-mno-side-effects -mstack-align -mdata-align -mconst-align -m32-bit -m16-bit -m8-bit -mno-prologue-epilogue
cc -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
cc -mno-gotplt ...
-client_name
-compatibility_version -current_version -dead_strip -dependency-file -dylib_file -dylinker_install_name -dynamic
cc -client_name ...
-dynamiclib
-exported_symbols_list -filelist -flat_namespace -force_cpusubtype_ALL -force_flat_namespace
cc -dynamiclib ...
-headerpad_max_install_names
-iframework -image_base -init -install_name -keep_private_externs -multi_module
cc -headerpad_max_install_names ...
-multiply_defined
-multiply_defined_unused -noall_load -no_dead_strip_inits_and_terms -nofixprebinding -nomultidefs
cc -multiply_defined ...
-noprebind
-noseglinkedit -pagezero_size -prebind -prebind_all_twolevel_modules -private_bundle -read_only_relocs -sectalign
cc -noprebind ...
-sectobjectsymbols
-whyload -seg1addr -sectcreate -sectobjectsymbols -sectorder -segaddr -segs_read_only_addr
cc -sectobjectsymbols ...
-segs_read_write_addr
-seg_addr_table -seg_addr_table_filename -seglinkedit -segprot -segs_read_only_addr
cc -segs_read_write_addr ...
-unexported_symbols_list
-weak_reference_mismatches -whatsloaded -F -gused -gfull -mmacosx-version-min=version -mkernel
cc -unexported_symbols_list ...
-mone-byte-bool
DEC Alpha Options -mno-fp-regs -msoft-float -mieee -mieee-with-inexact -mieee-conformant -mfp-trap-mode=mode
cc -mone-byte-bool ...
-mfp-rounding-mode
-mtrap-precision=mode -mbuild-constants -mcpu=cpu-type -mtune=cpu-type -mbwx -mmax -mfix -mcix
cc -mfp-rounding-mode ...
-mdouble
-mno-double -mmedia -mno-media -mmuladd -mno-muladd -mfdpic -minline-plt -mgprel-ro -multilib-library-pic
cc -mdouble ...
-mlinked-fp
-mlong-calls -malign-labels -mlibrary-pic -macc-4 -macc-8 -mpack -mno-pack -mno-eflags -mcond-move
cc -mlinked-fp ...
-mno-cond-move
-moptimize-membar -mno-optimize-membar -mscc -mno-scc -mcond-exec -mno-cond-exec -mvliw-branch
cc -mno-cond-move ...
-mno-vliw-branch
-mmulti-cond-exec -mno-multi-cond-exec -mnested-cond-exec -mno-nested-cond-exec -mtomcat-stats -mTLS -mtls
cc -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
cc -mcpu ...
-mgnu-ld
-mhp-ld -mfixed-range=register-range -mjump-in-delay -mlinker-opt -mlong-calls -mlong-load-store
cc -mgnu-ld ...
-mno-disable-fpregs
-mno-disable-indexing -mno-fast-indirect-calls -mno-gas -mno-jump-in-delay -mno-long-load-store
cc -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
cc -mno-portable-runtime ...
-mportable-runtime
IA-64 Options -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic -mvolatile-asm-stop -mregister-names -msdata
cc -mportable-runtime ...
-mno-sdata
-mconstant-gp -mauto-pic -mfused-madd -minline-float-divide-min-latency -minline-float-divide-max-throughput
cc -mno-sdata ...
-mno-inline-float-divide
-minline-int-divide-min-latency -minline-int-divide-max-throughput -mno-inline-int-divide
cc -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
cc -msched-br-in-data-spec ...
-msched-prefer-non-data-spec-insns
-msched-prefer-non-control-spec-insns -msched-stop-bits-after-every-cycle
cc -msched-prefer-non-data-spec-insns ...
-msched-count-spec-in-critical-path
-msel-sched-dont-check-control-spec -msched-fp-mem-deps-zero-cost
cc -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
cc -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
cc -mmodel ...
-m5200
-m5206e -m528x -m5307 -m5407 -mcfv4e -mbitfield -mno-bitfield -mc68000 -mc68020 -mnobitfield -mrtd -mno-rtd
cc -m5200 ...
-mdiv
-mno-div -mshort -mno-short -mhard-float -m68881 -msoft-float -mpcrel -malign-int -mstrict-align -msep-data
cc -mdiv ...
-mno-sep-data
MCore Options -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates -mno-relax-immediates -mwide-bitfields
cc -mno-sep-data ...
-mno-wide-bitfields
-m4byte-functions -mno-4byte-functions -mcallgraph-data -mno-callgraph-data -mslow-bytes -mno-slow-bytes
cc -mno-wide-bitfields ...
-mno-lsim
MeP Options -mabsdiff -mall-opts -maverage -mbased=n -mbitops -mc=n -mclip -mconfig=name -mcop -mcop32 -mcop64 -mivc2
cc -mno-lsim ...
-mdc
-mdiv -meb -mel -mio-volatile -ml -mleadz -mm -mminmax -mmult -mno-opts -mrepeat -ms -msatur -msdram -msim
cc -mdc ...
-msimnovec
MicroBlaze Options -msoft-float -mhard-float -msmall-divides -mcpu=cpu -mmemcpy -mxl-soft-mul -mxl-soft-div
cc -msimnovec ...
-mxl-barrel-shift
-mxl-pattern-compare -mxl-stack-check -mxl-gp-opt -mno-clearbss -mxl-multiply-high -mxl-float-convert
cc -mxl-barrel-shift ...
-mxl-float-sqrt
MIPS Options -EL -EB -march=arch -mtune=arch -mips1 -mips2 -mips3 -mips4 -mips32 -mips32r2 -mips32r3 -mips32r5
cc -mxl-float-sqrt ...
-mips32r6
-mips64 -mips64r2 -mips64r3 -mips64r5 -mips64r6 -mips16 -mno-mips16 -mflip-mips16 -minterlink-compressed
cc -mips32r6 ...
-mno-interlink-compressed
-minterlink-mips16 -mno-interlink-mips16 -mabi=abi -mabicalls -mno-abicalls -mshared -mno-shared
cc -mno-interlink-compressed ...
-mplt
-mno-plt -mxgot -mno-xgot -mgp32 -mgp64 -mfp32 -mfpxx -mfp64 -mhard-float -msoft-float -mno-float -msingle-float
cc -mplt ...
-mdouble-float
-modd-spreg -mno-odd-spreg -mabs=mode -mnan=encoding -mdsp -mno-dsp -mdspr2 -mno-dspr2 -mmcu -mmno-mcu -meva
cc -mdouble-float ...
-mno-eva
-mvirt -mno-virt -mxpa -mno-xpa -mmicromips -mno-micromips -mmsa -mno-msa -mfpu=fpu-type -msmartmips -mno-smartmips
cc -mno-eva ...
-mpaired-single
-mno-paired-single -mdmx -mno-mdmx -mips3d -mno-mips3d -mmt -mno-mt -mllsc -mno-llsc -mlong64 -mlong32
cc -mpaired-single ...
-msym32
-mno-sym32 -Gnum -mlocal-sdata -mno-local-sdata -mextern-sdata -mno-extern-sdata -mgpopt -mno-gopt -membedded-data
cc -msym32 ...
-mno-embedded-data
-muninit-const-in-rodata -mno-uninit-const-in-rodata -mcode-readable=setting -msplit-addresses
cc -mno-embedded-data ...
-mno-split-addresses
-mexplicit-relocs -mno-explicit-relocs -mcheck-zero-division -mno-check-zero-division -mdivide-traps
cc -mno-split-addresses ...
-mdivide-breaks
-mload-store-pairs -mno-load-store-pairs -mmemcpy -mno-memcpy -mlong-calls -mno-long-calls -mmad -mno-mad
cc -mdivide-breaks ...
-mimadd
-mno-imadd -mfused-madd -mno-fused-madd -nocpp -mfix-24k -mno-fix-24k -mfix-r4000 -mno-fix-r4000 -mfix-r4400
cc -mimadd ...
-mno-fix-r4400
-mfix-r10000 -mno-fix-r10000 -mfix-rm7000 -mno-fix-rm7000 -mfix-vr4120 -mno-fix-vr4120 -mfix-vr4130
cc -mno-fix-r4400 ...
-mno-fix-vr4130
-mfix-sb1 -mno-fix-sb1 -mflush-func=func -mno-flush-func -mbranch-cost=num -mbranch-likely
cc -mno-fix-vr4130 ...
-mno-branch-likely
-mcompact-branches=policy -mfp-exceptions -mno-fp-exceptions -mvr4130-align -mno-vr4130-align -msynci
cc -mno-branch-likely ...
-mno-synci
-mlxc1-sxc1 -mno-lxc1-sxc1 -mmadd4 -mno-madd4 -mrelax-pic-calls -mno-relax-pic-calls -mmcount-ra-address
cc -mno-synci ...
-mframe-header-opt
MMIX Options -mlibfuncs -mno-libfuncs -mepsilon -mno-epsilon -mabi=gnu -mabi=mmixware -mzero-extend -mknuthdiv
cc -mframe-header-opt ...
-mtoplevel-symbols
-melf -mbranch-predict -mno-branch-predict -mbase-addresses -mno-base-addresses -msingle-exit
cc -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
cc -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=
cc -mrelax ...
-msilicon-errata=
NDS32 Options -mbig-endian -mlittle-endian -mreduced-regs -mfull-regs -mcmov -mno-cmov -mperf-ext -mno-perf-ext -mv3push
cc -msilicon-errata= ...
-mno-v3push
Nios II Options -G num -mgpopt=option -mgpopt -mno-gpopt -mel -meb -mno-bypass-cache -mbypass-cache -mno-cache-volatile
cc -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
cc -mcache-volatile ...
-mcustom-insn
-mno-custom-insn -mcustom-fpu-cfg=name -mhal -msmallc -msys-crt0=name -msys-lib=name -march=arch -mbmx
cc -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
cc -mno-bmx ...
-mno-int32
-mfloat32 -mno-float64 -mfloat64 -mno-float32 -mabshi -mno-abshi -mbranch-expensive -mbranch-cheap -munix-asm
cc -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
cc -mdec-asm ...
-mtune
-msmall-data-limit=N-bytes -msave-restore -mno-save-restore -mstrict-align -mno-strict-align
cc -mtune ...
-mcmodel
RL78 Options -msim -mmul=none -mmul=g13 -mmul=g14 -mallregs -mcpu=g10 -mcpu=g13 -mcpu=g14 -mg10 -mg13 -mg14
cc -mcmodel ...
-m64bit-doubles
RS/6000 and PowerPC Options -mcpu=cpu-type -mtune=cpu-type -mcmodel=code-model -mpowerpc64 -maltivec -mno-altivec
cc -m64bit-doubles ...
-mpowerpc-gpopt
-mno-powerpc-gpopt -mpowerpc-gfxopt -mno-powerpc-gfxopt -mmfcrf -mno-mfcrf -mpopcntb -mno-popcntb -mpopcntd
cc -mpowerpc-gpopt ...
-mno-popcntd
-mfprnd -mno-fprnd -mcmpb -mno-cmpb -mmfpgpr -mno-mfpgpr -mhard-dfp -mno-hard-dfp -mfull-toc -mminimal-toc
cc -mno-popcntd ...
-mno-fp-in-toc
-mno-sum-in-toc -m64 -m32 -mxl-compat -mno-xl-compat -mpe -malign-power -malign-natural -msoft-float
cc -mno-fp-in-toc ...
-mhard-float
-mmultiple -mno-multiple -msingle-float -mdouble-float -msimple-fpu -mstring -mno-string -mupdate -mno-update
cc -mhard-float ...
-mavoid-indexed-addresses
-mno-avoid-indexed-addresses -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align -mstrict-align
cc -mavoid-indexed-addresses ...
-mno-strict-align
-mrelocatable -mno-relocatable -mrelocatable-lib -mno-relocatable-lib -mtoc -mno-toc -mlittle
cc -mno-strict-align ...
-mlittle-endian
-mbig -mbig-endian -mdynamic-no-pic -maltivec -mswdiv -msingle-pic-base
cc -mlittle-endian ...
-mprioritize-restricted-insns
-msched-costly-dep=dependence_type -minsert-sched-nops=scheme -mcall-sysv -mcall-netbsd
cc -mprioritize-restricted-insns ...
-maix-struct-return
-msvr4-struct-return -mabi=abi-type -msecure-plt -mbss-plt -mblock-move-inline-limit=num -misel -mno-isel
cc -maix-struct-return ...
-misel
-misel=no -mspe -mno-spe -mspe=yes -mspe=no -mpaired -mgen-cell-microcode -mwarn-cell-microcode -mvrsave
cc -misel ...
-mno-vrsave
-mmulhw -mno-mulhw -mdlmzb -mno-dlmzb -mfloat-gprs=yes -mfloat-gprs=no -mfloat-gprs=single -mfloat-gprs=double
cc -mno-vrsave ...
-mpointers-to-nested-functions
-mno-pointers-to-nested-functions -msave-toc-indirect -mno-save-toc-indirect -mpower8-fusion
cc -mpointers-to-nested-functions ...
-mno-mpower8-fusion
-mpower8-vector -mno-power8-vector -mcrypto -mno-crypto -mhtm -mno-htm -mdirect-move -mno-direct-move
cc -mno-mpower8-fusion ...
-mquad-memory
-mno-quad-memory -mquad-memory-atomic -mno-quad-memory-atomic -mcompat-align-parm -mno-compat-align-parm
cc -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
cc -mupper-regs-df ...
-mno-upper-regs
-mfloat128 -mno-float128 -mfloat128-hardware -mno-float128-hardware -mgnu-attribute -mno-gnu-attribute
cc -mno-upper-regs ...
-mstack-protector-guard
RX Options -m64bit-doubles -m32bit-doubles -fpu -nofpu -mcpu= -mbig-endian-data -mlittle-endian-data -msmall-data -msim
cc -mstack-protector-guard ...
-mno-sim
-mas100-syntax -mno-as100-syntax -mrelax -mmax-constant-size= -mint-register= -mpid -mallow-string-insns
cc -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
cc -mno-allow-string-insns ...
-mlong-double-128
-mbackchain -mno-backchain -mpacked-stack -mno-packed-stack -msmall-exec -mno-small-exec -mmvcle
cc -mlong-double-128 ...
-mno-mvcle
-m64 -m31 -mdebug -mno-debug -mesa -mzarch -mhtm -mvx -mzvector -mtpf-trace -mno-tpf-trace -mfused-madd
cc -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
cc -mno-fused-madd ...
-m4a-nofpu
-m4a-single-only -m4a-single -m4a -m4al -mb -ml -mdalign -mrelax -mbigtable -mfmovd -mrenesas -mno-renesas
cc -m4a-nofpu ...
-mnomacsave
-mieee -mno-ieee -mbitops -misize -minline-ic_invalidate -mpadstruct -mprefergot -musermode -multcost=number
cc -mnomacsave ...
-mbranch-cost
-mzdcbranch -mno-zdcbranch -mcbranch-force-delay-slot -mfused-madd -mno-fused-madd -mfsca -mno-fsca
cc -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
cc -mfsrra ...
-mfaster-structs
-mno-faster-structs -mflat -mno-flat -mfpu -mno-fpu -mhard-float -msoft-float -mhard-quad-float
cc -mfaster-structs ...
-msoft-quad-float
-mstack-bias -mno-stack-bias -mstd-struct-return -mno-std-struct-return -munaligned-doubles
cc -msoft-quad-float ...
-mno-unaligned-doubles
-muser-mode -mno-user-mode -mv8plus -mno-v8plus -mvis -mno-vis -mvis2 -mno-vis2 -mvis3 -mno-vis3
cc -mno-unaligned-doubles ...
-mvis4
-mno-vis4 -mvis4b -mno-vis4b -mcbcond -mno-cbcond -mfmaf -mno-fmaf -mfsmuld -mno-fsmuld -mpopc -mno-popc -msubxc
cc -mvis4 ...
-mno-subxc
SPU Options -mwarn-reloc -merror-reloc -msafe-dma -munsafe-dma -mbranch-hints -msmall-mem -mlarge-mem -mstdmain
cc -mno-subxc ...
-mfixed-range
-mea32 -mea64 -maddress-space-conversion -mno-address-space-conversion -mcache-size=cache-size
cc -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
cc -matomic-updates ...
-mzda
-mapp-regs -mno-app-regs -mdisable-callt -mno-disable-callt -mv850e2v3 -mv850e2 -mv850e1 -mv850es -mv850e -mv850
cc -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
cc -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
cc -muser-mode ...
-masm
-mno-fancy-math-387 -mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float -mno-wide-multiply -mrtd
cc -masm ...
-malign-double
-mpreferred-stack-boundary=num -mincoming-stack-boundary=num -mcld -mcx16 -msahf -mmovbe -mcrc32 -mrecip
cc -malign-double ...
-mrecip
-mvzeroupper -mprefer-avx128 -mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx -mavx2
cc -mrecip ...
-mavx512f
-mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
cc -mavx512f ...
-mpclmul
-mfsgsbase -mrdrnd -mf16c -mfma -mprefetchwt1 -mclflushopt -mxsavec -mxsaves -msse4a -m3dnow -m3dnowa -mpopcnt
cc -mpclmul ...
-mabm
-mbmi -mtbm -mfma4 -mxop -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp -mmpx -mmwaitx -mclzero -mpku
cc -mabm ...
-mthreads
-mms-bitfields -mno-align-stringops -minline-all-stringops -minline-stringops-dynamically -mstringop-strategy=alg
cc -mthreads ...
-mmemcpy-strategy
-mmemset-strategy=strategy -mpush-args -maccumulate-outgoing-args -m128bit-long-double
cc -mmemcpy-strategy ...
-m96bit-long-double
-mlong-double-64 -mlong-double-80 -mlong-double-128 -mregparm=num -msseregparm -mveclibabi=type
cc -m96bit-long-double ...
-mvect8-ret-in-mem
-mpc32 -mpc64 -mpc80 -mstackrealign -momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
cc -mvect8-ret-in-mem ...
-mfentry
-mrecord-mcount -mnop-mcount -m8bit-idiv -mavx256-split-unaligned-load -mavx256-split-unaligned-store
cc -mfentry ...
-malign-data
-mstack-protector-guard=guard -mmitigate-rop -mgeneral-regs-only -mindirect-branch=choice
cc -malign-data ...
-mfunction-return
x86 Windows Options -mconsole -mcygwin -mno-cygwin -mdll -mnop-fun-dllimport -mthread -municode -mwin32 -mwindows
cc -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
cc -fno-set-stack-executable ...
-mtext-section-literals
-mno-text-section-literals -mauto-litpools -mno-auto-litpools -mtarget-align -mno-target-align
cc -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:
cc -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
cc -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.
cc -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.
cc -### ...
--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.
cc --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.
cc --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:
cc -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
cc -Q ...
--version
Display the version number and copyrights of the invoked GCC.
cc --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
cc -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.
cc -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.
cc -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 ....
cc -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.
cc -fplugin ...
-fplugin-arg-name-key
Define an argument called key with a value of value for the plugin called name.
cc -fplugin-arg-name-key ...
-fdump-ada-spec[-slim]
For C and C++ source and include files, generate corresponding Ada specs.
cc -fdump-ada-spec[-slim] ...
-fada-spec-parent
In conjunction with -fdump-ada-spec[-slim] above, generate Ada specs as child units of parent unit.
cc -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:
cc -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
cc -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
cc -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.
cc -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.
cc -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.
cc -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
cc -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
cc -fno-builtin-function ...
-fgimple
Enable parsing of function definitions marked with "__GIMPLE". This is an experimental feature that allows unit testing ofGIMPLE passes.
cc -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.
cc -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.
cc -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.
cc -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
cc -fopenmp ...
-pthread
and thus is only supported on targets that have support for -pthread. -fopenmp implies -fopenmp-simd.
cc -pthread ...
-fopenmp-simd
Enable handling of OpenMP's SIMD directives with "#pragma omp" in C/C++ and "!$omp" in Fortran. Other OpenMP directives areignored.
cc -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.
cc -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).
cc -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.
cc -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++.
cc -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++.
cc -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.
cc -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.
cc -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
cc -fsigned-char ...
-fno-signed-char
is equivalent to -funsigned-char.
cc -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.
cc -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:
cc -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.
cc -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.
cc -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)".
cc -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).
cc -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; }
cc -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.
cc -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++.
cc -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++.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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".
cc -fnothrow-opt ...
-fno-operator-names
Do not treat the operator name keywords "and", "bitand", "bitor", "compl", "not", "or" and "xor" as synonyms as keywords.
cc -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.
cc -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.
cc -fno-pretty-templates ...
-frepo
Enable automatic template instantiation at link time. This option also implies -fno-implicit-templates.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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".
cc -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.
cc -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.
cc -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.
cc -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++.
cc -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:
cc -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
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -Wliteral-suffix ...
-Wlto-type-mismatch
During the link-time optimization warn about type mismatches in global declarations from different compilation units. Requires
cc -Wlto-type-mismatch ...
-flto
to be enabled. Enabled by default.
cc -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
cc -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.
cc -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>
cc -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.
cc -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.
cc -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.
cc -Wreorder ...
-std=c++11,
The following -W... options are not affected by -Wall.
cc -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.
cc -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.
cc -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.
cc -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;
cc -Woverloaded-virtual ...
-Wno-pmf-conversions
Disable the diagnostic for converting a bound pointer to member function to a plain pointer.
cc -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.
cc -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.
cc -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.
cc -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:
cc -Wno-terminate ...
-fgnu-runtime
Generate object code compatible with the standard GNU Objective-C runtime. This is the default for most types of systems.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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).
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -fno-local-ivars ...
-gen-decls
Dump interface declarations for all classes seen in the source file to a file named sourcename.decl.
cc -gen-decls ...
-Wassign-intercept
Warn whenever an Objective-C assignment is being intercepted by the garbage collector.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -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.
cc -fdiagnostics-parseable-fixits ...
-fdiagnostics-generate-patch
Print fix-it hints to stderr in unified diff format, after any diagnostics are printed. For example:
cc -fdiagnostics-generate-patch ...
-42,5
void show_cb(GtkDialog *dlg){
cc -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).
cc - ...
-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.
cc -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.
cc -fmax-errors ...
-w
Inhibit all warning messages.
cc -w ...
-Werror
Make all warnings into errors.
cc -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,
cc -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.
cc -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.
cc -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.
cc -Wall ...
-Waddress
-Warray-bounds=1 (only with -O2) -Wbool-compare -Wbool-operation -Wc++11-compat -Wc++14-compat -Wchar-subscripts
cc -Waddress ...
-Wcomment
-Wduplicate-decl-specifier (C and Objective-C only) -Wenum-compare (in C/ObjC; this is on by default in C++) -Wformat
cc -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)
cc -Wint-in-bool-context ...
-Wmaybe-uninitialized
for C/ObjC) -Wnarrowing (only for C++) -Wnonnull -Wnonnull-compare -Wopenmp-simd -Wparentheses -Wpointer-sign -Wreorder
cc -Wmaybe-uninitialized ...
-Wreturn-type
-Wsequence-point -Wsign-compare (only in C++) -Wsizeof-pointer-memaccess -Wstrict-aliasing -Wstrict-overflow=1
cc -Wreturn-type ...
-Wswitch
-Wtautological-compare -Wtrigraphs -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value
cc -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
cc -Wunused-variable ...
-Wextra
but many of them must be enabled individually.
cc -Wextra ...
-Wclobbered
only) -Wold-style-declaration (C only) -Woverride-init -Wsign-compare (C only) -Wtype-limits -Wuninitialized
cc -Wclobbered ...
-Wshift-negative-value
(in C++03 and in C99 and newer) -Wunused-parameter (only with -Wunused or -Wall)
cc -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.
cc -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
cc -Wno-coverage-mismatch ...
-Wno-cpp
(C, Objective-C, C++, Objective-C++ and Fortran only)Suppress warning messages emitted by "#warning" directives.
cc -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".
cc -Wdouble-promotion ...
-Wduplicate-decl-specifier
Warn if a declaration has duplicate "const", "volatile", "restrict" or "_Atomic" specifier. This warning is enabled by -Wall.
cc -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
cc -Wformat ...
-Wno-format-contains-nul
If -Wformat is specified, do not warn about format strings that contain NUL bytes.
cc -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.
cc -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.
cc -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.
cc -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".
cc -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.
cc -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.
cc -Wformat-truncation ...
-Wno-format-security
or disable all format warnings with -Wformat=0. To make format security warnings fatal specify
cc -Wno-format-security ...
-Wformat-y2k
If -Wformat is specified, also warn about "strftime" formats that may yield only a two-digit year.
cc -Wformat-y2k ...
-Wnonnull
Warn about passing a null pointer for arguments marked as requiring a non-null value by the "nonnull" function attribute.
cc -Wnonnull ...
-Wnonnull-compare
Warn when comparing an argument marked with the "nonnull" function attribute against null inside the function.
cc -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.
cc -Wnull-dereference ...
-Winit-self
Warn about uninitialized variables that are initialized with themselves. Note this option can only be used with the
cc -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++.
cc -Wuninitialized ...
-Wimplicit-int
Warn when a declaration does not specify a type. This warning is enabled by -Wall.
cc -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.
cc -Wimplicit-function-declaration ...
-Wimplicit
Same as -Wimplicit-int and -Wimplicit-function-declaration. This warning is enabled by -Wall.
cc -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.
cc -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.
cc -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
cc -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++.
cc -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.
cc -Wmissing-braces ...
-Wmissing-include-dirs
Warn if a user-supplied include directory does not exist.
cc -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.
cc -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++.
cc -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.
cc -Wno-return-local-addr ...
-Wshift-count-negative
Warn if shift count is negative. This warning is enabled by default.
cc -Wshift-count-negative ...
-Wshift-overflow
Warn about left shift overflows. This warning is enabled by default in C99 and C++11 modes (and newer).
cc -Wshift-overflow ...
-Wswitch-default
Warn whenever a "switch" statement does not have a "default" case.
cc -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.
cc -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:...}
cc -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.
cc -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
cc -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.
cc -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.
cc -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.
cc -Wunused-label ...
-Wunused-local-typedefs
Warn when a typedef locally defined in a function is not used. This warning is enabled by -Wall.
cc -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
cc -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
cc -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.
cc -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
cc -Wunused ...
-Wunused)
or separately specify -Wunused-parameter.
cc -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);}
cc -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.
cc -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
cc -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.
cc -Wstringop-overflow ...
-Wsuggest-attribute
Warn for cases where adding an attribute may be beneficial. The attributes currently supported are listed below.
cc -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.
cc -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.
cc -Wsuggest-final-methods ...
-Wsuggest-override
Warn about overriding virtual functions that are not marked with the override keyword.
cc -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.
cc -Walloc-zero ...
-Walloca
This option warns on all uses of "alloca" in the source.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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;
cc -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.
cc -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.
cc -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
cc -Wno-incompatible-pointer-types ...
-Wno-pointer-sign
which warns for pointer argument passing or assignment with different signedness.
cc -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.
cc -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
cc -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.
cc -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
cc -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.
cc -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.
cc -Wtraditional-conversion ...
-Wno-shadow-ivar
Do not warn whenever a local variable shadows an instance variable in an Objective-C method.
cc -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.
cc -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
cc -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
cc -Wunsafe-loop-optimizations ...
-funsafe-loop-optimizations
warn if the compiler makes such assumptions.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -Wtrigraphs ...
-Wundef
Warn if an undefined identifier is evaluated in an "#if" directive. Such identifiers are replaced with zero.
cc -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.
cc -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
cc -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.
cc -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__".
cc -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.
cc -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.
cc -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.
cc -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.
cc -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';
cc -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.
cc -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.
cc -Wwrite-strings ...
-Wconditionally-supported
Warn for conditionally-supported (C++11 [intro.defs]) constructs.
cc -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
cc -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.
cc -Wno-sign-conversion. ...
-Wno-conversion-null
Do not warn for conversions between "NULL" and non-pointer types. -Wconversion-null is enabled by default.
cc -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.
cc -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.
cc -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.
cc -Wdangling-else ...
-Wdelete-incomplete
Warn when deleting a pointer to incomplete type, which may cause undefined behavior at runtime. This warning is enabled bydefault.
cc -Wdelete-incomplete ...
-Wuseless-cast
Warn when an expression is casted to its own type.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -Wfloat-conversion ...
-Wno-scalar-storage-order
Do not warn on suspicious constructs involving reverse scalar storage order.
cc -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.
cc -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.
cc -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.
cc -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) { ... }
cc -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.
cc -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.)
cc -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.
cc -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.
cc -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__".
cc -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.)
cc -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.
cc -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.
cc -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++.
cc -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.
cc -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
cc -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.
cc -Wnormalized ...
-Wno-deprecated
Do not warn about usage of deprecated features.
cc -Wno-deprecated ...
-Wno-deprecated-declarations
Do not warn about uses of functions, variables, and types marked as deprecated by using the "deprecated" attribute.
cc -Wno-deprecated-declarations ...
-Wno-overflow
Do not warn about compile-time overflow in constant expressions.
cc -Wno-overflow ...
-Wno-odr
Warn about One Definition Rule violations during link-time optimization. Requires -flto-odr-type-merging to be enabled. Enabledby default.
cc -Wno-odr ...
-fsimd-cost-model
option can be used to relax the cost model.
cc -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.
cc -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.
cc -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;};
cc -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.
cc -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.
cc -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.
cc -Wredundant-decls ...
-Wrestrict
Warn when an argument passed to a restrict-qualified parameter aliases with another argument.
cc -Wrestrict ...
-Wnested-externs
Warn if an "extern" declaration is encountered within a function.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -Wno-pointer-to-int-cast ...
-Winvalid-pch
Warn if a precompiled header is found in the search path but cannot be used.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -Wpointer-sign ...
-Wstack-protector
This option is only active when -fstack-protector is active. It warns about functions that are not protected against stacksmashing.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -gxcoff+ ...
-gvms
Produce debugging information in Alpha/VMS debug format (if that is supported). This is the format used by DEBUG on Alpha/VMSsystems.
cc -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.
cc -gvmslevel ...
-feliminate-unused-debug-symbols
Produce debugging information in stabs format (if that is supported), for only symbols that are actually used.
cc -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.
cc -femit-class-debug-always ...
-fdebug-prefix-map
When compiling files in directory old, record debugging information describing them as in new instead.
cc -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.
cc -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.
cc -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.
cc -gsplit-dwarf ...
-gpubnames
Generate DWARF ".debug_pubnames" and ".debug_pubtypes" sections.
cc -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.
cc -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.
cc -gno-record-gcc-switches ...
-gno-strict-dwarf
Allow using extensions of later DWARF standard version than selected with -gdwarf-version.
cc -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.
cc -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.
cc -gz[ ...
-feliminate-dwarf2-dups
Compress DWARF debugging information by eliminating duplicated information about each symbol. This option only makes sense whengenerating DWARF debugging information.
cc -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.
cc -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.
cc -femit-struct-debug-detailed[ ...
-fno-dwarf2-cfi-asm
Emit DWARF unwind info as compiler generated ".eh_frame" section instead of using GAS ".cfi_*" directives.
cc -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.
cc -fno-eliminate-unused-debug-types ...
-O
turns on the following optimization flags:
cc -O ...
-fauto-inc-dec
-fbranch-count-reg -fcombine-stack-adjustments -fcompare-elim -fcprop-registers -fdce -fdefer-pop -fdelayed-branch
cc -fauto-inc-dec ...
-fipa-pure-const
-fipa-profile -fipa-reference -fmerge-constants -fmove-loop-invariants -freorder-blocks -fshrink-wrap
cc -fipa-pure-const ...
-ftree-copy-prop
-ftree-dce -ftree-dominator-opts -ftree-dse -ftree-forwprop -ftree-fre -ftree-phiprop -ftree-sink -ftree-slsr
cc -ftree-copy-prop ...
-ftree-sra
-ftree-pta -ftree-ter -funit-at-a-time
cc -ftree-sra ...
-O2
Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. As compared to
cc -O2 ...
-falign-functions
-falign-jumps -falign-loops -falign-labels -fcaller-saves -fcrossjumping -fcse-follow-jumps
cc -falign-functions ...
-fcse-skip-blocks
-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively -fexpensive-optimizations -fgcse
cc -fcse-skip-blocks ...
-freorder-blocks-algorithm
-freorder-blocks-and-partition -freorder-functions -frerun-cse-after-loop -fsched-interblock
cc -freorder-blocks-algorithm ...
-fsched-spec
-fschedule-insns -fschedule-insns2 -fstore-merging -fstrict-aliasing -fstrict-overflow -ftree-builtin-call-dce
cc -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
cc -ftree-switch-conversion ...
-U_FORTIFY_SOURCE
or -D_FORTIFY_SOURCE=0.
cc -U_FORTIFY_SOURCE ...
-O3
Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops,
cc -O3 ...
-fpredictive-commoning
-fgcse-after-reload -ftree-loop-vectorize -ftree-loop-distribute-patterns -fsplit-paths
cc -fpredictive-commoning ...
-ftree-slp-vectorize
-fvect-cost-model -ftree-partial-pre -fpeel-loops and -fipa-cp-clone options.
cc -ftree-slp-vectorize ...
-O0
Reduce compilation time and make debugging produce the expected results. This is the default.
cc -O0 ...
-Os
disables the following optimization flags: -falign-functions -falign-jumps -falign-loops -falign-labels -freorder-blocks
cc -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.
cc -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.
cc -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.
cc -fforward-propagate ...
-foptimize-sibling-calls
Optimize sibling and tail recursive calls.Enabled at levels -O2, -O3, -Os.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -fif-conversion ...
-fif-conversion2
Use conditional execution (where available) to transform conditional jumps into branch-less equivalents.Enabled at levels -O, -O2, -O3, -Os.
cc -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.
cc -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.
cc -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,
cc -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.
cc -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.
cc -fdevirtualize-at-ltrans ...
-fexpensive-optimizations
Perform a number of minor optimizations that are relatively expensive.Enabled at levels -O2, -O3, -Os.
cc -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.
cc -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
cc -fno-lifetime-dse ...
-flifetime-dse
The default behavior can be explicitly selected with -flifetime-dse=2. -flifetime-dse=0 is equivalent to
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -freschedule-modulo-scheduled-loops ...
-fselective-scheduling
Schedule instructions using selective scheduling algorithm. Selective scheduling runs instead of the first scheduler pass.
cc -fselective-scheduling ...
-fsel-sched-pipelining
Enable software pipelining of innermost loops during selective scheduling. This option has no effect unless one of
cc -fsel-sched-pipelining ...
-fsel-sched-pipelining-outer-loops
When pipelining loops during selective scheduling, also pipeline outer loops. This option has no effect unless
cc -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.
cc -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.
cc -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.
cc -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.
cc -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).
cc -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.
cc -fconserve-stack ...
-ftree-reassoc
Perform reassociation on trees. This flag is enabled by default at -O and higher.
cc -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.
cc -fcode-hoisting ...
-ftree-pre
Perform partial redundancy elimination (PRE) on trees. This flag is enabled by default at -O2 and -O3.
cc -ftree-pre ...
-ftree-partial-pre
Make partial redundancy elimination (PRE) more aggressive. This flag is enabled by default at -O3.
cc -ftree-partial-pre ...
-ftree-forwprop
Perform forward propagation on trees. This flag is enabled by default at -O and higher.
cc -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.
cc -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.
cc -fhoist-adjacent-loads ...
-fipa-reference
Discover which static variables do not escape the compilation unit. Enabled by default at -O and higher.
cc -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.
cc -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.
cc -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.
cc -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.
cc -fipa-cp-clone ...
-fipa-vrp
When enabled, perform interprocedural propagation of value ranges. This flag is enabled by default at -O2. It requires that
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -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
cc -floop-unroll-and-jam ...
--with-isl
to enable the Graphite loop transformation infrastructure.
cc --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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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
cc -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.
cc -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.
cc -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.
cc -ftree-loop-ivcanon ...
-fivopts
Perform induction variable optimizations (strength reduction, induction variable merging and induction variable elimination) ontrees.
cc -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.
cc -ftree-parallelize-loops ...
-ftree-pta
Perform function-local points-to analysis on trees. This flag is enabled by default at -O and higher.
cc -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.
cc -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.
cc -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.
cc -ftree-slsr ...
-ftree-vectorize
Perform vectorization on trees. This flag enables -ftree-loop-vectorize and -ftree-slp-vectorize if not explicitly specified.
cc -ftree-vectorize ...
-ftree-loop-vectorize
Perform loop vectorization on trees. This flag is enabled by default at -O3 and when -ftree-vectorize is enabled.
cc -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.
cc -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
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -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
cc -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.
cc -fno-peephole2 ...
-fpeephole
is enabled by default. -fpeephole2 enabled at levels -O2, -O3, -Os.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -funit-at-a-time ...
-fno-toplevel-reorder
Enabled by default.
cc -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.
cc -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.
cc -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,
cc -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
cc -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.
cc -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.
cc -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).
cc -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.
cc -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.
cc -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.
cc -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 \
cc -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 \
cc -- ...
--gcov
The following options control compiler behavior regarding floating-point arithmetic. These options trade off between speed andcorrectness. All must be specifically enabled.
cc --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.
cc -ffloat-store ...
-ffast-math
Sets the options -fno-math-errno, -funsafe-math-optimizations, -ffinite-math-only, -fno-rounding-math, -fno-signaling-nans,
cc -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.
cc -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.
cc -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
cc -funsafe-math-optimizations ...
-freciprocal-math.
The default is -fno-unsafe-math-optimizations.
cc -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.
cc -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.
cc -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.
cc -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
cc -fno-signed-zeros ...
-ffinite-math-only).
The default is -fsigned-zeros.
cc -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.
cc -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".
cc -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
cc -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.
cc -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.
cc -fno-fp-int-builtin-inexact ...
-fsingle-precision-constant
Treat floating-point constants as single precision instead of implicitly converting them to double-precision constants.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -ftracer ...
-funroll-loops
Unroll loops whose number of iterations can be determined at compile time or upon entry to the loop. -funroll-loops implies
cc -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.
cc -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.
cc -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.
cc -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).
cc -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.
cc -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.
cc -fbranch-target-load-optimize ...
-fbtr-bb-exclusive
When performing branch target register load optimization, don't reuse branch target registers within any basic block.
cc -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
cc -fstdarg-opt ...
-fno-stack-protector
-nostdlib nor -ffreestanding are found.
cc -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.
cc -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
cc --param ...
-fsanitize=address
asan-stackEnable buffer overflow detection for stack objects. This kind of protection is enabled by default when using
cc -fsanitize=address ...
-fsanitize=address.
asan-instrument-readsEnable buffer overflow detection for memory reads. This kind of protection is enabled by default when using
cc -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).
cc -fprofile-arcs ...
--coverage
This option is used to compile and link code instrumented for coverage analysis. The option is a synonym for -fprofile-arcs
cc --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.
cc -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
cc -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.
cc -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.
cc -fprofile-update ...
-fno-sanitize
This option disables all previously enabled sanitizers. -fsanitize=all is not allowed, as some sanitizers cannot be usedtogether.
cc -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.
cc -fasan-shadow-offset ...
-fsanitize-sections
Sanitize global variables in selected user-defined sections. si may contain wildcards.
cc -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.
cc -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.
cc -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.
cc -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.
cc -fcheck-pointer-bounds ...
-fchkp-check-incomplete-type
Generate pointer bounds checks for variables with incomplete type. Enabled by default.
cc -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.
cc -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.
cc -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.
cc -fchkp-narrow-to-innermost-array ...
-fchkp-optimize
Enables Pointer Bounds Checker optimizations. Enabled by default at optimization levels -O, -O2, -O3.
cc -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.
cc -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.
cc -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.
cc -fchkp-use-static-const-bounds ...
-fchkp-check-read
Instructs Pointer Bounds Checker to generate checks for all read accesses to memory. Enabled by default.
cc -fchkp-check-read ...
-fchkp-check-write
Instructs Pointer Bounds Checker to generate checks for all write accesses to memory. Enabled by default.
cc -fchkp-check-write ...
-fchkp-store-bounds
Instructs Pointer Bounds Checker to generate bounds stores for pointer writes. Enabled by default.
cc -fchkp-store-bounds ...
-fchkp-instrument-marked-only
Instructs Pointer Bounds Checker to instrument only functions marked with the "bnd_instrument" attribute. Disabled by default.
cc -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.
cc -fchkp-use-wrappers ...
-fstack-protector-all
Like -fstack-protector except that all functions are protected.
cc -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.
cc -fstack-protector-strong ...
-fstack-protector-explicit
Like -fstack-protector but only protects those functions which have the "stack_protect" attribute.
cc -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.
cc -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
cc -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.
cc -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.
cc -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.
cc -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).
cc -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.
cc -finstrument-functions-exclude-function-list ...
-D
Predefine name as a macro, with definition 1.
cc -D ...
-U
Cancel any previous definition of name, either built in or provided with a -D option.
cc -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.
cc -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.
cc -imacros ...
-undef
Do not predefine any system-specific or GCC-specific macros. The standard predefined macros remain defined.
cc -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.
cc -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
cc -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.
cc -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.
cc -MD ...
-MMD
Like -MD except mention only user header files, not system header files.
cc -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.
cc -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
cc -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".
cc -fdirectives-only". ...
-fextended-identifiers
Accept universal character names in identifiers. This option is enabled by default for C99 (and later C standard versions) andC++.
cc -fextended-identifiers ...
-fno-canonical-system-headers
When preprocessing, do not shorten system header paths with canonicalization.
cc -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.
cc -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.
cc -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.
cc -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".
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -dletters ...
-dN
but emit only the macro names not their expansions.
cc -dN ...
-dI
Output #include directives in addition to the result of preprocessing.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -E ...
-fuse-ld
Use the bfd linker instead of the default linker.
cc -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.
cc -l ...
-lobjc
You need this special case of the -l option in order to link an Objective-C or Objective-C++ program.
cc -lobjc ...
-nostartfiles
Do not use the standard system startup files when linking. The standard system libraries are used normally, unless -nostdlib or
cc -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.
cc -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
cc -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.
cc -pie ...
-no-pie
Don't produce a position independent executable.
cc -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.
cc -rdynamic ...
-s
Remove all symbol table and relocation information from the executable.
cc -s ...
-static
On systems that support dynamic linking, this prevents linking with the shared libraries. On other systems, this option has noeffect.
cc -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]
cc -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
cc -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
cc -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
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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.
cc -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
cc -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.
cc -I ...
-iprefix
Specify prefix as the prefix for subsequent -iwithprefix options. If the prefix represents a directory, you should include thefinal /.
cc -iprefix ...
-iwithprefixbefore
Append dir to the prefix specified previously with -iprefix, and add the resulting directory to the include search path.
cc -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.
cc -isysroot ...
-imultilib
Use dir as a subdirectory of the directory containing target-specific C++ headers.
cc -imultilib ...
-nostdinc
Do not search the standard system directories for header files. Only the directories explicitly specified with -I, -iquote,
cc -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.
cc -iplugindir ...
-Ldir
Add directory dir to the list of directories to be searched for -l.
cc -Ldir ...
-no-canonical-prefixes
Do not expand any symbolic links, resolve references to /../ or /./, or make the path absolute when generating a relative prefix.
cc -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.
cc --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.
cc -fstack-reuse ...
-ftrapv
This option generates traps for signed overflow on addition, subtraction, multiplication operations. The options -ftrapv and
cc -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
cc -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.
cc -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".
cc -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.
cc -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.
cc -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.
cc -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
cc -fpcc-struct-return ...
-freg-struct-return
switch. Use it to conform to a non-default application binary interface.
cc -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
cc -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.
cc -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.
cc -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.
cc -fno-common ...
-fno-ident
Ignore the "#ident" directive.
cc -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.
cc -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).
cc -fverbose-asm ...
-frecord-gcc-switches
This switch causes the command line used to invoke the compiler to be recorded into the object file that is being created. Thisswitch is only implemented on some targets and the exact format of the recording is target and binary file format dependent, butit usually takes the form of a section containing ASCII text. This switch is related to the -fverbose-asm switch, but thatswitch only records information in the assembler output file as comments, so it never reaches the object file. See also
cc -frecord-gcc-switches ...
-grecord-gcc-switches
for another way of storing compiler options into the object file.
cc -grecord-gcc-switches ...
-fPIC
If supported for the target machine, emit position-independent code, suitable for dynamic linking and avoiding any limit on thesize of the global offset table. This option makes a difference on AArch64, m68k, PowerPC and SPARC.Position-independent code requires special support, and therefore works only on certain machines.When this flag is set, the macros "__pic__" and "__PIC__" are defined to 2.
cc -fPIC ...