2012-09-15 69 views
2

我正在開發嵌入式ARM平臺上運行的軟件。在更新我們的平臺的過程中,我們正在從基於OpenEmbedded的系統切換到Linaro。Linaro編譯速度

在我的機器上,使用OpenEmbedded爲我們構建的32位gcc 4.6.4,我們需要大約9分鐘的時間來交叉編譯我們的ARM軟件。對於新系統,我們現在正在嘗試使用Linaro的gcc 4.7二進制文件 - 令人驚訝的結果是編譯突然需要大約兩倍的時間(18分鐘)。 Linaro gcc 4.6二進制文件具有相同的問題,因此它不是gcc版本特定的。

使用Linaro的crosstool-ng創建其編譯器的調整版本(例如嘗試儘可能接近配置選項)沒有加快速度。

  • 舊使用softfp,Linaro的硬並指定FPU
  • 舊目標沒有特別的ARM處理器/架構(ARM-無:

    我們的舊gcc編譯和Linaro的一個之間的主要區別-linux-gnueabi),Linaro的GCC(ARM-Linux的gnueabihf)具有with-target=armv7-awith-tune=cortex-a9明確地設置

更改配置的gcc選項,如啓用的SSP,拇指/臂模式,採用的multilib,目標CPU(cortex- a8訴s a9)沒有產生改善。

對於一個簡單的test.cpp,性能速度已經有所不同了,它只有一個主要功能vector<int>,所以它與鏈接無關,我懷疑STL頭文件造成了很大的差別。

我想出了什麼來調整。有人有想法嗎?


EDIT4:我也嘗試了手臂交叉編譯器的Ubuntu 12.04(gcc版本4.6.3(Ubuntu的/ Linaro的4.6.3-1ubuntu5)),它具有相當的編譯時間到我的4.6.4版本。所以在Linaro的版本中似乎有些特別的不同,我可能無法關閉或者是他們應用的一些特殊補丁?


EDIT3:-ftime-report從Linaro的GCC 4.7從項目的實際源文件:

Execution times (seconds) 
phase setup    : 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall 2076 kB (2%) ggc 
phase parsing   : 1.72 (74%) usr 0.34 (85%) sys 2.04 (75%) wall 66732 kB (79%) ggc 
phase lang. deferred : 0.28 (12%) usr 0.04 (10%) sys 0.33 (12%) wall 10215 kB (12%) ggc 
phase cgraph   : 0.32 (14%) usr 0.02 (5%) sys 0.33 (12%) wall 5481 kB (6%) ggc 
phase generate   : 0.60 (26%) usr 0.06 (15%) sys 0.66 (24%) wall 15700 kB (19%) ggc 
|name lookup   : 0.28 (12%) usr 0.02 (5%) sys 0.24 (9%) wall 8058 kB (10%) ggc 
|overload resolution : 0.32 (14%) usr 0.06 (15%) sys 0.36 (13%) wall 10042 kB (12%) ggc 
callgraph construction : 0.06 (3%) usr 0.00 (0%) sys 0.02 (1%) wall  551 kB (1%) ggc 
callgraph optimization : 0.02 (1%) usr 0.00 (0%) sys 0.01 (0%) wall  224 kB (0%) ggc 
varpool construction : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  94 kB (0%) ggc 
df scan insns   : 0.06 (3%) usr 0.00 (0%) sys 0.02 (1%) wall  5 kB (0%) ggc 
df reg dead/unused notes: 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  22 kB (0%) ggc 
alias analysis   : 0.00 (0%) usr 0.02 (5%) sys 0.00 (0%) wall  11 kB (0%) ggc 
preprocessing   : 0.08 (3%) usr 0.10 (25%) sys 0.29 (11%) wall 1069 kB (1%) ggc 
parser (global)   : 0.58 (25%) usr 0.08 (20%) sys 0.43 (16%) wall 25145 kB (30%) ggc 
parser struct body  : 0.28 (12%) usr 0.02 (5%) sys 0.34 (12%) wall 12400 kB (15%) ggc 
parser enumerator list : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  121 kB (0%) ggc 
parser function body : 0.14 (6%) usr 0.00 (0%) sys 0.15 (6%) wall 2435 kB (3%) ggc 
parser inl. func. body : 0.10 (4%) usr 0.02 (5%) sys 0.18 (7%) wall 3682 kB (4%) ggc 
parser inl. meth. body : 0.24 (10%) usr 0.02 (5%) sys 0.20 (7%) wall 5298 kB (6%) ggc 
template instantiation : 0.58 (25%) usr 0.14 (35%) sys 0.75 (28%) wall 26588 kB (31%) ggc 
tree gimplify   : 0.02 (1%) usr 0.00 (0%) sys 0.03 (1%) wall  785 kB (1%) ggc 
tree CFG construction : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  543 kB (1%) ggc 
tree SSA other   : 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall  32 kB (0%) ggc 
out of ssa    : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  0 kB (0%) ggc 
expand     : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  438 kB (1%) ggc 
varconst    : 0.00 (0%) usr 0.00 (0%) sys 0.01 (0%) wall  6 kB (0%) ggc 
integrated RA   : 0.04 (2%) usr 0.00 (0%) sys 0.09 (3%) wall 1313 kB (2%) ggc 
reload     : 0.06 (3%) usr 0.00 (0%) sys 0.02 (1%) wall  60 kB (0%) ggc 
thread pro- & epilogue : 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall  92 kB (0%) ggc 
final     : 0.02 (1%) usr 0.00 (0%) sys 0.02 (1%) wall  4 kB (0%) ggc 
rest of compilation  : 0.02 (1%) usr 0.00 (0%) sys 0.02 (1%) wall  133 kB (0%) ggc 
unaccounted todo  : 0.02 (1%) usr 0.00 (0%) sys 0.01 (0%) wall  0 kB (0%) ggc 
TOTAL     : 2.32    0.40    2.72    84519 kB 

