JDK-8288101 : False build warning-as-error with GCC 9 after JDK-8214976
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 19
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux
  • Submitted: 2022-06-09
  • Updated: 2022-06-14
  • Resolved: 2022-06-10
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 19 JDK 20
19 masterFixed 20Fixed
Related Reports
Relates :  
Description
gcc version 9.4.0 (also 9.3.1) produces build warning after JDK-8214976:

os_posix.cpp:786:34: error: call to 'exit' declared with attribute warning: use os::exit [-Werror=attribute-warning]
  786 |   ALLOW_C_FUNCTION(::exit, ::exit(num);)
      |                            ~~~~~~^~~~~

Workaround: Use configure flag --disable-warnings-as-errors

Comments
Changeset: d9c1364d Author: Aleksey Shipilev <shade@openjdk.org> Date: 2022-06-10 17:07:20 +0000 URL: https://git.openjdk.org/jdk19/commit/d9c1364ddecde7e56e165b86e55dc23bda4ff921
10-06-2022

Kim, I'm not sure if it's worth creating a new issue in my case, since I'm compiling for Windows. Seems like Visual C++ and gcc somehow share the same issue with conflicting C/C++ linkage when Windows is the target OS. Might be a CRT thing, least that's what it sounds like to me
10-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk19/pull/1 Date: 2022-06-09 16:35:54 +0000
09-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9109 Date: 2022-06-09 16:07:34 +0000
09-06-2022

Alright, I'll delete my branch in that case
09-06-2022

Julian, the key is to submit it against JDK 19, as the repo just forked for RDP1. Please let me do this.
09-06-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9108 Date: 2022-06-09 15:36:56 +0000
09-06-2022

[~jwaters] Please let me know what the bug is for your issue. (Linking to JDK-8214976 will do.) That sounds like something I was seeing on Windows that led to abandoning the attempt to support this feature there.
09-06-2022

[~shade] I've already submitted a PR for this - It does seem to be taking some time for Skara to properly process it though, so it may take a while
09-06-2022

[~shade] Yes, bumping the test to 10 is fine. I used 9 based on documentation - I don't have easy access for testing. From the discussion above it sounds though like the issue is a bug in _Pragma handling? Sigh.
09-06-2022

Kim, would you agree bumping the check to GCC >= 10 is a sensible workaround here? I played with Godbolt (https://godbolt.org/z/Ybr9fb63e), and I believe this is just a GCC 9 compiler bug with nesting pragmas and macros :/ If so, I'll submit my PR against JDK 19, once it forks.
09-06-2022

Alright, got it!
09-06-2022

I just did the full build ("make clean images") on GCC 10.2.1, and it passed fine for both Linux x86_64 fastdebug and release. Your issue seems to be a different one, please open a separate bug, so we don't confuse the two? You might need to provide full details on the build environment there.
09-06-2022

Did try to do that, but it doesn't seem to work :/ Does it properly build with 11 on your end? If so this might be something on my end causing this; After all the underlying errors seem to be slightly different (On my end it's FORBID_C_FUNCTION that's causing the fuss). I'll create a PR for this in the meantime if changing it from 9 to 10 is the best solution
09-06-2022

Julian, please try to "rm -rf build/", and do clean reconfigure/build.
09-06-2022

Experimenting with godbolt: https://godbolt.org/z/Ybr9fb63e: - GCC 9 fails with the warning above, in all minor releases; - GCC 10 and up successfully disable the warning;
09-06-2022

It still fails for me on gcc 11.2 though- I can't tell if this is also an issue for 11 and above
09-06-2022

Nuclear option is to only enable these macros on GCC >= 10: diff --git a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp index 1636ad48fba..782865d9461 100644 --- a/src/hotspot/share/utilities/compilerWarnings_gcc.hpp +++ b/src/hotspot/share/utilities/compilerWarnings_gcc.hpp @@ -69,7 +69,7 @@ #endif // clang/gcc version check -#if (__GNUC__ >= 9) || (defined(__clang_major__) && (__clang_major__ >= 14)) +#if (__GNUC__ >= 10) || (defined(__clang_major__) && (__clang_major__ >= 14)) // Use "warning" attribute to detect uses of "forbidden" functions. //
09-06-2022

Fails for me with GCC 9.4.0. Passes with GCC 10.2.1. Looks like a GCC 9 specific thing?
09-06-2022

Interestingly this seems to differ slightly from the issue I'm currently facing; This errors due to a warning attribute, while mine fails mid build due to "conflicting declaration of <name here> with 'C' linkage" with a note of "previous declaration with 'C++' linkage" appended afterwards. I can't really figure out what's going on here unfortunately :(
09-06-2022