Dr Andrew John Hughes said the following on 05/19/11 05:29:
On 08:35 Mon 16 May , Kelly O'Hair wrote:
<snip>
The -Werror option is a blessing and a curse. I find it highly commendable that teams (like
hotspot) have taken a 'no warnings allowed' approach to their code base, more teams should do this.
Given the critical nature of a VM in the JDK, it only makes sense to take all
precautions in verifying the code is correct.
I find it quite interesting that the one situation where -Werror is used is
where it's likely to hit
the most difficulties. The HotSpot code is compiled by three different
compilers (gcc and whatever
is used on Solaris and Windows) and the version of these used can vary
considerably, as the system C++ compiler
is unrelated to the JDK.
Hotspot only uses -Werror with gcc. And its use predates the sudden
plethora of compiler versions now used to build OpenJDK. In prior times
the build compiler for a given release was set in stone so we knew what
warnings (and bugs!) to expect. I believe we also disable problematic
warnings when necessary. By using -Werror when we did update compiler
versions we quickly discovered where the compiler was tightening the
rules and issuing new warnings - then we could determine whether to fix
the code (if practical) or disable the warning.
In contrast, there are basically two Java compilers in general use (javac and
ecj)
and one is part of OpenJDK. Yet, the Java code does not have -Werror enabled
by default and there
are a mass of warnings there as a result.
I don't understand the point you are making here. Does javac even have a
-Werror? The bulk of javac warnings stem from legacy code being compiled
under newer compilers with new language features - the resulting code is
not erroneous hence only a warning is issued.
I think comparing C/C++ compiler warnings with javac compiler warnings
is like comparing apples and elephants.
David
-----
But it only makes 100% sense when using the same compiler, same compiler
version, and on the same system.
Which is extremely rare with HotSpot and the C++ compiler, but the first two
are very likely for the Java
code as the build uses its own javac in most cases.
For hotspot, you should be able to get rid of -Werror by setting
WARNINGS_ARE_ERRORS to empty.
Thanks for this, I wasn't aware of it. Are these flags documented somewhere?
I keep seeming to find
out about new ones randomly in e-mails.
I've wondered if we need to put a little more smarts in determining what situations
(compiler&os) warrant
adding the -Werror, but at the same time if it is a valid warning, maybe the
behavior we have is right.
So my attitude up to this time has been that new ports should use
WARNINGS_ARE_ERRORS=
to start, but eventually they should fix these warnings before a port is
finished.
(And I use the term 'port' very loosely here, a new version of gcc is a port to
me).
I'd go for using the version checking that's already in the build system, and
only turning on Werror if
gcc/g++ matches the version that's been tested against. Even then, there may
be platform-dependent differences.
snip...
-kto