GCC命令选项

来源:互联网 发布:台湾电视台直播软件 编辑:程序博客网 时间:2024/06/07 12:32

    当你调用GCC时,他会自动做预处理,编译,汇编和链接操作。全局开关允许你在中途停止这些操作。例如-c选项说明不要运行链接器,然后输出由汇编器生成的目标文件组成。其他的选项被传送到操作中的某一步。一些选项控制预处理器和其他的编译器本身。另外一些选项控制汇编器和链接器。

    大部分你用的gcc命令行选项都对c程序有用,然而有个选项只对另外一种语言有用,(通常是c+),这在解释中说的很清楚。如果对一个指定选项的描述没有提到源语言,你就可以把这个选项用到所有支持的语言中去。gcc程序接受选项和文件名作为操作符,大部分选项有重复的单词,因此复用单个单词的选项也许没有分组:-dv和-d -v有很大不同。

    你可以混合选项和其他的参数。大部分情况下选项的顺序可以不管。当同一种选项用了几次时先后顺序就要考虑了,例如如果你用了"—L"选项不止一次,就要按指定的顺序来搜索程序的目录。同样,"-L"选项的配置也很重要.

    许多选项有着如-f或-W开头的长名字,-fmove-loop-invariants,-Wformat等等。他们中的大部分都有正面的和负面的格式,-ffoo的负面格式会像-fno-foo这样。该手册只记录了这两种格式中的一种,哪一种都不是默认的。

    下面是所有选项的概述,按类型分类。

    全局开关

    -c -S -E -o file -combine -pipe -pass-exit-codes -x language -v -### --help[=class[,...]] --target-help --version -wrapper@file

    c语言选项

    -ansi -std=stanard -fgnu89-inline

    -aux-info filename

    -fno-asm  -fn-builtin  -fno-builtin-function

    -fhosted  -ffreestanding  -fopenmp  -fms-extensions

    -trigraphs  -no-integrated-cpp  -traditional  -traditional-cpp

    -fallow-single-precision  -fcond-mismatch  -flax-vector-conversions

    -funsigned-bitfields  -funsogned-char

    c++语言选项

    -fabi-version=n  -fno-access-control  -fcheck-new

    -fconversion-space  -ffriend-injection

    -fno-elide-constructors

    -fno-enforce-eh-specs

    -ffor-scope  -fno-for-scope  -fno-gnu-keywords

    -fno-implicit-templates

    -fno-implicit-inline-templates

    -fno-implement-inlines  -fms-extensions

    -fno-optional-diags  -fpermissive

    -frepo  -fno-rtti  -fstats  -ftemplate-depth-n

    -fno-threadsafe-statics  -ftemplate-depth-n

    -fno-default-inline  -fvisibility-inlines-hidden

    -fvisibility-ms-compact

    -Wabi  -Wctor-dtor  -Wreorder

    -Wnon-virtual-dtor  -Wreorder

    -Weffect++  -Wstrict-null-sentinel

    -Wno-non-template-friend  -Wold-style-cast

    -Woverloaded-virtual  -Wno-pmf-conversions

    -Wsign-promo

    Objective-C and Objective-C++ 语言选项

    -fconstant-string-class=class-name
    -fgnu-runtime -fnext-runtime
    -fno-nil-receivers
    -fobjc-call-cxx-cdtors
    -fobjc-direct-dispatch
    -fobjc-exceptions
    -fobjc-gc
    -freplace-objc-classes
    -fzero-link
    -gen-decls
    -Wassign-intercept
    -Wno-protocol -Wselector
    -Wstrict-selector-match
    -Wundeclared-selector

    独立于语言的选项

    -fmessage-length=n
    -fdiagnostics-show-location=[once|every-line]
    -fdiagnostics-show-option

    警告选项

    -fsyntax-only -pedantic -pedantic-errors
-w -Wextra -Wall -Waddress -Waggregate-return -Warray-bounds
-Wno-attributes -Wno-builtin-macro-redefined
-Wc++-compat -Wc++0x-compat -Wcast-align -Wcast-qual
-Wchar-subscripts -Wclobbered -Wcomment
-Wconversion -Wcoverage-mismatch -Wno-deprecated
-Wno-deprecated-declarations -Wdisabled-optimization
-Wno-div-by-zero -Wempty-body -Wenum-compare -Wno-endif-labels

    -Werror -Werror=*
