精選文章
mbed OS - gcc build option
續 : mbed OS user guide
看來是用這套 :Ninja Build System
在 blinky\build\stm32f429i-disco-gcc\ 下, 有一個 build.ninja, 可以看到 compiler options
-mcpu=cortex-m4 -mthumb
--std=gnu++11 :
使用的 語法標準 C++11 with gnu extensions
-fno-exceptions -fno-unwind-tables
Using Exceptions
  
DWARF based unwinding (.eh_frame)
-fno-rtti
-ffunction-sections -fdata-sections
linker 移除不需要的程式
-fno-threadsafe-statics
-g -gstrict-dwarf -gdwarf-3
Debug options; 使用 DWARF format 3, 且僅使用此,
-Wall -Wextra
-Os
Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size.
It also performs further optimizations designed to reduce code size.
-Os disables the following optimization flags:
之前自加的:
--save-temps : 同時產生 .i 和 .s 檔
-MMD : 生成文件關聯訊息, 輸出導入 .d 檔
其他想增加改進的:
http://blog.httrack.com/blog/2014/03/09/what-are-your-gcc-flags/
http://ptspts.blogspot.tw/2013/12/how-to-make-smaller-c-and-c-binaries.html
延伸閱讀:
pratical guild to bare metal c++
http://elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf
看來是用這套 :Ninja Build System
在 blinky\build\stm32f429i-disco-gcc\ 下, 有一個 build.ninja, 可以看到 compiler options
-mcpu=cortex-m4 -mthumb
   ARM cortex-m4 的設定, 視平台調整
使用的 語法標準 C++11 with gnu extensions
-fno-exceptions -fno-unwind-tables
Using Exceptions
- All exception handling in STL libraries are removed; throws are replaced with 
abort()calls - Stack unwind data and code is removed. This saves some code space, and may make register allocation marginally easier for the compiler (but I doubt it'll have much performance impact). Notably, however, if an exception is thrown, and the library tries to unwind through 
-fno-exceptionscode, it will abort at that point, as there is no unwind data. 
DWARF based unwinding (.eh_frame)
-fno-rtti
-ffunction-sections -fdata-sections
linker 移除不需要的程式
-fno-threadsafe-statics
     對於 local statics 變數, 為了做 thread safe, 會增加保護, 用此可以省些 code, 
     不做 thread safe 保護
Debug options; 使用 DWARF format 3, 且僅使用此,
-Wall -Wextra
  warning 類, all 全開, extra, 增開
Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size.
It also performs further optimizations designed to reduce code size.
-Os disables the following optimization flags:
          -falign-functions  -falign-jumps  -falign-loops 
          -falign-labels  -freorder-blocks  -freorder-blocks-and-partition -fprefetch-loop-arrays
-O turns on the following optimization flags:-O2 turns on all optimization flags specified by -O. It also turns on the following optimization flags:-fthread-jumps -fcrossjumping -foptimize-sibling-calls -fcse-follow-jumps -fcse-skip-blocks -fgcse -fgcse-lm -fexpensive-optimizations -fstrength-reduce -frerun-cse-after-loop -frerun-loop-opt -fcaller-saves -fforce-mem -fpeephole2 -fschedule-insns -fschedule-insns2 -fsched-interblock -fsched-spec -fregmove -fstrict-aliasing -fdelete-null-pointer-checks -freorder-blocks -freorder-functions -funit-at-a-time -falign-functions -falign-jumps -falign-loops -falign-labels -ftree-pre
          -fdefer-pop 
          -fdelayed-branch 
          -fguess-branch-probability 
          -fcprop-registers 
          -floop-optimize 
          -fif-conversion 
          -fif-conversion2 
          -ftree-ccp 
          -ftree-dce 
          -ftree-dominator-opts 
          -ftree-dse 
          -ftree-ter 
          -ftree-lrs 
          -ftree-sra 
          -ftree-copyrename 
          -ftree-fre 
          -ftree-ch 
-fmerge-constants
之前自加的:
-nostartfiles
      連接的時候不使用標準系統的啟動文件。標準系統庫通常被使用,除非選項“-nostdlib”和“-nodefaultlibs” 被使用。
-nodefaultlibs
     連接的使用不使用標準系統庫。只有你指定的庫才能夠傳遞給連接器。與系統庫有關的特定的連接選項(例如-static-libgcc 和-shared-libgcc )將會被忽略。標準的啟動文件通常會被使用,除非-nostartfiles選項被使用。
    編譯器可能會生成memcmp,memset,memcpy和memmove的調用,這些entries通常會被標準庫libc中的相關的entries解決。當這個選項被使用的時候,這些入口點應該通過其他的方法被提供。
 -nostdlib
    鏈接的時候不使用標準的系統啟動文件和系統庫。沒有啟動文件和只用你指定的庫可以被傳遞給連接器。與系統庫有關的特定的連接選項(例如-static-libgcc和-shared-libgcc )將會被忽略。編譯器可能會生成memcmp,memset,memcpy和memmove的調用,這些entries通常會被標準庫libc中的相關的entries解決。當這個選項被使用的時候,這些入口點應該通過其他的方法被提供。
--save-temps : 同時產生 .i 和 .s 檔
-MMD : 生成文件關聯訊息, 輸出導入 .d 檔
其他想增加改進的:
http://blog.httrack.com/blog/2014/03/09/what-are-your-gcc-flags/
http://ptspts.blogspot.tw/2013/12/how-to-make-smaller-c-and-c-binaries.html
延伸閱讀:
pratical guild to bare metal c++
http://elinux.org/images/2/2d/ELC2010-gc-sections_Denys_Vlasenko.pdf
留言
張貼留言