最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【整理】crosstool中Target CFLAGS参数的含义和如何设置

CrossCompiler crifan 5859浏览 0评论

【背景】

折腾:

【记录】在Cygwin下编译gcc-3.4.5-glibc-2.3.6的arm-xscale-linux-gnu交叉编译器

期间,需要搞懂,对应的Target CFLAGS的含义,以及如何配置。

【折腾过程】

1.去看看Target CFLAGS的帮助说明:

crosstool-NG v1.9.3 Configuration – .config

Target CFLAGS
CT_TARGET_CFLAGS:

Used to add specific options when compiling libraries of the toolchain,
that will run on the target (eg. libc.so).                            
                                                                      
Note that the options above for ARCH, ABI, CPU, TUNE and FPU will be  
automaticaly used. You don’t need to specify them here.               
                                                                      
Leave blank if you don’t know better.

Symbol: TARGET_CFLAGS [=]                                             
Prompt: Target CFLAGS
  Defined at config/target.in:293
  Location:
    -> Target options

2.参考之前别人的配置:

http://crosstool.googlecode.com/svn/trunk/src/buildlogs/arm-xscale-gcc-3.4.5-glibc-2.3.2-tls.dat.txt

http://hg.easyneuf.org/crosstool/annotate/32fbc2e2154a/buildlogs/arm-xscale-gcc-3.4.5-glibc-2.3.6.dat.txt

去添加一个-O。

3.但是也要去搞清楚-O是啥意思。

所以找到:

3.10 Options That Control Optimization

看到真正的官网解释:

-O
-O1
    Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

    With -O, the compiler tries to reduce code size and execution time, without performing any optimizations that take a great deal of compilation time.

    -O turns on the following optimization flags:

              -fauto-inc-dec
              -fcompare-elim
              -fcprop-registers
              -fdce
              -fdefer-pop
              -fdelayed-branch
              -fdse
              -fguess-branch-probability
              -fif-conversion2
              -fif-conversion
              -fipa-pure-const
              -fipa-profile
              -fipa-reference
              -fmerge-constants
              -fsplit-wide-types
              -ftree-bit-ccp
              -ftree-builtin-call-dce
              -ftree-ccp
              -ftree-ch
              -ftree-copyrename
              -ftree-dce
              -ftree-dominator-opts
              -ftree-dse
              -ftree-forwprop
              -ftree-fre
              -ftree-phiprop
              -ftree-slsr
              -ftree-sra
              -ftree-pta
              -ftree-ter
              -funit-at-a-time

    -O also turns on -fomit-frame-pointer on machines where doing so does not interfere with debugging.

4.所以,就去设置为-O即可:

target cflags use o

(-O) Target CFLAGS

 

【总结】

-O

== -O1(默认为O1)

==会执行很多优化的动作(具体参见上面的列表),以实现:降低代码大小和执行时间

(而如果不优化,编译时间会大大增加)

转载请注明:在路上 » 【整理】crosstool中Target CFLAGS参数的含义和如何设置

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.186 seconds, using 22.19MB memory