gcc(c\c++)命令参数行解析

阅读数:755 评论数:0

跳转到新版页面

分类

C/C++

正文

一、概述

GCC一般包括预处理、编译、组装和链接。GCC的运行一般是调用命令gcc,在cross-compiling时使用machine-gcc或machine-gcc-version,在使用c++时使用g++。

二、通用参数

-c -S -E -o file -x language
-v -### --help[=class[,...]] --target-help --version
-pass-exit-codes -pipe -specs=file -wrapper
@file -ffile-prefix-map=old=new
-fplugin=file -fplugin-arg-name=arg
-fdump-ada-spec[-slim] -fada-spec-parent=unit -fump-go-spec=file
-g 为了调试时使用,gdb会用到。
-x language filename

设定文件所使用的语言,使后缀名无效,对以后的多个有效。也就是根据约定C语言的后缀名称是.c的,而C++的后缀名是.C或者.cpp。

可以使用的参数有下面的这些:

‘c’,`objective-c',`c-header', `c++', `cpp-output', `assembler', and `assembler-with-cpp'。

例子用法: 

gcc -x c hello.pig 

-x none filename

 关掉上一个选项,也就是让gcc根据文件名后缀,自动识别文件类型
 例子用法: 

gcc -x c hello.pig -x none hello2.c 

-c

只激活预处理,编译,和汇编,也就是他只把程序做成obj文件

例子用法: 

gcc -c hello.c

他将生成.o的obj文件

-S

只激活预处理和编译,就是指把文件编译成为汇编代码。

例子用法

gcc -S hello.c

他将生成.s的汇编代码,你可以用文本编辑器察看

-E

只激活预处理,这个不生成文件,你需要把它重定向到一个输出文件里面。

 例子用法: 

  gcc -E hello.c > pianoapan.txt 

  gcc -E hello.c | more

一个hello word 也要与处理成800行的代码

-o

制定目标名称,缺省的时候,gcc 编译出来的文件是a.out

例子用法

gcc -o hello.exe hello.c (哦,windows用习惯了) 

gcc -o hello.asm -S hello.c

-v 编译过程的信息输出。
-### 和-v类似,但是命令并不真正执行,而且参数需要用双引号引起来,除非参数只包含数字、字母或./-_
--target-help 显示目标机器特定的命令行选项。
--version  显示编译器版本信息。
-pass-exit-codes 在某一阶段退出时返回其中最高的错误码
-pipe 使用管道代替临时文件,用于编译不同阶段的交互。
-specs=file 用文件的内容覆盖内建的specs文件,
-wrapper 所有命令都在一个包装程序下运行,包括程序和它的参数用逗号分开。例如 gcc -c t.c -wrapper gdb,--args。
-ffile-prefix-map=old=new 当编译在old目录中的文件时,记录它的引用时使用的相对目录是new目录。这个参数项造价于分别使用-f*-prefix-map参数项,这个参数项可以使编译结果与目录保持无关性。
-fplugin=name.so 从name.so中加载插件代码。
-fplugin-arg-name-key=value 为一个称为name的插件定义一个key=value的参数

三、C语言参数

-ansi -std=standard -fgnu89-inline
-fpermitted-flt-eval-methods=standard
-aux-info filename -fallow-parameterless-variadic-functions
-fno-asm -fno-builtin -fno-builtin-function -fgimple
-fhosted -ffreestanding -fopenacc -fopenmp -fopenmp-simd
-fms-extensions -fplan9-extensions -fsso-struct=endianness
-fallow-single-precision -fcond-mismatch -flax-vector-conversions
-fsigned-bitfields -fsigned-char
-funsigned-bitfields -funsigned-char
-ansi 以C语言中等价于-std=c90,在c++语言中等价于-std=c++90.
-std= 指定语言标准。当前只支持c和c++。
-fgnu89-inline 当在C99模式,对于inline函数使用传统的GNU语法。而-fno-gnu-gnu89-inline则表示相反。
-fpermitted-flt-eval-method=style FLT_EVAL_METHOD指定除赋值和转换之外的所有浮点算术运算完成的精度。style只能是c11或者ts-18661-3,默认对于-std=c11或者类似的,-fpermitted-flt-eval-methods=c11,而于-std=gnu11或者类似的,-fpermitted-flt-eval-methods=ts-18661-3。
-aux-info filename 把给定filename的文件中的所有函数声明包含到头文件里。
-fallow-parameterless-variadic-functions 允许无参的可变函数。
-fno-asm 不识别asm, inline或者typeof关键字,需要改成__asm__, __inline__ , __typeof__。-ansi参数项已包含此项。