與同爲我的gcc-4.6:

Execution times (seconds) 
callgraph construction: 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall  527 kB (1%) ggc 
trivially dead code : 0.00 (0%) usr 0.00 (0%) sys 0.01 (1%) wall  0 kB (0%) ggc 
df scan insns   : 0.02 (2%) usr 0.00 (0%) sys 0.01 (1%) wall  5 kB (0%) ggc 
df reg dead/unused notes: 0.00 (0%) usr 0.00 (0%) sys 0.01 (1%) wall  22 kB (0%) ggc 
preprocessing   : 0.08 (7%) usr 0.10 (26%) sys 0.14 (9%) wall 1016 kB (1%) ggc 
parser    : 0.68 (58%) usr 0.24 (63%) sys 0.83 (52%) wall 52215 kB (76%) ggc 
name lookup   : 0.28 (24%) usr 0.02 (5%) sys 0.41 (26%) wall 10211 kB (15%) ggc 
inline heuristics  : 0.00 (0%) usr 0.02 (5%) sys 0.00 (0%) wall  0 kB (0%) ggc 
tree gimplify   : 0.00 (0%) usr 0.00 (0%) sys 0.01 (1%) wall  637 kB (1%) ggc 
tree CFG construction : 0.02 (2%) usr 0.00 (0%) sys 0.00 (0%) wall  463 kB (1%) ggc 
expand    : 0.02 (2%) usr 0.00 (0%) sys 0.01 (1%) wall  426 kB (1%) ggc 
varconst    : 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall  132 kB (0%) ggc 
integrated RA   : 0.02 (2%) usr 0.00 (0%) sys 0.03 (2%) wall  304 kB (0%) ggc 
reload    : 0.00 (0%) usr 0.00 (0%) sys 0.01 (1%) wall  58 kB (0%) ggc 
machine dep reorg  : 0.02 (2%) usr 0.00 (0%) sys 0.00 (0%) wall  3 kB (0%) ggc 
final     : 0.00 (0%) usr 0.00 (0%) sys 0.02 (1%) wall  4 kB (0%) ggc 
rest of compilation : 0.02 (2%) usr 0.00 (0%) sys 0.01 (1%) wall  133 kB (0%) ggc 
unaccounted todo  : 0.02 (2%) usr 0.00 (0%) sys 0.03 (2%) wall  0 kB (0%) ggc 
TOTAL     : 1.18    0.38    1.59    68315 kB 

EDIT2: Linaro gc ç4.6.3的-ftime-report輸出一個非常簡單的TEST.CPP(包括期權-fno-graphite-identity -fno-graphite):

Execution times (seconds) 
preprocessing   : 0.00 (0%) usr 0.02 (50%) sys 0.02 (10%) wall  121 kB (2%) ggc 
parser    : 0.10 (62%) usr 0.02 (50%) sys 0.11 (55%) wall 4022 kB (65%) ggc 
name lookup   : 0.02 (12%) usr 0.00 (0%) sys 0.04 (20%) wall  879 kB (14%) ggc 
tree gimplify   : 0.02 (13%) usr 0.00 (0%) sys 0.00 (0%) wall  20 kB (0%) ggc 
expand    : 0.00 (0%) usr 0.00 (0%) sys 0.01 (5%) wall  34 kB (1%) ggc 
integrated RA   : 0.02 (12%) usr 0.00 (0%) sys 0.01 (5%) wall  59 kB (1%) ggc 
TOTAL     : 0.16    0.04    0.20    6207 kB 

,並用我的舊的gcc 4.6.4在同一個文件:

Execution times (seconds) 
preprocessing   : 0.02 (25%) usr 0.00 (0%) sys 0.02 (14%) wall  119 kB (2%) ggc 
parser    : 0.00 (0%) usr 0.04 (100%) sys 0.06 (43%) wall 4021 kB (65%) ggc 
name lookup   : 0.04 (50%) usr 0.00 (0%) sys 0.03 (21%) wall  879 kB (14%) ggc 
expand    : 0.02 (25%) usr 0.00 (0%) sys 0.01 (7%) wall  34 kB (1%) ggc 
unaccounted todo  : 0.00 (0%) usr 0.00 (0%) sys 0.01 (7%) wall  0 kB (0%) ggc 
TOTAL     : 0.08    0.04    0.14    6204 kB 

生成預處理文件兩個編譯器都沒有產生顯着差異(Linaro的gcc的輸出只有3行更長)。


