JDK-8220086 : GCC #pragma not allowed inside functions
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 10.0.2
  • Priority: P5
  • Status: Closed
  • Resolution: Won't Fix
  • OS: linux_redhat_6.2
  • CPU: x86_64
  • Submitted: 2019-03-04
  • Updated: 2019-03-04
  • Resolved: 2019-03-04
Related Reports
Relates :  
Description
When trying to build JDK 10 with gcc 4.4.7 (e.g. RHEL 6) then the build fails with:

In file included from /home/jdk9/jdk10u/src/hotspot/share/runtime/os.inline.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/thread.inline.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/handles.inline.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/reflectionUtils.hpp:32,
                 from /home/jdk9/jdk10u/src/hotspot/share/classfile/systemDictionary.hpp:34,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciEnv.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciUtilities.hpp:28,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciNullObject.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciConstant.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciArray.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/precompiled/precompiled.hpp:35:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp: In static member function ���static dirent* os::readdir(DIR*, dirent*)���:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:104: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:120: error: #pragma GCC diagnostic not allowed inside functions
In file included from /home/jdk9/jdk10u/src/hotspot/share/runtime/os.inline.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/thread.inline.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/handles.inline.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/runtime/reflectionUtils.hpp:32,
                 from /home/jdk9/jdk10u/src/hotspot/share/classfile/systemDictionary.hpp:34,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciEnv.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciUtilities.hpp:28,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciNullObject.hpp:30,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciConstant.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/ci/ciArray.hpp:29,
                 from /home/jdk9/jdk10u/src/hotspot/share/precompiled/precompiled.hpp:35:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp: In static member function ���static dirent* os::readdir(DIR*, dirent*)���:
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:103: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:104: error: #pragma GCC diagnostic not allowed inside functions
/home/jdk9/jdk10u/src/hotspot/os/linux/os_linux.inline.hpp:120: error: #pragma GCC diagnostic not allowed inside functions
gmake[3]: *** [/home/jdk9/jdk10u/build/release/hotspot/variant-server/libjvm/gtest/objs/precompiled/precompiled.hpp.gch] Error 1

Moving the pragma outside the function lets the build proceed.
Comments
JDK 10 is no longer maintained and gcc 4.4.7 is a rather old GCC. Closing as won't fix, but attaching a patch with the work-around.
04-03-2019