-fno-builtin

-fno-builtin-function

不识别不以__builtin_开头的内置函数function。如果使用的-fno-builtin或者-ffreestanding时,但又想使用内置函数,需要定义宏。比如#define abs(n)  __builtin_abs  ((n))
-fhosted 等价于-fno-freestanding
-ffreestanding  实现了-fno-builtin,等价于-fno-hosted
-fopenacc 启用OpenACC指令。
-fopenmp 启用OpenMP指令。
-fms-extensions 接收微软头文件中使用的一些非标准结构。
-funsigned-char char类型是unsigned
-fsigned-char char类型是signed
-fsso-struct=endianess 大端存储big-endian,小端存储little-endian,主机默认存储native。

四、c++语言参数

-fabi-version=n -fno-access-control
-faligned-new=n -fargs-in-order=n -fcheck-new
-fconstexpr-depth=n -fconstexpr-loop-limit=n
-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
-fnew-inheriting-ctors
-fnew-ttp-matching
-fno-nonansi-builtins -fnothrow-opt -fno-operator-names
-fno-optional-diags -fpermissive
-fno-pretty-templates
-frepo -fno-rtti -fsized-deallocation
-ftemplate-backtrace-limit=n
-ftemplate-depth=n
-fno-threadsafe-statics -fuse-cxa-atexit
-fno-weak -nostdinc++
-fvisiblity-inlines-hidden
-fvisiblity-ms-compat
-fext-numeric-literals
-Wabi=n -Wabi-tag -Wconversion-null -Wctor-dtor-privacy
-Wdelete-non-virtual-dtor -Wliteral-suffix -Wmultiple-inheritance
-Wnamespaces -Wnarrowing
-Wnoexcept  -Wnoexcept-type -Wclass-memaccess
-Wnon-virtual-dtor -Wreorder -Wregister
-Weffc++ -Wstrict-null-sentinel -Wtemplates
-Wno-non-template-friedn -Wold-style-cast
-Woverloaded-virtual -Wno-pmf-conversions
-Wsign-promo -Wvirtual-inheritance

-fabi-version=n

指定C++ ABI(Application Binary Interface)的版本,默认是0。

五、调试信息格式参数项

-fmessage-length=n
-fdiagnostics-show-location=[once|every-line]
-fdiagnostics-color=[auto|never|always]
-fno-diagnostics-show-option -fno-diagnostics-show-caret
-fdiagnostics-parseable-fixits -fdiagnostics-generate-patch
-fdiagnostics-show-template-tree -fno-elide-type
-fno-show-column

六、报警参数项

