git: e406118f7741 - main - java/openjdk13 java/openjdk14 java/openjdk15 java/openjdk16 java/openjdk17 java/openjdk17-jre: fix build with clang 14

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Mon, 04 Apr 2022 08:09:52 UTC
The branch main has been updated by dim (src committer):

URL: https://cgit.FreeBSD.org/ports/commit/?id=e406118f774154589b91dc8d84f7f0320766d5a4

commit e406118f774154589b91dc8d84f7f0320766d5a4
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-03-26 19:47:44 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2022-04-04 07:56:40 +0000

    java/openjdk13 java/openjdk14 java/openjdk15 java/openjdk16 java/openjdk17 java/openjdk17-jre: fix build with clang 14
    
    During an exp-run for llvm 14 (see bug 261742), it turned out that
    java/openjdk13 and java/openjdk17 fail to build with clang 14 (but this
    also affects openjdk14 through 16):
    
    === Output from failing command(s) repeated here ===
    * For target hotspot_variant-server_libjvm_objs_serviceThread.o:
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
          while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
                 ~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: note: cast one or both operands to int to silence this warning
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
          while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: note: cast one or both operands to int to silence this warning
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
          while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: note: cast one or both operands to int to silence this warning
    /wrkdirs/usr/ports/java/openjdk13/work/jdk13u-jdk-13.0.10-5-1/src/hotspot/share/runtime/serviceThread.cpp:133:15: error: use of bitwise '|' with boolean operands [-Werror,-Wbitwise-instead-of-logical]
          while (((sensors_changed = LowMemoryDetector::has_pending_requests()) |
                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       ... (rest of output omitted)
    
    Although the warning is normally an indication of a potential problem,
    in this case a comment just before the affected code explictly mentions
    the reason for using bitwise '|' instead of logical '||':
    
          // Process all available work on each (outer) iteration, rather than
          // only the first recognized bit of work, to avoid frequently true early
          // tests from potentially starving later work.  Hence the use of
          // arithmetic-or to combine results; we don't want short-circuiting.
    
    (See
    <https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/serviceThread.cpp#L140>)
    
    Therefore, we should suppress -Wbitwise-instead-of-logical for clang 14
    and higher.
    
    PR:             262845
    Approved by:    portmgr (build fix blanket)
    MFH:            2022Q2
---
 java/openjdk13/Makefile | 7 ++++++-
 java/openjdk14/Makefile | 7 ++++++-
 java/openjdk15/Makefile | 7 ++++++-
 java/openjdk16/Makefile | 7 ++++++-
 java/openjdk17/Makefile | 7 ++++++-
 5 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/java/openjdk13/Makefile b/java/openjdk13/Makefile
index c78fdded6489..a187baee5ad6 100644
--- a/java/openjdk13/Makefile
+++ b/java/openjdk13/Makefile
@@ -130,7 +130,12 @@ CONFIGURE_ARGS+=	--with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA
 .else
 MAKE_ENV+=	USE_CLANG=true
 .if ${COMPILER_VERSION} >= 130
-CONFIGURE_ARGS+=	--with-extra-cflags="-Wno-unused-but-set-parameter"
+EXTRA_CFLAGS+=		-Wno-unused-but-set-parameter
+.if ${COMPILER_VERSION} >= 140
+EXTRA_CFLAGS+=		-Wno-bitwise-instead-of-logical
+.endif
+CONFIGURE_ARGS+=	--with-extra-cflags="${EXTRA_CFLAGS}"
+CONFIGURE_ARGS+=	--with-extra-cxxflags="${EXTRA_CFLAGS}"
 .endif
 .endif
 
diff --git a/java/openjdk14/Makefile b/java/openjdk14/Makefile
index eaf7ae811e30..5c01e6bb95e2 100644
--- a/java/openjdk14/Makefile
+++ b/java/openjdk14/Makefile
@@ -132,7 +132,12 @@ CONFIGURE_ARGS+=	--with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA
 .else
 MAKE_ENV+=	USE_CLANG=true
 .if ${COMPILER_VERSION} >= 130
-CONFIGURE_ARGS+=	--with-extra-cflags="-Wno-unused-but-set-parameter"
+EXTRA_CFLAGS+=		-Wno-unused-but-set-parameter
+.if ${COMPILER_VERSION} >= 140
+EXTRA_CFLAGS+=		-Wno-bitwise-instead-of-logical
+.endif
+CONFIGURE_ARGS+=	--with-extra-cflags="${EXTRA_CFLAGS}"
+CONFIGURE_ARGS+=	--with-extra-cxxflags="${EXTRA_CFLAGS}"
 .endif
 .endif
 
diff --git a/java/openjdk15/Makefile b/java/openjdk15/Makefile
index 28e44f2ea369..acd497b76ea2 100644
--- a/java/openjdk15/Makefile
+++ b/java/openjdk15/Makefile
@@ -131,7 +131,12 @@ CONFIGURE_ARGS+=	--with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA
 .else
 MAKE_ENV+=	USE_CLANG=true
 .if ${COMPILER_VERSION} >= 130
-CONFIGURE_ARGS+=	--with-extra-cflags="-Wno-unused-but-set-parameter"
+EXTRA_CFLAGS+=		-Wno-unused-but-set-parameter
+.if ${COMPILER_VERSION} >= 140
+EXTRA_CFLAGS+=		-Wno-bitwise-instead-of-logical
+.endif
+CONFIGURE_ARGS+=	--with-extra-cflags="${EXTRA_CFLAGS}"
+CONFIGURE_ARGS+=	--with-extra-cxxflags="${EXTRA_CFLAGS}"
 .endif
 .endif
 
diff --git a/java/openjdk16/Makefile b/java/openjdk16/Makefile
index 4d7f95959c51..bba4b4283847 100644
--- a/java/openjdk16/Makefile
+++ b/java/openjdk16/Makefile
@@ -134,7 +134,12 @@ CONFIGURE_ARGS+=	--with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA
 .else
 MAKE_ENV+=	USE_CLANG=true
 .if ${COMPILER_VERSION} >= 130
-CONFIGURE_ARGS+=	--with-extra-cflags="-Wno-unused-but-set-parameter"
+EXTRA_CFLAGS+=		-Wno-unused-but-set-parameter
+.if ${COMPILER_VERSION} >= 140
+EXTRA_CFLAGS+=		-Wno-bitwise-instead-of-logical
+.endif
+CONFIGURE_ARGS+=	--with-extra-cflags="${EXTRA_CFLAGS}"
+CONFIGURE_ARGS+=	--with-extra-cxxflags="${EXTRA_CFLAGS}"
 .endif
 .endif
 
diff --git a/java/openjdk17/Makefile b/java/openjdk17/Makefile
index 04dd691cf65f..056911944d74 100644
--- a/java/openjdk17/Makefile
+++ b/java/openjdk17/Makefile
@@ -149,7 +149,12 @@ CONFIGURE_ARGS+=	--with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA
 .else
 MAKE_ENV+=	USE_CLANG=true
 .if ${COMPILER_VERSION} >= 130
-CONFIGURE_ARGS+=	--with-extra-cflags="-Wno-unused-but-set-parameter"
+EXTRA_CFLAGS+=		-Wno-unused-but-set-parameter
+.if ${COMPILER_VERSION} >= 140
+EXTRA_CFLAGS+=		-Wno-bitwise-instead-of-logical
+.endif
+CONFIGURE_ARGS+=	--with-extra-cflags="${EXTRA_CFLAGS}"
+CONFIGURE_ARGS+=	--with-extra-cxxflags="${EXTRA_CFLAGS}"
 .endif
 .endif