-
Notifications
You must be signed in to change notification settings - Fork 721
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable OMR_WARNINGS_AS_ERRORS in the JIT on Power for non-xlC builds #18614
Conversation
runtime/compiler/CMakeLists.txt
Outdated
@@ -328,7 +328,7 @@ omr_stringify(J9_CXXFLAGS_STR ${J9_SHAREDFLAGS} ${J9_CXXFLAGS}) | |||
set(CMAKE_CXX_FLAGS "${J9_CXXFLAGS_STR}") | |||
set(CMAKE_C_FLAGS "${J9_CFLAGS_STR}") | |||
|
|||
if(OMR_ARCH_X86 OR OMR_ARCH_S390 OR OMR_ARCH_AARCH64) | |||
if(OMR_ARCH_X86 OR OMR_ARCH_S390 OR OMR_ARCH_AARCH64 OR (OMR_ARCH_POWER AND (__clang__ OR __GNUC__ OR __GNUG__))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest this should use OMR_TOOLCONFIG
instead of __clang__
, __GNUC__
, or __GNUG__
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, perhaps OMR_ARCH_POWER AND NOT OMR_TOOLCONFIG STREQUAL "xlc"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, if we want to enable warnings for all compilers except xlc, that would be the way to say it.
How many warnings would we have to address to omit the tool-chain part of that expression (i.e. how close are we to fixing the warnings issued by xlc)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll let you know once I find out!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like we have 16 unique types of warnings issued by xlc:
- (W) "offsetof" cannot be applied to _. It is not a POD (plain old data) type.
- (W) The subscript _ is out of range. The valid range is _.
- (W) WARNING in _: Infinite loop. Program may not stop.
- (W) WARNING: subprogram _ could not be inlined into _.
- (W) Maximum number of common component diagnostics, _ has been exceeded.
- (W) Macro name _ has been redefined.
- (W) Cannot pass an argument of non-POD class type _ through ellipsis.
- (W) An expression of type _ cannot be converted to type _.
- (W) The characters "/*" are detected in a comment.
- (W) A return value of type _ is expected.
- (W) File is empty.
- (W) The source file is empty.
- (W) _ might be used before it is set.
- (W) Compilation unit is empty.
- (W) Function argument assignment between types _ and _ is not allowed.
- (W) Operation between types _ and _ is not allowed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of those should be easy to fix:
- the three flavours of "file/unit is empty" can be avoided by changing the cmake configuration to avoid compiling such files
- the "maximum diagnostics" should fix itself once we fix the others
/*
in a comment - trivial
The others should be treated as errors, to me they signal broken code (not just warnings).
Have you tested with gcc 13 (which is the default version on Ubuntu 24.04)? |
@keithc-ca I don't believe I did, but once I've cleaned up any warnings that appeared while I was gone I'll make sure to do that. |
@keithc-ca I can confirm that no warnings arise from the JIT when building JDK 11 on plinux Ubuntu 20.04 with gcc 13. I actually had to disable To be fair, the only warning that I know crashed the build for certain was the first one, because after that I configured with The warnings in question:
|
I saw (1) in my xlinux build with gcc 13; that one will require some more thought. Warnings (2) and (4) should be easy to address: simply remove the dead code. Warning (3) may just require moving the declaration to a larger scope so the target survives as long as the pointer. I tried to address warning (5) some time ago, but I remember having trouble telling the compiler to ignore the return value. That is code we inherit from https://github.com/libffi/libffi so any improvements should be shared there as well. Warning (6) should be straight-forward: add initialization visible to the compiler. Issue (7) is in openjdk code; I'm not sure jdk11 has been kept current with newer compliers. Even the head stream, the minimum gcc version is 10. |
@keithc-ca Do you know how it's possible for a change in the JIT's With a better understanding of why this CMake dependency between the JIT and other components exists, perhaps we could figure out how to fix it, or at least be better informed about when it's safe to change the JIT's |
The only thing that I can think of is that |
Understood. I'll start working on those warnings! |
I hadn't actually tested this at the time, but it turns out that even the warning from the openjdk code is treated as an error. Would that be a PR to https://github.com/ibmruntimes/openj9-openjdk-jdk11? If so, I suppose I should check all of our JDK versions... |
We have three independent configuration options:
jdk11 may not be ready for newer compilers, in which case we should just use the first option. OpenJ9 code and OMR code should not have warnings even without using the latter two options. |
I see, I'll just focus on the OpenJ9 and OMR warnings then. |
ef351a1
to
0d8a5ec
Compare
0d8a5ec
to
1a24e10
Compare
@keithc-ca @pshipton @zl-wang Now that the last warning has been disabled, could I get a review on this when one or more of you has a chance? |
@keithc-ca How would I run a build of IBM Java 8 on AIX? That is the last build we have that still uses the xlC frontend and I would like to confirm that this change doesn't break that build. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please squash.
Signed-off-by: Dylan Tuttle <[email protected]>
422674a
to
5fb4b0a
Compare
Done! |
Jenkins test sanity plinux jdk23 |
The test failure appears to be #17474. |
"Warnings as errors" is enabled on a component-by-component basis throughout OpenJ9 and OMR. For the JIT, warnings as errors is enabled on every platform in OMR and on x86, Z, and Aarch64 in OpenJ9.
This PR enables warnings as errors on Power in OpenJ9 by turning the OMR_WARNINGS_AS_ERRORS flag on if OMR_ARCH_POWER is true. This will ensure all builds on Power compile code with the -Werror flag, which will halt compilation if a warning is reported.