-fsyntax-only -fmax-errors=n-Wpedantic
-pedantic-errors
-w -Wextra -Wall -Waddress -Waggregate-return -Waligned-new
-Walloc-zero -Walloc-size-larger-than=n-Walloca -Walloca-larger-than=n
-Wno-aggressive-loop-optimizations -Warray-bounds -Warray-bounds=n
-Wno-attributes -Wbool-compare -Wbool-operation
-Wno-builtin-declaration-mismatch
-Wno-builtin-macro-redefined -Wc90-c99-compat -Wc99-c11-compat
-Wc++-compat -Wc++11-compat -Wc++14-compat
-Wcast-align -Wcast-align=strict -Wcast-function-type -Wcast-qual
-Wchar-subscripts -Wchkp -Wcatch-value -Wcatch-value=n
-Wclobbered -Wcomment -Wconditionally-supported
-Wconversion -Wcoverage-mismatch -Wno-cpp -Wdangling-else -Wdate-time
-Wdelete-incomplete
-Wno-deprecated -Wno-deprecated-declarations -Wno-designated-init
-Wdisabled-optimization
-Wno-discarded-qualifiers -Wno-discarded-array-qualifiers
-Wno-div-by-zero -Wdouble-promotion
-Wduplicated-branches -Wduplicated-cond
-Wempty-body -Wenum-compare -Wno-endif-labels -Wexpansion-to-defined
-Werror -Werror=* -Wextra-semi -Wfatal-errors
-Wfloat-equal -Wformat -Wformat=2
-Wno-format-contains-nul -Wno-format-extra-args
-Wformat-nonliteral -Wformat-overflow=n
-Wformat-security -Wformat-signedness -Wformat-truncation=n
-Wformat-y2k -Wframe-address
-Wframe-larger-than=len
-Wno-free-nonheap-object -Wjump-misses-init
-Wif-not-aligned
-Wignored-qualifiers -Wignored-attributes -Wincompatible-pointer-types
-Wimplicit -Wimplicit-fallthrough -Wimplicit-fallthrough=n
-Wimplicit-function-declaration -Wimplicit-int
-Winit-self -Winline -Wno-int-conversion -Wint-in-bool-context
-Wno-int-to-pointer-cast -Winvalid-memory-model -Wno-invalid-offsetof
-Winvalid-pch -Wlarger-than=len
-Wlogical-op -Wlogical-not-parentheses -Wlong-long
-Wmain -Wmaybe-uninitialized -Wmemset-elt-size -Wmemset-transposed-args
-Wmisleading-indentation -Wmissing-attributes -Wmissing-braces
-Wmissing-field-initializers -Wmissing-include-dirs
-Wno-multichar -Wmultistatement-macros -Wnonnull -Wnonnull-compare
-Wnormalized=[none|id|nfc|nfkc]
-Wnull-dereference -Wodr -Wno-overflow -Wopenmp-simd
-Woverride-init-side-effects -Woverlength-strings
-Wpacked -Wpacked-bitfield-compat -Wpacked-not-aligned -Wpadded
-Wparentheses -Wno-pedantic-ms-format
-Wplacement-new -Wplacement-new=n
-Wpointer-arith -Wpointer-compare -Wno-pointer-to-int-cast
-Wno-pragmas -Wredundant-decls -Wrestrict -Wno-return-local-addr
-Wreturn-type -Wsequence-point -Wshadow -Wno-shadow-ivar
-Wshadow=global, -Wshadow=local, -Wshadow=compatible-local
-Wshift-overflow -Wshift-overflow=n
-Wshift-count-negative -Wshift-count-overflow -Wshift-negative-value
-Wsign-compare -Wsign-conversion -Wfloat-conversion
-Wno-scalar-storage-order -Wsizeof-pointer-div
-Wsizeof-pointer-memaccess -Wsizeof-array-argument
-Wstack-protector -Wstack-usage=len
-Wstrict-aliasing
-Wstrict-aliasing=n -Wstrict-overflow -Wstrict-overflow=n
-Wstringop-overflow=n
-Wstringop-truncation
-Wsuggest-attribute=[pure|const|noreturn|format|malloc]
-Wsuggest-final-types
-Wsuggest-final-methods -Wsuggest-override
-Wmissing-format-attribute -Wsubobject-linkage
-Wswitch -Wswitch-bool -Wswitch-default -Wswitch-enum
-Wswitch-unreachable -Wsync-nand
-Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs
-Wtype-limits -Wundef
-Wuninitialized -Wunknown-pragmas
-Wunsuffixed-float-constants -Wunused -Wunused-function
-Wunused-label -Wunused-local-typedefs -Wunused-macros
-Wunused-parameter -Wno-unused-result
-Wunused-value -Wunused-variable
-Wunused-const-variable -Wunused-const-variable=n
-Wunused-but-set-parameter -Wunused-but-set-variable
-Wuseless-cast -Wvariadic-macros -Wvector-operation-performance
-Wvla -Wvla-larger-than=n
-Wvolatile-register-var -Wwrite-strings-Wzero-as-null-pointer-constant -Whsa

