我正在处理一个使用LLVM 2.6和llvm-gcc前端进行编译的项目。我正在尝试使用LLVM 3.1和clang进行编译测试。当我这样做时,关于-O5优化级别,我收到了以下错误消息:
error: invalid value '5' in '-O5'
然而,在-O5
标志下,LLVM 2.6和llvm-gcc运行良好。我看到了关于Clang优化级别的以下文档:
-O0 -O1 -O2 -Os -O3 -O4
Specify which optimization level to use. -O0 means "no optimization": this level compiles the
fastest and generates the most debuggable code. -O2 is a moderate level of optimization which
enables most optimizations. -Os is like -O2 with extra optimizations to reduce code size. -O3
is like -O2, except that it enables optimizations that take longer to perform or that may
generate larger code (in an attempt to make the program run faster). On supported platforms, -O4
enables link-time optimization; object files are stored in the LLVM bitcode file format and whole
program optimization is done at link time. -O1 is somewhere between -O0 and -O2.
所以我正在尝试弄清楚我正在使用的Makefile中的-O5
是在做什么(我没有编写这个Makefile)。这是一些已经改变并曾经与LLVM一起使用的东西吗?还是它仍然是一个有用的功能,只是我需要以其他方式激活它。
此外,如果有用的话,我运行的命令基本上是:
/bin/clang -g -c -mcmodel=medium -fstrict-aliasing -Wstrict-aliasing -O5 -emit-llvm -fkeep-inline-functions -fno-stack-protector -c -o foo.bc foo.cpp
如果有必要的话,我还在运行 Linux (Ubuntu 10.04) x86_64 系统。
-O3
。例如,clang++ -O5 test.cc -o test
会显示warning: optimization level '-O5' is not supported; using '-O3' instead
。 - jdhao