Answers:
我无法回答有关-mfpu
flag的问题,但建议您先尝试以下操作:
-march=native
-mcpu=native
-mtune=native
据报道GCC manual page related to ARM options
:
-march = native使编译器自动检测构建计算机的体系结构。目前,此功能仅在Linux上受支持,并且并非所有体系结构都可以识别。如果自动检测失败,则该选项无效。
-mcpu = native使编译器自动检测构建计算机的CPU。目前,此功能仅在Linux上受支持,并且并非所有体系结构都可以识别。如果自动检测失败,则该选项无效。
-mtune = native使编译器自动检测构建计算机的CPU。目前,此功能仅在Linux上受支持,并且并非所有体系结构都可以识别。如果自动检测失败,则该选项无效。
然后,您可以添加-Q -v
到自己的视图中,GCC flags
以查看启用了哪些优化,并在必要时进行进一步的优化。
这是-march=native
我的Raspberry Pi上的示例程序使用的输出:
#> gcc -march=native -Q -v test.c -o test
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-linux-gnueabihf/4.6/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Debian 4.6.3-8+rpi1' --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs --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/include/c++/4.6 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --enable-plugin --enable-objc-gc --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 4.6.3 (Debian 4.6.3-8+rpi1)
COLLECT_GCC_OPTIONS='-march=native' '-Q' '-v' '-o' 'test' '-mfloat-abi=hard' '-mfpu=vfp'
/usr/lib/gcc/arm-linux-gnueabihf/4.6/cc1 -v -imultilib . -imultiarch arm-linux-gnueabihf test.c -dumpbase test.c -march=native -mfloat-abi=hard -mfpu=vfp -auxbase test -version -o /tmp/cc1rCJ4W.s
cc1: error: bad value (native) for -march switch
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=38 --param ggc-min-heapsize=15522
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/4.6/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/arm-linux-gnueabihf/4.6/include
/usr/local/include
/usr/lib/gcc/arm-linux-gnueabihf/4.6/include-fixed
/usr/include/arm-linux-gnueabihf
/usr/include
End of search list.
GNU C (Debian 4.6.3-8+rpi1) version 4.6.3 (arm-linux-gnueabihf)
compiled by GNU C version 4.6.3, GMP version 5.0.5, MPFR version 3.1.0-p10, MPC version 0.9
GGC heuristics: --param ggc-min-expand=38 --param ggc-min-heapsize=15522
options passed: -v -imultilib . -imultiarch arm-linux-gnueabihf test.c
-march=native -mfloat-abi=hard -mfpu=vfp
options enabled: -fauto-inc-dec -fbranch-count-reg -fcommon
-fdelete-null-pointer-checks -fdwarf2-cfi-asm -fearly-inlining
-feliminate-unused-debug-types -ffunction-cse -fgcse-lm -fident
-finline-functions-called-once -fira-share-save-slots
-fira-share-spill-slots -fivopts -fkeep-static-consts -fleading-underscore
-fmath-errno -fmerge-debug-strings -fmove-loop-invariants -fpeephole
-fprefetch-loop-arrays -freg-struct-return -fsched-critical-path-heuristic
-fsched-dep-count-heuristic -fsched-group-heuristic -fsched-interblock
-fsched-last-insn-heuristic -fsched-rank-heuristic -fsched-spec
-fsched-spec-insn-heuristic -fsched-stalled-insns-dep -fshow-column
-fsigned-zeros -fsplit-ivs-in-unroller -fstrict-volatile-bitfields
-ftrapping-math -ftree-cselim -ftree-forwprop -ftree-loop-if-convert
-ftree-loop-im -ftree-loop-ivcanon -ftree-loop-optimize
-ftree-parallelize-loops= -ftree-phiprop -ftree-pta -ftree-reassoc
-ftree-scev-cprop -ftree-slp-vectorize -ftree-vect-loop-version
-funit-at-a-time -fvar-tracking -fvar-tracking-assignments
-fzero-initialized-in-bss -mglibc -mlittle-endian -msched-prolog
Execution times (seconds)
TOTAL : 0.00 0.00 0.00 8 kB
-march=native
已针对实施ARM GCC
。Raspberry Pi可能是不受支持(因此未被检测)的体系结构,在这种情况下-march=native
无效。
$ gcc -march=native test.c
cc1: error: bad value (native) for -march switch
,它在您的输出中说的也一样。(也与-mcpu相同)
gcc -mcpu=native -march=native -Q --help=target
为我提供了*** Error in
gcc':double free或rupture(顶部):0x0020c5a8 ***`。