七、c和objective-c专用报警参数项

-Wbad-function-cast -Wmissing-declarations
-Wmissing-parameter-type -Wmissing-prototypes -Wnested-externs
-Wold-style-declaration -Wold-style-definition
-Wstrict-prototypes -Wtraditional -Wtraditional-conversion
-Wdeclaration-after-statement -Wpointer-sign

八、调试参数项

g -glevel-gdwarf -gdwarf-version
-ggdb -grecord-gcc-switches -gno-record-gcc-switches
-gstabs -gstabs+ -gstrict-dwarf -gno-strict-dwarf
-gas-loc-support -gno-as-loc-support
-gas-locview-support -gno-as-locview-support
-gcolumn-info -gno-column-info
-gstatement-frontiers -gno-statement-frontiers
-gvariable-location-views -gno-variable-location-views
-ginternal-reset-location-views -gno-internal-reset-location-views
-ginline-points -gno-inline-points
-gvms -gxcoff -gxcoff+ -gz[=type]
-fdebug-prefix-map=old=new
-fdebug-types-section
-fno-eliminate-unused-debug-types
-femit-struct-debug-baseonly -femit-struct-debug-reduced
-femit-struct-debug-detailed[=spec-list]
-feliminate-unused-debug-symbols -femit-class-debug-always
-fno-merge-debug-strings -fno-dwarf2-cfi-asm
-fvar-tracking -fvar-tracking-assignments

九、优化参数项

