CC: Warning: -O5 overwrites previously set optimization level of -O3

I'm trying to get a clean compile of the Boost 1.32.0 library using the Studio Express August build, and in the course of that (this post is not about Boost), I get the following:

sunpro-C++-action bin/boost/libs/filesystem/build/libboost_filesystem.a/sunpro/release/exception. o

/opt/SPROexpress/opt/SUNWspro//bin//CC -O -xlang=c99 -mt \

-library=stlport4 -features=tmplife -features=tmplrefstatic -errtags=yes \

-D_POSIX_THREAD_SEMANTICS -c -DNDEBUG -DNDEBUG -fast -O4 -xtarget=generic \

-library=stlport4 -features=tmplife -features=tmplrefstatic -erroff=wbadinitl,wbadasgl \

-Qoption ccfe -complextmplexp \

-I"bin/boost/libs/filesystem/build" -I"/thirdparty/lib/boost_1_32_0" -I"/thirdparty/lib/boost_1_32_0" \

-o "bin/boost/libs/filesystem/build/libboost_filesystem.a/sunpro/release/exception .o" \

"/thirdparty/lib/boost_1_32_0/libs/filesystem/build/../src/exception.cpp"

CC: Warning: -O5 overwrites previously set optimization level of -O3

Maybe I'm doing something wrong in the way that both -O and -O4 get specified on the command line, but why is the error message specifying -O5 and -O3, neither of which I specified?

[1204 byte] By [herteg] at [2007-11-26 10:10:40]
# 1

I see what's going on here. -O expands to -O3. That is overridden by the -O5 which is included in the expansion of -fast.

Four things about this:

(1) The warning message should say "overrides", not "overwrites".

(2) There is no corresponding warning when the -O5 is overridden by the following -O4. Or is it?

(3) The effect of multiple -Olevel options is unspecified; that should be corrected in the manual.

(4) The Sun Studio 11 C++ User's Guide is inconsistent on the meaning of the -O option:

A.2.61 -O

The -O macro now expands to -xO3 instead of -xO2.

A.2.145 -xOlevel

On the SPARC Platform:

The -O option is equivalent to the -xO2 option.

herteg at 2007-7-7 1:55:54 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 2
You can file a bug against C++ compiler (not sure if web interface allows to specify that the bug is in the docs) through http://bugs.sun.com/services/bugreport/submit_intro.doThe one who is assigned to this bug would be able to re-categorize it to docs issue.
MaximKartashev at 2007-7-7 1:55:54 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 3

Herteg,

> I see what's going on here. -O expands to -O3. That

> is overridden by the -O5 which is included in the

> expansion of -fast.

This is correct.

> Four things about this:

>

> (1) The warning message should say "overrides", not

> "overwrites".

I think that there should be no warning at all. We have "rightmost wins" rule for the compiler flags, and both -O and -fast are documented well enough to understand which -O<n> (or -xO<n>) they will be translated into.

The problem is that I don't see this "rightmost wins" in the documentation for -O<n>/-xO<n>.

> (2) There is no corresponding warning when the -O5 is

> overridden by the following -O4. Or is it?

I believe there shouldn't be one in the first place.

> (3) The effect of multiple -Olevel options is

> unspecified; that should be corrected in the manual.

Well, it is specified, it's just not documented :-)

> (4) The Sun Studio 11 C++ User's Guide is

> inconsistent on the meaning of the -O option:

>

> A.2.61 -O

> The -O macro now expands to -xO3 instead of -xO2.

>

> A.2.145 -xOlevel

> On the SPARC Platform:

> The -O option is equivalent to the -xO2 option.

The second one is wrong. But I suppose you already know this.

Thank you very much for bringing this to our attention! Would you please file a bug through the web interface: http://bugs.sun.com/services/bugreport/index.jsp ?

Thanks,

Boris

Boris_Ivanovsky at 2007-7-7 1:55:54 > top of Java-index,Development Tools,Solaris and Linux Development Tools...
# 4

>> (1) The warning message should say "overrides", not "overwrites".

> I think that there should be no warning at all. We have "rightmost wins" rule for the compiler flags, and both -O and -fast are documented well enough to understand which -O<n> (or -xO<n>) they will be translated into.

Actually, I agree on wanting no warning, unless it were off by default and there were some kind of "tell me all the things I normally want suppressed" flag. I just didn't dare hope.

> The problem is that I don't see this "rightmost wins" in the documentation for -O<n>/-xO<n>.

You're right. I encountered the same problem with -erroff=... . Definitely this kind of blanket rule belongs in the docs.

herteg at 2007-7-7 1:55:54 > top of Java-index,Development Tools,Solaris and Linux Development Tools...