-Wfatal-errors -Wfloat-equal -Wformat -Wformat=2
-Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral
-Wformat-security -Wformat-y2k
-Wframe-larger-than=len -Wignored-qualifiers
-Wimplicit -Wimplicit-function-declaration -Wimplicit-int
-Winit-self -Winline
-Wno-int-to-pointer-cast -Wno-invalid-offsetof
-Winvalid-pch -Wlarger-than=len -Wunsafe-loop-optimizations
-Wlogical-op -Wlong-long
-Wmain -Wmissing-braces -Wmissing-field-initializers
-Wmissing-format-attribute -Wmissing-include-dirs
-Wmissing-noreturn -Wno-mudflap
-Wno-multichar -Wnonnull -Wno-overflow
-Woverlength-strings -Wpacked -Wpacked-bitfield-compat -Wpadded
-Wparentheses -Wpedantic-ms-format -Wno-pedantic-ms-format
-Wpointer-arith -Wno-pointer-to-int-cast
-Wredundant-decls
-Wreturn-type -Wsequence-point -Wshadow
-Wsign-compare -Wsign-conversion -Wstack-protector
-Wstrict-aliasing -Wstrict-aliasing=n
-Wstrict-overflow -Wstrict-overflow=n
-Wswitch -Wswitch-default -Wswitch-enum -Wsync-nand
-Wsystem-headers -Wtrigraphs -Wtype-limits -Wundef -Wuninitialized
-Wunknown-pragmas -Wno-pragmas -Wunreachable-code
-Wunused -Wunused-function -Wunused-label -Wunused-parameter
-Wunused-value -Wunused-variable
-Wvariadic-macros -Wvla
-Wvolatile-register-var -Wwrite-strings

    调试选项

-dletters -dumpspecs -dumpmachine -dumpversion
-fdbg-cnt-list -fdbg-cnt=counter-value-list
-fdump-noaddr -fdump-unnumbered
-fdump-translation-unit[-n]
-fdump-class-hierarchy[-n]
-fdump-ipa-all -fdump-ipa-cgraph -fdump-ipa-inline
-fdump-statistics
-fdump-tree-all
-fdump-tree-original[-n]
-fdump-tree-optimized[-n]
-fdump-tree-cfg -fdump-tree-vcg -fdump-tree-alias
-fdump-tree-ch
-fdump-tree-ssa[-n] -fdump-tree-pre[-n]
-fdump-tree-ccp[-n] -fdump-tree-dce[-n]
-fdump-tree-gimple[-raw] -fdump-tree-mudflap[-n]
-fdump-tree-dom[-n]
-fdump-tree-dse[-n]
-fdump-tree-phiopt[-n]
-fdump-tree-forwprop[-n]
-fdump-tree-copyrename[-n]

-fdump-tree-nrv -fdump-tree-vect
-fdump-tree-sink
-fdump-tree-sra[-n]
-fdump-tree-fre[-n]
-fdump-tree-vrp[-n]
-ftree-vectorizer-verbose=n
-fdump-tree-storeccp[-n]
-feliminate-dwarf2-dups -feliminate-unused-debug-types
-feliminate-unused-debug-symbols -femit-class-debug-always
-fmem-report -fpre-ipa-mem-report -fpost-ipa-mem-report -fprofile-arcs
-frandom-seed=string -fsched-verbose=n
-fsel-sched-verbose -fsel-sched-dump-cfg -fsel-sched-pipelining-verbose
-ftest-coverage -ftime-report -fvar-tracking
-g -glevel -gcoff -gdwarf-2
-ggdb -gstabs -gstabs+ -gvms -gxcoff -gxcoff+
-fno-merge-debug-strings -fno-dwarf2-cfi-asm
-fdebug-prefix-map=old=new
-femit-struct-debug-baseonly -femit-struct-debug-reduced
-femit-struct-debug-detailed[=spec-list]
-p -pg -print-file-name=library -print-libgcc-file-name
-print-multi-directory -print-multi-lib
-print-prog-name=program -print-search-dirs -Q
-print-sysroot -print-sysroot-headers-suffix
-save-temps -time

优化选项