-faggressive-loop-optimizations -falign-functions[=n]
-falign-jumps[=n]
-falign-labels[=n] -falign-loops[=n]
-fassociative-math -fauto-profile -fauto-profile[=path]
-fauto-inc-dec -fbranch-probabilities
-fbranch-target-load-optimize -fbranch-target-load-optimize2
-fbtr-bb-exclusive -fcaller-saves
-fcombine-stack-adjustments -fconserve-stack
-fcompare-elim -fcprop-registers -fcrossjumping
-fcse-follow-jumps -fcse-skip-blocks -fcx-fortran-rules
-fcx-limited-range
-fdata-sections -fdce -fdelayed-branch
-fdelete-null-pointer-checks -fdevirtualize -fdevirtualize-speculatively
-fdevirtualize-at-ltrans -fdse
-fearly-inlining -fipa-sra -fexpensive-optimizations -ffat-lto-objects
-ffast-math -ffinite-math-only -ffloat-store -fexcess-precision=style
-fforward-propagate -ffp-contract=style
-ffunction-sections
-fgcse -fgcse-after-reload -fgcse-las -fgcse-lm -fgraphite-identity
-fgcse-sm -fhoist-adjacent-loads -fif-conversion
-fif-conversion2 -findirect-inlining
-finline-functions -finline-functions-called-once -finline-limit=n
-finline-small-functions -fipa-cp -fipa-cp-clone
-fipa-bit-cp -fipa-vrp
-fipa-pta -fipa-profile -fipa-pure-const -fipa-reference -fipa-icf
-fira-algorithm=algorithm
-fira-region=region
-fira-hoist-pressure
-fira-loop-pressure -fno-ira-share-save-slots
-fno-ira-share-spill-slots
-fisolate-erroneous-paths-dereference -fisolate-erroneous-paths-attribute
-fivopts -fkeep-inline-functions -fkeep-static-functions
-fkeep-static-consts -flimit-function-alignment -flive-range-shrinkage
-floop-block -floop-interchange -floop-strip-mine
-floop-unroll-and-jam -floop-nest-optimize
-floop-parallelize-all -flra-remat -flto -flto-compression-level
-flto-partition=alg
-fmerge-all-constants
-fmerge-constants -fmodulo-sched -fmodulo-sched-allow-regmoves
-fmove-loop-invariants -fno-branch-count-reg
-fno-defer-pop -fno-fp-int-builtin-inexact -fno-function-cse
-fno-guess-branch-probability -fno-inline -fno-math-errno -fno-peephole
-fno-peephole2 -fno-printf-return-value -fno-sched-interblock
-fno-sched-spec -fno-signed-zeros
-fno-toplevel-reorder -fno-trapping-math -fno-zero-initialized-in-bss
-fomit-frame-pointer -foptimize-sibling-calls
-fpartial-inlining -fpeel-loops -fpredictive-commoning
-fprefetch-loop-arrays
-fprofile-correction-fprofile-use -fprofile-use=path
-fprofile-values
-fprofile-reorder-functions
-freciprocal-math -free -frename-registers -freorder-blocks
-freorder-blocks-algorithm=algorithm
-freorder-blocks-and-partition -freorder-functions
-frerun-cse-after-loop -freschedule-modulo-scheduled-loops
-frounding-math -fsched2-use-superblocks -fsched-pressure
-fsched-spec-load -fsched-spec-load-dangerous
-fsched-stalled-insns-dep[=n] -fsched-stalled-insns[=n]
-fsched-group-heuristic -fsched-critical-path-heuristic
-fsched-spec-insn-heuristic -fsched-rank-heuristic
-fsched-last-insn-heuristic -fsched-dep-count-heuristic
-fschedule-fusion-fschedule-insns -fschedule-insns2 -fsection-anchors
-fselective-scheduling -fselective-scheduling2
-fsel-sched-pipelining -fsel-sched-pipelining-outer-loops
-fsemantic-interposition -fshrink-wrap -fshrink-wrap-separate
-fsignaling-nans
-fsingle-precision-constant -fsplit-ivs-in-unroller -fsplit-loops
-fsplit-paths-fsplit-wide-types -fssa-backprop -fssa-phiopt
-fstdarg-opt -fstore-merging -fstrict-aliasing
-fthread-jumps -ftracer -ftree-bit-ccp
-ftree-builtin-call-dce -ftree-ccp -ftree-ch
-ftree-coalesce-vars -ftree-copy-prop -ftree-dce -ftree-dominator-opts
-ftree-dse -ftree-forwprop -ftree-fre -fcode-hoisting
-ftree-loop-if-convert -ftree-loop-im
-ftree-phiprop -ftree-loop-distribution -ftree-loop-distribute-patterns
-ftree-loop-ivcanon -ftree-loop-linear -ftree-loop-optimize
-ftree-loop-vectorize
-ftree-parallelize-loops=n-ftree-pre -ftree-partial-pre -ftree-pta
-ftree-reassoc -ftree-sink -ftree-slsr -ftree-sra
-ftree-switch-conversion -ftree-tail-merge
-ftree-ter -ftree-vectorize -ftree-vrp -funconstrained-commons
-funit-at-a-time -funroll-all-loops -funroll-loops
-funsafe-math-optimizations -funswitch-loops
-fipa-ra -fvariable-expansion-in-unroller -fvect-cost-model -fvpt
-fweb -fwhole-program -fwpa -fuse-linker-plugin
--paramname=value-O -O0 -O1 -O2 -O3 -Os -Ofast -Og

-O

-O1

