gcc 无法识别的命令行选项“-V”和“-qversion”与 autoconf

syr*_*inx 22 linux gcc autoconf

使用 gcc 4.7.2 和 autoconf 2.69 进行编译时,我经常会在 configure.log 中得到诸如此类的结果。例子:

configure:3091: $? = 0 
configure:3080: gcc -V >&5 
gcc: error: unrecognized command line option '-V' 
gcc: fatal error: no input files compilation terminated. 
configure:3091: $? = 1 
configure:3080: gcc -qversion >&5 
gcc: error: unrecognized command line option '-qversion' 
gcc: fatal error: no input files compilation terminated. 
configure:3091: $? = 1 
configure:3111: checking whether the C compiler works 
configure:3133: gcc -march=x86-64 -mtune=generic -Os -pipe -Wl,-O1 conftest.c >&5
configure:3137: $? = 0 
configure:3185: result: yes
Run Code Online (Sandbox Code Playgroud)

编译成功进行,但我想知道为什么 autoconf 正在测试 gcc 不支持的命令行。这适用于其他编译器吗?

小智 12

引用这个:

gcc -V 是一种在您有多个 gcc 版本时选择特定 gcc 版本的方法,尽管这是一个诱饵:configure 正在迭代一组选项(--version -v -V 等)以确保它可以记录C 编译器的版本,无论是 gcc 还是其他。

引用这个:

gcc 曾经有一个 -V 选项用于版本报告。它现在使用 -v,并提供编译器构建时使用的配置选项。

您的包裹有点过时,并没有反映这一事实。

顺便说一句, -qversion 选项已合并到 -v ...

引用这个:

在某些版本的 gcc 上,-V 选项告诉它使用指定版本的编译器——但它需要一个参数。它记录在这里。该选项似乎已在 4.5.4 和 4.6.4 之间的某个时间删除。

其中引用了这个: