I am working on a project that I had been compiling with LLVM 2.6 and the llvm-gcc front end. I'm trying to test compiling it with LLVM 3.1 and clang. When I did this I got the following error message about -O5 optimization level:
error: invalid value '5' in '-O5'
However, LLVM 2.6 and llvm-gcc have worked fine with the -O5
flag. I saw the following documentation about the Clang optimization levels:
-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.
So I'm trying to figure out what the -O5
in the Makefile I'm working with was doing in the first place (I didn't write the Makefile). Is this something that changed and used to be used with LLVM? Or is it still a useful feature and I just need to activate it in some other way.
Also in case it's useful the command I'm running that is giving the error is basically:
/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
Also in case it matters I am running on a Linux (Ubuntu 10.04) x86_64 system.
-O3
is used instead. For example,clang++ -O5 test.cc -o test
showswarning: optimization level '-O5' is not supported; using '-O3' instead
. – Semaphore