-O尝试优化编译生成的代码大小和执行时间,但不会进行编译耗时较多的优化操作。
-O2 相比于-O,在编译时间变长,但编译生成的代码性能更高
-O3 进一步增加优化项
-O0 这个默认值,减少编译时长,生成可调试的代码
-Os 对生成的代码大小进行优化。开启了-O2的所有优化项,但代码大小不增长。
-Ofast 开启了所有-O3的优化项,但是忽略严格的标准编译标准
-Og 优化调试体验。优化内容不涉及调试交互部分。

 

十、编程指令参数项

-p -pg -fprofile-arcs --coverage -ftest-coverage
-fprofile-abs-path
-fprofile-dir=path-fprofile-generate -fprofile-generate=path
-fsanitize=style-fsanitize-recover -fsanitize-recover=style
-fasan-shadow-offset=number-fsanitize-sections=s1,s2,...
-fsanitize-undefined-trap-on-error -fbounds-check
-fcheck-pointer-bounds -fchkp-check-incomplete-type
-fchkp-first-field-has-own-bounds -fchkp-narrow-bounds
-fchkp-narrow-to-innermost-array -fchkp-optimize-fchkp-use
-fast-string-functions -fchkp-use-nochk-string-functions
-fchkp-use-static-bounds -fchkp-use-static-const-bounds
-fchkp-treat-zero-dynamic-size-as-infinite -fchkp-check-read
-fchkp-check-read -fchkp-check-write -fchkp-store-bounds
-fchkp-instrument-calls -fchkp-instrument-marked-only
-fchkp-use-wrappers -fchkp-flexible-struct-trailing-arrays
-fcf-protection=[full|branch|return|none]
-fstack-protector -fstack-protector-all -fstack-protector-strong
-fstack-protector-explicit -fstack-check
-fstack-limit-register=reg
-fstack-limit-symbol=sym
-fno-stack-limit -fsplit-stack
-fvtable-verify=[std|preinit|none]
-fvtv-counts -fvtv-debug
-finstrument-functions
-finstrument-functions-exclude-function-list=sym,sym,...
-finstrument-functions-exclude-file-list=file,file,...

-finstrument-functions

编译器会在函数的前面添加__cyg_profile_func_enter(),在后面添加__cyg_profile_func_exit()。

十一、预处理参数项

-Aquestion=answer
-A-question[=answer]
-C -CC -Dmacro[=defn]
-dD -dI -dM -dN -dU
-fdebug-cpp -fdirectives-only -fdollars-in-identifiers
-fexec-charset=charset
-fextended-identifiers
-finput-charset=charset
-fmacro-prefix-map=old=new
-fno-canonical-system-headers
-fpch-deps -fpch-preprocess
-fpreprocessed -ftabstop=width
-ftrack-macro-expansion
-fwide-exec-charset=charset
-fworking-directory
-H -imacrosfile-includefile
-M -MD -MF -MG -MM -MMD -MP -MQ -MT
-no-integrated-cpp -P -pthread -remap
-traditional -traditional-cpp -trigraphs
-Umacro-undef
-Wp,option-Xpreprocessor option
-D name 定义一个名为name值为1的宏
-D name=definition 类似于#define指令,
-U name 取消之前宏定义
-include file 作用同#include "file",但是此时搜索的第一个目录不是源文件所在的目录,而是预处理的工作目录。
-imacros file 和-include非常像,但是它只获取文件中的宏。
-undef 不预定义任何系统特定的或GCC特定的宏,但是其它标准的预定义宏仍然存在。
-pthread

定义了使用POSIX线程库时需要额外宏。

 

-M 不输出预编译的结果,而是根据main source file输出一个适合的make 规则用于描述其依赖。
-fpreprocessed 标识输入文件已经被预处理过。
-fdirective-only  在预处理时,只处理指令,不扩展宏。
-fdollars-in-identifiers 标识符里可以使用$
-fextended-identifiers 标识符中可以使用unicode
-fno-canonical-system-headers 在预处理时,系统头文件路径规范时不缩写。
-ftabstop=width 设置tab的字符数
-fmacro-prefix-map=old=new 当对old目录中的文件预处理时,在扩展__FILE__和__BASE_FILE__宏时,相对的目录设置为new,而不是old。
-fexec-charset=charset 设置字符串和字符常量使用的字符集,默认是utf-8,字符集可心人造丝主iconv库支持的任何字符集。
-fwide-exec-charset=charset 设置宽字符串和字符常量使用的字符集
-finput-charset=charset 设置输入使用的字符集。
-fworking-directory 预处理时输出行标志。
-C 保留注释
-CC 保留注释,包括宏扩展过程。
-P 在预处理时不生成行标志。

 

