eclipse / omr

Eclipse OMR™ Cross platform components for building reliable, high performance language runtimes
http://www.eclipse.org/omr
Other
940 stars 394 forks source link

Debug builds are broken with -Werror in GCC 11 due to -Wnonnull changes #7402

Open cjjdespres opened 1 month ago

cjjdespres commented 1 month ago

I tried producing a debug build of JDK21 with openj9 using the Ubuntu 22 docker image from mkdocker.sh, with the additional flags

export cflags="-Og -ggdb3 -fno-inline -DDEBUG"
export EXTRA_CMAKE_ARGS="-DJ9JIT_EXTRA_CFLAGS=\"$cflags\" -DJ9JIT_EXTRA_CXXFLAGS=\"$cflags\""

as I normally do (in the Ubuntu 20 image, at least) and I got compilation errors in omr:

[ 34%] Building CXX object runtime/compiler/CMakeFiles/j9jit.dir/root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/InterferenceGraph.cpp.o
/root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/InterferenceGraph.cpp: In member function 'virtual bool TR_InterferenceGraph::simplify()':
/root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/InterferenceGraph.cpp:423:51: error: 'this' pointer is null [-Werror=nonnull]
  423 |          workingSet->reset(bestSpillNode->getIndex());
      |                            ~~~~~~~~~~~~~~~~~~~~~~~^~
In file included from /root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/IGBase.hpp:28,
                 from /root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/InterferenceGraph.hpp:34,
                 from /root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/InterferenceGraph.cpp:22:
/root/hostdir/foo/openj9-openjdk-jdk21/omr/compiler/infra/IGNode.hpp:89:16: note: in a call to non-static member function 'IGNodeIndex TR_IGNode::getIndex()'
   89 |    IGNodeIndex getIndex()       {return _index;}
      |                ^~~~~~~~
cc1plus: all warnings being treated as errors

I'm fairly sure this is due to the use of GCC 11 in the image. From the changelog:

  • Enhancements to existing warnings:
    • -Wnonnull considers the implicit this argument of every C++ nonstatic member function to have been implicitly declared with attribute nonnull and triggers warnings for calls where the pointer is null.

There are only a few places where the warning arises. I can put up a PR to resolve them.

cjjdespres commented 1 month ago

This only shows up in omr because most (all?) of the openj9 code has OMR_ENHANCED_WARNINGS turned off.