JDK-8290900 : Build failure with Clang 14+ due to function warning attribute
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 19
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-07-22
  • Updated: 2022-10-07
  • Resolved: 2022-07-23
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.0.2Fixed 20 b08Fixed
Related Reports
Relates :  
Relates :  
Description
After JDK-8214976, OpenJDK cannot build with Clang 14 or newer. This is because Clang 14+ currently does not support merging warning attributes of functions. Build failure looks like:
```
jdkGitHead/src/hotspot/share/utilities/globalDefinitions.hpp:165:1: error: 'warning' attribute does not appear on the first declaration
FORBID_C_FUNCTION(void exit(int), "use os::exit");
^                                                                                                                                                                            
jdkGitHead/src/hotspot/share/utilities/compilerWarnings_gcc.hpp:85:29: note: expanded from macro 'FORBID_C_FUNCTION'
  extern "C" __attribute__((__warning__(alternative))) signature;
                            ^                                                         
/usr/include/stdlib.h:617:13: note: previous declaration is here                                                                                                             
extern void exit (int __status) __THROW __attribute__ ((__noreturn__));
```

https://github.com/llvm/llvm-project/issues/56519 has been opened and will be fixed in a future Clang release. I propose we temporarily disable the warning attribute when building with Clang, until the LLVM issue #56519 is fixed and released.
Comments
A pull request was submitted for review. URL: https://git.openjdk.org/jdk19u/pull/44 Date: 2022-10-05 00:08:07 +0000
05-10-2022

Fix Request [19u] This bug prevents building JDK 19 with Clang 14. Backport applies to 19u cleanly.
05-10-2022

Changeset: 0599a05f Author: Man Cao <manc@openjdk.org> Date: 2022-07-23 02:54:07 +0000 URL: https://git.openjdk.org/jdk/commit/0599a05f8c7e26d4acae0b2cc805a65bdd6c6f67
23-07-2022

A pull request was submitted for review. URL: https://git.openjdk.org/jdk/pull/9621 Date: 2022-07-22 23:40:08 +0000
22-07-2022