十二、组装参数项

Wa,option-Xassembler option

十三、链接参数项

object-file-name -fuse-ld=linker -llibrary
-nostartfiles -nodefaultlibs -nostdlib -pie -pthread -rdynamic
-s -static -static-pie -static-libgcc -static-libstdc++
-static-libasan -static-libtsan -static-liblsan -static-libubsan
-static-libmpx -static-libmpxwrappers
-shared -shared-libgcc -symbolic
-T script -Wl,option -Xlinker option
-u symbol -z keyword

十四、header搜索目录参数项

-Bprefix -I dir -I-
-idirafter dir
-imacros file-imultilib dir
-iplugindir=dir -iprefix file
-iquote dir-isysroot dir -isystem dir
-iwithprefix dir-iwithprefixbefore dir
-Ldir -no-canonical-prefixes --no-sysroot-suffix
-nostdinc -nostdinc++ --sysroot=dir

-I dir

-iquote dir

-isystem dir

-idirafter dir

-iquote只对双引号的#include "file"有效,-I、-isystem,-idirafter对#include "file"和#include <file>都有效。它们搜索的顺序:

1、对于相引号的#include,第一个搜索的目录是当前目录。

2、对于双引号的#include,接下来从左到右搜索-iquote指定的目录。

3、从左到右搜索-I指定的目录

4、从左到右搜索-isystem指定的目录

5、从左到右搜索-idirater指定的目录。

-iwithprefix dir

-iwithprefixbefore dir

-iwithprefix dir是把目录添加在-idirafter级别,-iwithprefixbefore dir是把目录添加到-I级别

十五、代码生成参数项

-fcall-saved-reg
-fcall-used-reg
-ffixed-reg-fexceptions
-fnon-call-exceptions -fdelete-dead-exceptions -funwind-tables
-fasynchronous-unwind-tables
-fno-gnu-unique
-finhibit-size-directive -fno-common -fno-ident
-fpcc-struct-return -fpic -fPIC -fpie -fPIE -fno-plt
-fno-jump-tables
-frecord-gcc-switches
-freg-struct-return -fshort-enums -fshort-wchar
-fverbose-asm -fpack-struct[=n]
-fleading-underscore -ftls-model=model
-fstack-reuse=reuse_level
-ftrampolines -ftrapv -fwrapv
-fvisibility=[default|internal|hidden|protected]
-fstrict-volatile-bitfields -fsync-libcalls

十六、机器相关参数项

(1)GNU/Linux参数项

-mglibc -muclibc -mmusl -mbionic -mandroid-tno-android-cc -tno-android-ld

(2)x86参数项