EDIT1: GCC -v用於縮短或除去舊的(路徑(例如--sbindir)

# arm-none-linux-gnueabi-g++ -v 
Using built-in specs. 
COLLECT_GCC=..sysroots/i686-linux/usr/bin/arm-none-linux-gnueabi-g++ 
COLLECT_LTO_WRAPPER=../libexec/gcc/arm-none-linux-gnueabi/4.6.4/lto-wrapper 
Target: arm-none-linux-gnueabi 
Configured with: ..tmp/work/armv7a-none-linux-gnueabi/gcc-cross-4.6.3+svnr184847-r27/gcc-4_6-branch/configure --build=i686-linux --host=i686-linux --target=arm-none-linux-gnueabi --with-gnu-ld --enable-shared --enable-languages=c,c++ --enable-threads=posix --disable-multilib --enable-c99 --enable-long-long --enable-symvers=gnu --enable-libstdcxx-pch --program-prefix=arm-none-linux-gnueabi- --without-local-prefix --enable-lto --enable-libssp --disable-bootstrap --disable-libgomp --disable-libmudflap --with-system-zlib --with-linker-hash-style=gnu --with-ppl=no --with-cloog=no --enable-cheaders=c_global --enable-languages=c,c++,fortran --disable-libunwind-exceptions --with-mpfr=..sysroots/i686-linux/usr --with-system-zlib --enable-__cxa_atexit 
Thread model: posix 
gcc version 4.6.4 20120303 (prerelease) (GCC) 

和Linaro的GCC -v

# arm-linux-gnueabihf-g++ -v 
Using built-in specs. 
COLLECT_GCC=..compiler/bin/arm-linux-gnueabihf-g++ 
COLLECT_LTO_WRAPPER=../libexec/gcc/arm-linux-gnueabihf/4.7.2/lto-wrapper 
Target: arm-linux-gnueabihf 
Configured with: .build/src/gcc-linaro-4.7-2012.08/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --enable-languages=c,c++,fortran --enable-multilib --with-arch=armv7-a --with-tune=cortex-a9 --with-fpu=vfpv3-d16 --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-2012.08-20120827 - Linaro GCC 2012.08' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=.. --with-mpfr=.. --with-mpc=.. --with-ppl=.. --with-cloog=.. --with-libelf=.. --with-host-libstdcxx='-L.. -lpwl' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-gold --with-local-prefix=.. --enable-c99 --enable-long-long --with-mode=thumb 
Thread model: posix 
gcc version 4.7.2 20120731 (prerelease) (crosstool-NG linaro-1.13.1-2012.08-20120827 - Linaro GCC 2012.08) 

對於後者我也做了調整,讓--disable-multilib --disable-libmudflap --disable-libgomp --disable-multilib。

而這裏的Ubuntu 12.04的ARM編譯器:

> arm-linux-gnueabihf-g++-4.6 -v 
Using built-in specs. 
COLLECT_GCC=arm-linux-gnueabihf-g++-4.6 
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper 
Target: arm-linux-gnueabihf 
Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro 4.6.3-1ubuntu5' --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-4.6 --enable-shared --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/arm-linux-gnueabihf/include/c++/4.6.3 --libdir=/usr/lib --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --enable-multilib --disable-sjlj-exceptions --with-arch=armv7-a --with-float=hard --with-fpu=vfpv3-d16 --with-mode=thumb --disable-werror --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-linux-gnueabihf 
+0

Linaro的GCC使用cloog及PPL所以提供了石墨的循環優化。 –

+0

@BasileStarynkevitch:我在'-fno-graphite-identity -fno-graphite'的編譯過程中嘗試禁用它,但它在編譯時間上完全沒有區別。 – Frankie

回答

1

你可以通過-time-ftime-reportgcc編譯器來找出原因並在gcc正在編譯時間。

但是爲什麼編譯時間對您來說很重要?

您應該注意生成的可執行二進制文件的執行時間。

此外,我們展示傳遞給你的gcc

-v選項的輸出,你可能通過-j選項,您make命令把它並行工作(如並行運行幾個gcc)。您還可以降低優化級別,例如從-O3-O2-O1

+0

很棒的建議。實際上,它可能是唯一的方法來確定差異可能來自 – paulsm4

+0

我關心編譯時間,因爲這是一個非盈利項目(大學生),而我的機器上是8分鐘18分鐘。有些學生已經在舊機器上運行了1小時的編譯速度,如果我的下一次系統升級改爲2:20小時,他們不會很高興:-) – Frankie

+0

我已經做了'make -j'。我在我的問題中添加了gcc -v輸出。 '-ftime-report'選項會導致內部編譯器錯誤,'-time'會給我''cc1plus 2.36 0.15 \ n爲0.00 0.00',而新的''cc1plus 5.00 0.12 \ n爲0.02 0.00 '。 – Frankie

0

行 - 你 - 時間 - 報告測試清楚地顯示「解析器」是罪魁禍首;我猜測模板(通常)和STL(特別是)是根本原因。

建議:

看看有沒有什麼辦法可以在你的工具鏈使用「預編譯頭」。如果可以,那可能會消除整個問題。

LINKS(不幸的是,我不肯定可能會或可能不會適用於你):

+0

我的項目已經使用預編譯頭文件運行。關閉或打開它們在比較編譯速度上沒有顯着差異。請記住,我的問題是關於Linaro的gcc版本只有更通用的gcc交叉編譯器的一半。 – Frankie

+0

並記住,你的分析表明「解析器」。對我而言,這意味着「模板」,「標題中的模板」......以及「STL標題中的STL模板」。問:你確定你的.pch包含你正在使用的系統頭文件(包括STL)嗎?問:你確定編譯器被配置爲使用pch嗎?請記住:「變慢的Linaro」似乎是一個不幸的事實。 *真實*問題是「我們如何加快速度?」恕我直言... – paulsm4

+0

我使用兩個編譯器完全相同的Makefile(只是換出編譯器名稱)。如果我以任何通用的方式加快Linaro的gcc,這也會加速其他gcc的速度,我的問題仍然是開放的 - Linaro的gcc版本(在解析顯然)做的是什麼,其他gcc沒有? – Frankie