The FreeBSD folks did an in-depth analysis of why jdk
1.8 and 11 fail to build with llvm13. You can read about
it here:

https://github.com/freebsd/freebsd-ports/commit/3822416493c

In llvm13 the 'this' pointer was annotated with alignment:

https://github.com/llvm/llvm-project/commit/0aa0458f142

It was reverted and then put back in:

https://github.com/llvm/llvm-project/commit/16d03818412

In jdk/1.8 and jdk/11 code bases there's a class markOopDesc
that bit twiddles the 'this' pointer and the alignment change
is presumably optimizing it away.

I don't have an llvm13 system setup yet so I'm taking a shot
in the dark that annotating the value() method as no-inline will
correct the llvm13 build. The idea being that value() is getting
optimized away and the compiler is seeing 'this' as aligned and
further optimizing away the bit twiddling. 

https://github.com/openjdk/jdk11u/blob/master/src/hotspot/share/oops/markOop.hpp#L107

For jdk/17 markOopDesc was rewritten and it fails to build due
to -Werror. Adding -Wno-unused-but-set-parameter should fix that.

Index: 1.8/Makefile
===================================================================
RCS file: /cvs/ports/devel/jdk/1.8/Makefile,v
retrieving revision 1.64
diff -u -p -u -r1.64 Makefile
--- 1.8/Makefile        5 Aug 2021 15:40:20 -0000       1.64
+++ 1.8/Makefile        30 Oct 2021 12:56:25 -0000
@@ -13,7 +13,7 @@ V=            ${BASE_VER}.${UPDATE_VER}.${BUILD_VE
 PKGNAME=       jdk-${V}
 PKGSTEM=       jdk-${BASE_VER}
 EPOCH=         0
-REVISION=      0
+REVISION=      1
 
 DIST_SUBDIR=   jdk
 DISTNAME=      jdk8u${UPDATE_VER}-${BUILD_VER}.${BSD_PORT_REL}
Index: 1.8/patches/patch-hotspot_src_share_vm_oops_markOop_hpp
===================================================================
RCS file: 1.8/patches/patch-hotspot_src_share_vm_oops_markOop_hpp
diff -N 1.8/patches/patch-hotspot_src_share_vm_oops_markOop_hpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 1.8/patches/patch-hotspot_src_share_vm_oops_markOop_hpp     30 Oct 2021 
12:56:25 -0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Fix build with llvm 13
+
+Index: hotspot/src/share/vm/oops/markOop.hpp
+--- hotspot/src/share/vm/oops/markOop.hpp.orig
++++ hotspot/src/share/vm/oops/markOop.hpp
+@@ -104,7 +104,7 @@ class JavaThread;
+ class markOopDesc: public oopDesc {
+  private:
+   // Conversion
+-  uintptr_t value() const { return (uintptr_t) this; }
++  NOINLINE uintptr_t value() const { return (uintptr_t) this; }
+ 
+  public:
+   // Constants
Index: 11/Makefile
===================================================================
RCS file: /cvs/ports/devel/jdk/11/Makefile,v
retrieving revision 1.25
diff -u -p -u -r1.25 Makefile
--- 11/Makefile 5 Aug 2021 02:21:41 -0000       1.25
+++ 11/Makefile 30 Oct 2021 12:56:25 -0000
@@ -13,6 +13,7 @@ PACKAGE_VER=  ${BASE_VER}.${PATCH_VER}.${
 PKGNAME=       jdk-${PACKAGE_VER}
 PKGSTEM=       jdk-11
 EPOCH=         0
+REVISION=      0
 
 DIST_SUBDIR=   jdk
 DISTNAME=      jdk-${VERSION_STR}
Index: 11/patches/patch-src_hotspot_share_oops_markOop_hpp
===================================================================
RCS file: 11/patches/patch-src_hotspot_share_oops_markOop_hpp
diff -N 11/patches/patch-src_hotspot_share_oops_markOop_hpp
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ 11/patches/patch-src_hotspot_share_oops_markOop_hpp 30 Oct 2021 12:56:25 
-0000
@@ -0,0 +1,16 @@
+$OpenBSD$
+
+Fix build for llvm13
+
+Index: src/hotspot/share/oops/markOop.hpp
+--- src/hotspot/share/oops/markOop.hpp.orig
++++ src/hotspot/share/oops/markOop.hpp
+@@ -104,7 +104,7 @@ class JavaThread;
+ class markOopDesc: public oopDesc {
+  private:
+   // Conversion
+-  uintptr_t value() const { return (uintptr_t) this; }
++  NOINLINE uintptr_t value() const { return (uintptr_t) this; }
+ 
+  public:
+   // Constants
Index: 17/Makefile
===================================================================
RCS file: /cvs/ports/devel/jdk/17/Makefile,v
retrieving revision 1.2
diff -u -p -u -r1.2 Makefile
--- 17/Makefile 30 Oct 2021 00:31:15 -0000      1.2
+++ 17/Makefile 30 Oct 2021 12:56:25 -0000
@@ -13,7 +13,7 @@ PACKAGE_VER=  ${BASE_VER}.${PATCH_VER}.${
 PKGNAME=       jdk-${PACKAGE_VER}
 PKGSTEM=       jdk-17
 EPOCH=         0
-REVISION=      0
+REVISION=      1
 
 DIST_SUBDIR=   jdk
 DISTNAME=      jdk-${VERSION_STR}
Index: 17/patches/patch-make_hotspot_lib_CompileJvm_gmk
===================================================================
RCS file: 
/cvs/ports/devel/jdk/17/patches/patch-make_hotspot_lib_CompileJvm_gmk,v
retrieving revision 1.1.1.1
diff -u -p -u -r1.1.1.1 patch-make_hotspot_lib_CompileJvm_gmk
--- 17/patches/patch-make_hotspot_lib_CompileJvm_gmk    29 Oct 2021 18:15:16 
-0000      1.1.1.1
+++ 17/patches/patch-make_hotspot_lib_CompileJvm_gmk    30 Oct 2021 12:56:25 
-0000
@@ -1,11 +1,22 @@
 $OpenBSD: patch-make_hotspot_lib_CompileJvm_gmk,v 1.1.1.1 2021/10/29 18:15:16 
kurt Exp $
 
-This file name changed in 17 and needs to be excluded
+threadLS_bsd_aarch64.S name changed in 17 and needs to be excluded.
+Disable unused-but-set-parameter for llvm13.
 
 Index: make/hotspot/lib/CompileJvm.gmk
 --- make/hotspot/lib/CompileJvm.gmk.orig
 +++ make/hotspot/lib/CompileJvm.gmk
-@@ -128,7 +128,7 @@ else ifeq ($(call And, $(call isTargetOs, linux) $(cal
+@@ -95,7 +95,8 @@ DISABLED_WARNINGS_clang := tautological-compare \
+     undefined-var-template sometimes-uninitialized unknown-pragmas \
+     delete-non-virtual-dtor missing-braces char-subscripts \
+     ignored-qualifiers missing-field-initializers mismatched-tags \
+-    unnamed-type-template-args shift-negative-value format-nonliteral
++    unnamed-type-template-args shift-negative-value format-nonliteral \
++    unused-but-set-parameter
+ 
+ ifneq (,$(filter 1%,$(CC_VERSION_NUMBER)))
+   DISABLED_WARNINGS_clang += misleading-indentation
+@@ -128,7 +129,7 @@ else ifeq ($(call And, $(call isTargetOs, linux) $(cal
  endif
  
  ifeq ($(OPENJDK_TARGET_OS_ENV)-$(OPENJDK_TARGET_CPU), bsd.openbsd-aarch64)

Reply via email to