-mtune=cpu-type
-march=cpu-type
-mtune-ctrl=feature-list
-mdump-tune-features -mno-default
-mfpmath=unit
-masm=dialect
-mno-fancy-math-387
-mno-fp-ret-in-387 -m80387 -mhard-float -msoft-float
-mno-wide-multiply -mrtd -malign-double
-mpreferred-stack-boundary=num
-mincoming-stack-boundary=num
-mcld -mcx16 -msahf -mmovbe -mcrc32
-mrecip -mrecip=opt
-mvzeroupper -mprefer-avx128 -mprefer-vector-width=opt
-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx
-mavx2 -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl
-mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi -msha -maes
-mpclmul -mfsgsbase -mrdrnd -mf16c -mfma -mpconfig -mwbnoinvd
-mprefetchwt1 -mclflushopt -mclwb -mxsavec -mxsaves
-msse4a -m3dnow -m3dnowa -mpopcnt -mabm -mbmi -mtbm -mfma4 -mxop
-madx -mlzcnt -mbmi2 -mfxsr -mxsave -mxsaveopt -mrtm -mlwp -mmpx
-mmwaitx -mclzero -mpku -mthreads -mgfni -mvaes
-mshstk -mforce-indirect-call -mavx512vbmi2
-mvpclmulqdq -mavx512bitalg -mmovdiri -mmovdir64b -mavx512vpopcntdq
-mavx5124fmaps -mavx512vnni -mavx5124vnniw -mprfchw -mrdpid
-mrdseed -msgx-mms-bitfields -mno-align-stringops -minline-all-stringops
-minline-stringops-dynamically -mstringop-strategy=alg
-mmemcpy-strategy=strategy
-mmemset-strategy=strategy
-mpush-args -maccumulate-outgoing-args -m128bit-long-double
-m96bit-long-double -mlong-double-64 -mlong-double-80 -mlong-double-128
-mregparm=num
-msseregparm
-mveclibabi=type
-mvect8-ret-in-mem
-mpc32 -mpc64 -mpc80 -mstackrealign
-momit-leaf-frame-pointer -mno-red-zone -mno-tls-direct-seg-refs
-mcmodel=code-model
-mabi=name-maddress
-mode=mode
-m32 -m64 -mx32 -m16 -miamcu -mlarge-data-threshold=num
-msse2avx -mfentry -mrecord-mcount -mnop-mcount -m8bit-idiv
-mavx256-split-unaligned-load -mavx256-split-unaligned-store
-malign-data=type
-mstack-protector-guard=guard
-mstack-protector-guard-reg=reg
-mstack-protector-guard-offset=offset
-mstack-protector-guard-symbol=symbol
-mmitigate-rop
-mgeneral-regs-only -mcall-ms2sysv-xlogues
-mindirect-branch=choice
-mfunction-return=choice
-mindirect-branch-register

 

 




相关推荐

文档对应gcc版本8.4 GCC原来表示GNU C Compiler,现在一脙GNU Compiler Collection。支持C、C++、Objective-C,Objecti

一、概述 1、作用 __attribute__ 可以设置函数属性(Function Attribute)、变量属性(Variable Attribute)和类型属性(Type Attribute)。

编译器中的sanitize来自于google的开源sanitizers项目,后GNU将该工具加入到GCC编译中,是查找隐藏Bug的利器。 -fsanitize=address</p

一、基本的asm 格式: asm asm-qualifiers ( AssemblerInstructions) (1)asm关键字是GNU的扩展,当编译配置项为-ansi或-std配置项时,使用__

内建函数就是编译器内部实现的函数,它们随时跟着gcc升级而变化,所以不推荐普遍的使用。使用内建函数更高效,因为它们大多以inline方式编译或者针对特定平台进行优化。 C标准库中的

在1999年的ISO C标准中,一个函数可以接收变参数,而宏定义中也可以接收变参数,例如: #define debug(for

强弱符号的链接规则 链接器会按照如下规则处理与选择被多次定义的全局符号 (1)不允许强符号被多次定义,如果有多个强符号定义,则链

一、概述 1、prolog与epilog prolog翻译过来是“序言;开端”。 epilog翻译过来是”后记;结语“。 prolog与epilog其实就是两段固定的代码,当编译器对程序进行编译的时候

在C语言编程过程中,我们常常会实现一些可变参数的函数调用(类scanf、printf函数),变参函数在我们编程过程中带来了很大的方便,但是也有一些问题,即我们在调用可变参数的函数的时候,默认情况

GCC:GNU(Gnu's Not Unix)编译器套装(GNU Compiler Collection,GCC),指一套编程语言编译器,以GPL及LGPL许可证所发行的自由软件