RFR: 8348286: [AIX] clang 17 introduces new warning Wtentative-Definitions which produces Build errors

Magnus Ihse Bursie ihse at openjdk.org
Thu Jan 23 00:24:46 UTC 2025


On Wed, 22 Jan 2025 15:34:36 GMT, Joachim Kern <jkern at openjdk.org> wrote:

> We (SAP) try to introduce the ‘IBM Open XL C/C++ for AIX 17.1.2’ (based on clang 17) as a feasible compiler for jdk25, because in combination with the 17.1.3 runtime this would enable the support for ubsan.
> Unfortunately, the new compiler comes along with a new set of compiler warnings turned into errors by -Werror.
> One of the warnings is -Wtentative-definitions. It is fired when a variable definition in a header is found:
> /jdk/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h:36:20: error: possible missing 'extern' on global variable definition in header [-Werror,-Wtentative-definitions]
>    36 | IMGEXTERN jfieldID g_BImgRasterID;
>       | ^
> From now on headers allow only extern declarations of variables. The definition must take place in a c/cpp file. This means e.g.
> imageInitIDs.h:36:20
>    36 extern jfieldID g_BImgRasterID;
> and the corresponding c-File
>    jfieldID g_BImgRasterID;
> 
> The other possible solution would be to compile everything with
> -Wno-tentative-definitions
> which could be set in flags-cflags.m4, if compiling with clang 17.

Try this instead:

diff --git a/make/autoconf/flags-cflags.m4 b/make/autoconf/flags-cflags.m4
index 729e508cc26..04831c07d97 100644
--- a/make/autoconf/flags-cflags.m4
+++ b/make/autoconf/flags-cflags.m4
@@ -263,7 +263,7 @@ AC_DEFUN([FLAGS_SETUP_WARNINGS],
 
       # These warnings will never be turned on, since they generate too many
       # false positives.
-      DISABLED_WARNINGS="unknown-warning-option unused-parameter"
+      DISABLED_WARNINGS="unknown-warning-option unused-parameter tentative-definitions"
       ;;
   esac
   AC_SUBST(DISABLE_WARNING_PREFIX)

-------------

PR Comment: https://git.openjdk.org/jdk/pull/23236#issuecomment-2608561423


More information about the build-dev mailing list