我正在尝试确定GCC(4.7.3,Mac OS X 10.6.8上的Macports安装)启用了哪些编译器选项。我知道以下方法:
Using the -Q option with a simple input file as suggested by GCC 4.3.3 compiler options enabled:
gcc -Q -v -o hello hello.c
Using the -Q --help=x combination (for values of x, see GCC documentation) e.g:
gcc -Q --help=target
To see enabled defines:
echo "" | gcc -E -dM - | sort
然而,当我使用相同的优化选项运行方法1和方法2时,我获得了两个不同的启用/禁用选项集。
$ gcc -Q -v -O3 -march=native -o hello hello.c
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
options passed: -v -D__DYNAMIC__ hello.c -march=corei7-avx -mcx16 -msahf
-mno-movbe -maes -mpclmul -mpopcnt -mno-abm -mno-lwp -mno-fma -mno-fma4
-mno-xop -mno-bmi -mno-bmi2 -mno-tbm -mavx -mno-avx2 -msse4.2 -msse4.1
-mno-lzcnt -mno-rdrnd -mno-f16c -mno-fsgsbase --param l1-cache-size=32
--param l1-cache-line-size=64 --param l2-cache-size=6144 -mtune=corei7-avx
-fPIC -mmacosx-version-min=10.6.8 -O3
options enabled: -Wnonportable-cfstrings -fPIC -falign-labels
-fasynchronous-unwind-tables -fauto-inc-dec -fbranch-count-reg
-fcaller-saves -fcombine-stack-adjustments -fcommon -fcompare-elim
-fcprop-registers -fcrossjumping -fcse-follow-jumps -fdebug-types-section
-fdefer-pop -fdelete-null-pointer-checks -fdevirtualize -fearly-inlining
...
相反,
$ gcc -Q -O3 -march=native --help=optimizers
-falign-functions [enabled]
-falign-jumps [enabled]
-falign-labels [enabled]
-falign-loops [enabled]
-fasynchronous-unwind-tables [enabled]
-fbranch-count-reg [enabled]
-fbranch-probabilities [disabled]
-fbranch-target-load-optimize [disabled]
-fbranch-target-load-optimize2 [disabled]
-fbtr-bb-exclusive [disabled]
-fcaller-saves [enabled]
-fcombine-stack-adjustments [enabled]
-fcommon [enabled]
-fcompare-elim [enabled]
-fconserve-stack [disabled]
-fcprop-registers [enabled]
-fcrossjumping [enabled]
-fcse-follow-jumps [enabled]
-fcx-fortran-rules [disabled]
-fcx-limited-range [disabled]
-fdata-sections [disabled]
-fdce [enabled]
-fdefer-pop [enabled]
-fdelayed-branch [disabled]
-fdelete-null-pointer-checks [enabled]
-fdevirtualize [enabled]
-fdse [enabled]
-fearly-inlining [enabled]
...
查看选项-falign-functions、-falign-jumps、-falign-labels和-falign-loops,方法2声称它们都已启用,而方法1仅声称启用了-falign-labels。此外,选项-fdce和-fdse根据方法2已启用,但根据方法1未启用。
问题:我应该信任哪种方法?
附注:方法2的选项列表不完整,因为选项被分组,并且只有使用--help=选项请求的组别才会列出。要查看方法2中所有选项,请运行:
$ gcc -Q -O3 -march=native --help=optimizers --help=target --help=c
--help=common --help=warnings | sort