linux编译gcc多久时间,Linux gcc编译参数说明

在linux中使用gcc编译程序时,若使用-g参数在程序中加入调试信息,则生成可执行文件的大小接近不加-g参数时的两倍。

1.-O,-O1:

这两个命令的效果是一样的,目的都是在不影响编译速度的前提下,尽量采用一些优化算法降低代码大小和可执行代码的运行速度。并开启如下的优化选项:

-fauto-inc-dec

-fbranch-count-reg

-fcombine-stack-adjustments

-fcompare-elim

-fcprop-registers

-fdce

-fdefer-pop

-fdelayed-branch

-fdse

-fforward-propagate

-fguess-branch-probability

-fif-conversion2

-fif-conversion

-finline-functions-called-once

-fipa-pure-const

-fipa-profile

-fipa-reference

-fmerge-constants

-fmove-loop-invariants

-freorder-blocks

-fshrink-wrap

-fshrink-wrap-separate

-fsplit-wide-types

-fssa-backprop

-fssa-phiopt

-fstore-merging

-ftree-bit-ccp

-ftree-ccp

-ftree-ch

-ftree-coalesce-vars

-ftree-copy-prop

-ftree-dce

-ftree-dominator-opts

-ftree-dse

-ftree-forwprop

-ftree-fre

-ftree-phiprop

-ftree-sink

-ftree-slsr

-ftree-sra

-ftree-pta

-ftree-ter

-funit-at-a-time

2. -O2

该优化选项会牺牲部分编译速度,除了执行-O1所执行的所有优化之外,还会采用几乎所有的目标配置支持的优化算法,用以提高目标代码的运行速度。

-fthread-jumps

-falign-functions  -falign-jumps

-falign-loops  -falign-labels

-fcaller-saves

-fcrossjumping

-fcse-follow-jumps  -fcse-skip-blocks

-fdelete-null-pointer-checks

-fdevirtualize -fdevirtualize-speculatively

-fexpensive-optimizations

-fgcse  -fgcse-lm

-fhoist-adjacent-loads

-finline-small-functions

-findirect-inlining

-fipa-cp

-fipa-cp-alignment

-fipa-bit-cp

-fipa-sra

-fipa-icf

-fisolate-erroneous-paths-dereference

-flra-remat

-foptimize-sibling-calls

-foptimize-strlen

-fpartial-inlining

-fpeephole2

-freorder-blocks-algorithm=stc

-freorder-blocks-and-partition -freorder-functions

-frerun-cse-after-loop

-fsched-interblock  -fsched-spec

-fschedule-insns  -fschedule-insns2

-fstrict-aliasing -fstrict-overflow

-ftree-builtin-call-dce

-ftree-switch-conversion -ftree-tail-merge

-fcode-hoisting

-ftree-pre

-ftree-vrp

-fipa-ra

3. -O3

该选项除了执行-O2所有的优化选项之外,一般都是采取很多向量化算法,提高代码的并行执行程度,利用现代CPU中的流水线,Cache等。这个选项会提高执行代码的大小,当然会降低目标代码的执行时间。

-finline-functions      // 采用一些启发式算法对函数进行内联

-funswitch-loops        // 执行循环unswitch变换

-fpredictive-commoning  //

-fgcse-after-reload     //执行全局的共同子表达式消除

-ftree-loop-vectorize   //

-ftree-loop-distribute-patterns

-fsplit-paths

-ftree-slp-vectorize

-fvect-cost-model

-ftree-partial-pre

-fpeel-loops

-fipa-cp-clone options

4. -Os

这个优化标识和-O3有异曲同工之妙,当然两者的目标不一样,-O3的目标是宁愿增加目标代码的大小,也要拼命的提高运行速度,但是这个选项是在-O2的基础之上,尽量的降低目标代码的大小,这对于存储容量很小的设备来说非常重要。为了降低目标代码大小,会禁用下列优化选项,一般就是压缩内存中的对齐空白(alignment padding)

-falign-functions

-falign-jumps

-falign-loops

-falign-labels

-freorder-blocks

-freorder-blocks-algorithm=stc

-freorder-blocks-and-partition

-fprefetch-loop-arrays

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值