From nobody Sat Oct 16 12:22:29 2021 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 7F52717FB0B0; Sat, 16 Oct 2021 12:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4HWj2F354qz4kjJ; Sat, 16 Oct 2021 12:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4ACE119C9D; Sat, 16 Oct 2021 12:22:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19GCMTQM083300; Sat, 16 Oct 2021 12:22:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19GCMTVT083299; Sat, 16 Oct 2021 12:22:29 GMT (envelope-from git) Date: Sat, 16 Oct 2021 12:22:29 GMT Message-Id: <202110161222.19GCMTVT083299@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Dimitry Andric Subject: git: 3822416493cf - main - java/openjdk*: work around UB in markOopDesc, fix builds with clang 13 List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3822416493cfbbed8fe7a487391b40bec956d671 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim (src committer): URL: https://cgit.FreeBSD.org/ports/commit/?id=3822416493cfbbed8fe7a487391b40bec956d671 commit 3822416493cfbbed8fe7a487391b40bec956d671 Author: Dimitry Andric AuthorDate: 2021-10-15 18:18:36 +0000 Commit: Dimitry Andric CommitDate: 2021-10-16 12:22:03 +0000 java/openjdk*: work around UB in markOopDesc, fix builds with clang 13 During an exp-run for llvm 13 (see bug 258209), it turned out that java/openjdk11 through openjdk13 fail to build with clang 13: === Output from failing command(s) repeated here === * For target jdk__packages_attribute.done: These crashes are all caused by the markOop/markOopDesc classes, which are used to keep track of objects, and which are 'marked' using the low few bits. (See https://github.com/openjdk/jdk13u/blob/master/src/hotspot/share/oops/markOop.hpp ). After some laborious bisecting, I found out that these crashes start occuring after the upstream commit https://github.com /llvm/llvm-project/commit/16d03818412 (Return "[CGCall] Annotate this argument with alignment"). What happens afterwards, is that clang considers the "this" pointer to always be aligned to the alignment of the actual object, and then masking or adding a few low bits is not working as expected. The reason openjdk14 and higher work fine with clang 13, and don't crash similarly, is that the OpenJDK people completely redid the markOop/markOopDesc classes in https://github.com/openjdk/jdk/commit/ae5615c6142a4dc0d9033462f4880d7b3c127e26 ("8229258: Rework markOop and markOopDesc into a simpler mark word value carrier"). E.g, the markOopDesc class was renamed to markWord, and *stores* a pointer-like value instead of *being* a pointer-like value. This is a much safer way of handling things. However, this upstream commit is *very* large, as are a few of its follow-ups, which is probably the reason why it has not been backported to JDKs <= 13. I tried manually backporting it, but got lost in many nasty patch conflicts and problems. As a workaround, build openjdk8 through 13 with clang12 from the devel/llvm12 port, for the time being. In addition, allow openjdk14 through 17 to be built with clang 13, by adding -Wno-unused-but-set-parameter to the compilation flags. PR: 258954 Approved by: maintainer timeout (2 weeks) MFH: 2021Q4 --- java/openjdk11/Makefile | 9 +++++++++ java/openjdk12/Makefile | 10 +++++++++- java/openjdk13/Makefile | 9 +++++++++ java/openjdk14/Makefile | 5 ++++- java/openjdk15/Makefile | 4 ++++ java/openjdk16/Makefile | 4 ++++ java/openjdk17/Makefile | 5 ++++- java/openjdk8/Makefile | 8 ++++++++ 8 files changed, 51 insertions(+), 3 deletions(-) diff --git a/java/openjdk11/Makefile b/java/openjdk11/Makefile index a6f9fe592ded..68fae74c20b0 100644 --- a/java/openjdk11/Makefile +++ b/java/openjdk11/Makefile @@ -1,6 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} +PORTREVISION= 1 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -142,6 +143,14 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +# PR258954: OpenJDK <= 13 crash due to undefined behavior with clang >= 13 +# See also https://bugs.openjdk.java.net/browse/JDK-8229258 +LLVM_VER= 12 +BUILD_DEPENDS+= clang${LLVM_VER}:devel/llvm${LLVM_VER} +CC= ${LOCALBASE}/bin/clang${LLVM_VER} +CXX= ${LOCALBASE}/bin/clang++${LLVM_VER} +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Marmv*} || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk12/Makefile b/java/openjdk12/Makefile index 9f860f250a77..8790137eff98 100644 --- a/java/openjdk12/Makefile +++ b/java/openjdk12/Makefile @@ -1,7 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} -PORTREVISION= 3 +PORTREVISION= 4 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -131,6 +131,14 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +# PR258954: OpenJDK <= 13 crash due to undefined behavior with clang >= 13 +# See also https://bugs.openjdk.java.net/browse/JDK-8229258 +LLVM_VER= 12 +BUILD_DEPENDS+= clang${LLVM_VER}:devel/llvm${LLVM_VER} +CC= ${LOCALBASE}/bin/clang${LLVM_VER} +CXX= ${LOCALBASE}/bin/clang++${LLVM_VER} +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk13/Makefile b/java/openjdk13/Makefile index 20cf6fcc719e..ea5e79d3d418 100644 --- a/java/openjdk13/Makefile +++ b/java/openjdk13/Makefile @@ -1,6 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} +PORTREVISION= 1 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -129,6 +130,14 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +# PR258954: OpenJDK <= 13 crash due to undefined behavior with clang >= 13 +# See also https://bugs.openjdk.java.net/browse/JDK-8229258 +LLVM_VER= 12 +BUILD_DEPENDS+= clang${LLVM_VER}:devel/llvm${LLVM_VER} +CC= ${LOCALBASE}/bin/clang${LLVM_VER} +CXX= ${LOCALBASE}/bin/clang++${LLVM_VER} +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk14/Makefile b/java/openjdk14/Makefile index d799dbc1b1f1..eaf7ae811e30 100644 --- a/java/openjdk14/Makefile +++ b/java/openjdk14/Makefile @@ -1,7 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} -PORTREVISION= 2 +PORTREVISION= 3 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -131,6 +131,9 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +CONFIGURE_ARGS+= --with-extra-cflags="-Wno-unused-but-set-parameter" +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk15/Makefile b/java/openjdk15/Makefile index 1f88eade1ed4..fbf793351302 100644 --- a/java/openjdk15/Makefile +++ b/java/openjdk15/Makefile @@ -1,6 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} +PORTREVISION= 1 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -130,6 +131,9 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +CONFIGURE_ARGS+= --with-extra-cflags="-Wno-unused-but-set-parameter" +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk16/Makefile b/java/openjdk16/Makefile index e47aa553774e..4d7f95959c51 100644 --- a/java/openjdk16/Makefile +++ b/java/openjdk16/Makefile @@ -1,6 +1,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} +PORTREVISION= 1 CATEGORIES= java devel PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} @@ -132,6 +133,9 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +CONFIGURE_ARGS+= --with-extra-cflags="-Wno-unused-but-set-parameter" +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk17/Makefile b/java/openjdk17/Makefile index 50d43bd35a2f..ae32625b5908 100644 --- a/java/openjdk17/Makefile +++ b/java/openjdk17/Makefile @@ -2,7 +2,7 @@ PORTNAME= openjdk DISTVERSIONPREFIX= jdk- DISTVERSION= ${JDK_MAJOR_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION} CATEGORIES= java devel -PORTREVISION= 1 +PORTREVISION= 2 PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION} MAINTAINER= java@FreeBSD.org @@ -133,6 +133,9 @@ CONFIGURE_ARGS+= --with-extra-ldflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFA --with-extra-cxxflags="-Wl,-rpath=${LOCALBASE}/lib/gcc${GCC_DEFAULT}" .else MAKE_ENV+= USE_CLANG=true +.if ${COMPILER_VERSION} >= 130 +CONFIGURE_ARGS+= --with-extra-cflags="-Wno-unused-but-set-parameter" +.endif .endif .if ${ARCH} == aarch64 || ${ARCH:Mpowerpc64*} diff --git a/java/openjdk8/Makefile b/java/openjdk8/Makefile index 90f20695c4d1..65cbbb39a314 100644 --- a/java/openjdk8/Makefile +++ b/java/openjdk8/Makefile @@ -204,6 +204,14 @@ LIB_DEPENDS+= libffi.so:devel/libffi .if ${COMPILER_TYPE} == clang MAKE_ENV+= COMPILER_WARNINGS_FATAL=false USE_CLANG=true CONFIGURE_ENV+= LIBCXX="-lc++" +.if ${COMPILER_VERSION} >= 130 +# PR258954: OpenJDK <= 13 crash due to undefined behavior with clang >= 13 +# See also https://bugs.openjdk.java.net/browse/JDK-8229258 +LLVM_VER= 12 +BUILD_DEPENDS+= clang${LLVM_VER}:devel/llvm${LLVM_VER} +CC= ${LOCALBASE}/bin/clang${LLVM_VER} +CXX= ${LOCALBASE}/bin/clang++${LLVM_VER} +.endif .endif # GCC is broken with PCH: https://lists.freebsd.org/pipermail/svn-src-all/2015-March/101722.html