-falign-functions[=n] -falign-jumps[=n]
-falign-labels[=n] -falign-loops[=n] -fassociative-math
-fauto-inc-dec -fbranch-probabilities -fbranch-target-load-optimize
-fbranch-target-load-optimize2 -fbtr-bb-exclusive -fcaller-saves
-fcheck-data-deps -fconserve-stack -fcprop-registers -fcrossjumping
-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules -fcx-limited-range
-fdata-sections -fdce -fdce
-fdelayed-branch -fdelete-null-pointer-checks -fdse -fdse
-fearly-inlining -fexpensive-optimizations -ffast-math
-ffinite-math-only -ffloat-store -fforward-propagate
-ffunction-sections -fgcse -fgcse-after-reload -fgcse-las -fgcse-lm
-fgcse-sm -fif-conversion -fif-conversion2 -findirect-inlining
-finline-functions -finline-functions-called-once -finline-limit=n
-finline-small-functions -fipa-cp -fipa-cp-clone -fipa-matrix-reorg -fipapta
-fipa-pure-const -fipa-reference -fipa-struct-reorg
-fipa-type-escape -fira-algorithm=algorithm
-fira-region=region -fira-coalesce -fno-ira-share-save-slots
-fno-ira-share-spill-slots -fira-verbose=n
-fivopts -fkeep-inline-functions -fkeep-static-consts
-floop-block -floop-interchange -floop-strip-mine
-fmerge-all-constants -fmerge-constants -fmodulo-sched
-fmodulo-sched-allow-regmoves -fmove-loop-invariants -fmudflap
-fmudflapir -fmudflapth -fno-branch-count-reg -fno-default-inline
-fno-defer-pop -fno-function-cse -fno-guess-branch-probability
-fno-inline -fno-math-errno -fno-peephole -fno-peephole2
-fno-sched-interblock -fno-sched-spec -fno-signed-zeros
-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
-fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls
-fpeel-loops -fpredictive-commoning -fprefetch-loop-arrays
-fprofile-correction -fprofile-dir=path -fprofile-generate

-fprofile-generate=path
-fprofile-use -fprofile-use=path -fprofile-values
-freciprocal-math -fregmove -frename-registers -freorder-blocks
-freorder-blocks-and-partition -freorder-functions
-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
-frounding-math -frtl-abstract-sequences -fsched2-use-superblocks
-fsched2-use-traces -fsched-spec-load -fsched-spec-load-dangerous
-fsched-stalled-insns-dep[=n] -fsched-stalled-insns[=n]
-fschedule-insns -fschedule-insns2 -fsection-anchors -fsee
-fselective-scheduling -fselective-scheduling2
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
-fsignaling-nans -fsingle-precision-constant -fsplit-ivs-in-unroller
-fsplit-wide-types -fstack-protector -fstack-protector-all
-fstrict-aliasing -fstrict-overflow -fthread-jumps -ftracer
-ftree-builtin-call-dce -ftree-ccp -ftree-ch -ftree-copy-prop
-ftree-copyrename -ftree-dce
-ftree-dominator-opts -ftree-dse -ftree-fre -ftree-loop-im
-ftree-loop-distribution
-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
-ftree-parallelize-loops=n -ftree-pre -ftree-reassoc
-ftree-sink -ftree-sra -ftree-switch-conversion
-ftree-ter -ftree-vect-loop-version -ftree-vectorize -ftree-vrp
-funit-at-a-time -funroll-all-loops -funroll-loops
-funsafe-loop-optimizations -funsafe-math-optimizations -funswitch-loops
-fvariable-expansion-in-unroller -fvect-cost-model -fvpt -fweb
-fwhole-program
--param name=value -O -O0 -O1 -O2 -O3 -Os

预处理选项

-Aquestion=answer
-A-question[=answer]
-C -dD -dI -dM -dN
-Dmacro[=defn] -E -H
-idirafter dir
-include file -imacros file
-iprefix file -iwithprefix dir
-iwithprefixbefore dir -isystem dir
-imultilib dir -isysroot dir
-M -MM -MF -MG -MP -MQ -MT -nostdinc
-P -fworking-directory -remap
-trigraphs -undef -Umacro -Wp,option
-Xpreprocessor option
汇编选项
-Wa,option -Xassembler option
连接选项

object-file-name -llibrary
-nostartfiles -nodefaultlibs -nostdlib -pie -rdynamic
-s -static -static-libgcc -shared -shared-libgcc -symbolic
-T script -Wl,option -Xlinker option

-u symbol

原创粉丝点击