Clang 13 doesn't like when you use 'this' as tagged pointer. It optimizes

away the bit twiddling. Work around this by setting all accessor methods to
no-inline and where that wasn't sufficient, reduce optimization level to
-O1 to prevent clang from optimizing away code that is needed.

Also remove ant as build depend. This was never needed and mistakenly
copied from the 1.7 jdk port.
This commit is contained in:
kurt 2022-01-08 22:41:06 +00:00
parent c474325196
commit 5ea37d57bd
9 changed files with 186 additions and 15 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.67 2021/12/22 11:05:12 rsadowski Exp $
# $OpenBSD: Makefile,v 1.68 2022/01/08 22:41:06 kurt Exp $
ONLY_FOR_ARCHS= i386 amd64 aarch64 sparc64
USE_WXNEEDED= Yes
@ -13,13 +13,13 @@ V= ${BASE_VER}.${UPDATE_VER}.${BUILD_VER}.${BSD_PORT_REL}
PKGNAME= jdk-${V}
PKGSTEM= jdk-${BASE_VER}
EPOCH= 0
REVISION= 1
DIST_SUBDIR= jdk
DISTNAME= jdk8u${UPDATE_VER}-${BUILD_VER}.${BSD_PORT_REL}
BOOTJDK_DATE= 20210615
DISTFILES= ${DISTNAME}${EXTRACT_SUFX}
WRKDIST= ${WRKDIR}/jdk8u-jdk8u${UPDATE_VER}-${BUILD_VER}.${BSD_PORT_REL}
REVISION= 0
CATEGORIES= devel/jdk java
@ -31,8 +31,6 @@ HOMEPAGE= https://openjdk.java.net/
MASTER_SITES= https://github.com/battleblow/jdk8u/archive/
MASTER_SITES1= https://spacehopper.org/mirrors/ \
http://www.intricatesoftware.com/distfiles/
MASTER_SITES2= ${MASTER_SITE_APACHE:=ant/binaries/} \
https://archive.apache.org/dist/ant/binaries/
MAINTAINER= Kurt Miller <kurt@openbsd.org>
@ -43,13 +41,10 @@ DEBUG_PACKAGES= ${BUILD_PACKAGES}
NO_TEST= Yes
APACHE_ANT_V= 1.9.7
APACHE_ANT= apache-ant-${APACHE_ANT_V}-bin.tar.gz
SUPDISTFILES+= openjdk-jdk8u-bootjdk-i386-${BOOTJDK_DATE}.tar.gz:1 \
openjdk-jdk8u-bootjdk-amd64-${BOOTJDK_DATE}.tar.gz:1 \
openjdk-jdk8u-bootjdk-aarch64-${BOOTJDK_DATE}.tar.gz:1 \
openjdk-jdk8u-bootjdk-sparc64-${BOOTJDK_DATE}.tar.gz:1 \
${APACHE_ANT}:2
openjdk-jdk8u-bootjdk-sparc64-${BOOTJDK_DATE}.tar.gz:1
COMPILER= base-clang base-gcc
@ -60,8 +55,7 @@ INSTALLED!= (pkg_info -qe "jdk->=1.8.0.00v0,<1.9v0" && echo yes) || echo no
. if ${INSTALLED:L} != "yes"
ERRORS += "Fatal: This flavor requires an installed 1.8.0.00v0 or greater jdk package"
. endif
BUILD_DEPENDS+= jdk->=1.8.0.00v0,<1.9v0:devel/jdk/1.8 \
devel/apache-ant>=1.8.2
BUILD_DEPENDS+= jdk->=1.8.0.00v0,<1.9v0:devel/jdk/1.8
BOOT_JDK= ${LOCALBASE}/jdk-1.8.0
.else
BOOT_JDK_DIST= openjdk-jdk8u-bootjdk-${MACHINE_ARCH}-${BOOTJDK_DATE}.tar.gz
@ -69,9 +63,7 @@ BOOT_JDK_DIST= openjdk-jdk8u-bootjdk-${MACHINE_ARCH}-${BOOTJDK_DATE}.tar.gz
(${MACHINE_ARCH}==aarch64) || (${MACHINE_ARCH}==sparc64)
DISTFILES+= ${BOOT_JDK_DIST}:1
. endif
DISTFILES+= ${APACHE_ANT}:2
MAKE_ENV+= ANT_HOME=${WRKDIR}/apache-ant-${APACHE_ANT_V} \
LD_LIBRARY_PATH=${WRKDIR}/bootjdk-libs
MAKE_ENV+= LD_LIBRARY_PATH=${WRKDIR}/bootjdk-libs
CONFIGURE_ENV+= LD_LIBRARY_PATH=${WRKDIR}/bootjdk-libs
BOOT_JDK= ${WRKDIR}/bootjdk
.endif

View File

@ -1,10 +1,8 @@
SHA256 (jdk/apache-ant-1.9.7-bin.tar.gz) = HQuAj+gszpvMFn+Nu3x+icHX91NMDZxkv2Fex8Pmv+U=
SHA256 (jdk/jdk8u312-b07.1.tar.gz) = yBvNdeaqZmBYTfkJzNI5OCku7gcpJP25XUQAuhqwIaA=
SHA256 (jdk/openjdk-jdk8u-bootjdk-aarch64-20210615.tar.gz) = dcHgGHTdP2tOgUhTrrHxkCsOrnM+lnmqITDpygG8CgM=
SHA256 (jdk/openjdk-jdk8u-bootjdk-amd64-20210615.tar.gz) = PNX1evUzIBaoq/FQSWdS0w8DdrhUrxeCO8LrQeq8gr4=
SHA256 (jdk/openjdk-jdk8u-bootjdk-i386-20210615.tar.gz) = Ssb52Qm1oThmjf1e3Nz4UCnACdQHa4WTm08eFTQiZuE=
SHA256 (jdk/openjdk-jdk8u-bootjdk-sparc64-20210615.tar.gz) = wmY4+ZGdyrBKNcVGe4N2XOKMwzkN2qK/Z319brEbLqc=
SIZE (jdk/apache-ant-1.9.7-bin.tar.gz) = 5601575
SIZE (jdk/jdk8u312-b07.1.tar.gz) = 88671270
SIZE (jdk/openjdk-jdk8u-bootjdk-aarch64-20210615.tar.gz) = 103452168
SIZE (jdk/openjdk-jdk8u-bootjdk-amd64-20210615.tar.gz) = 104795359

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-hotspot_make_bsd_makefiles_gcc_make,v 1.5 2022/01/08 22:41:06 kurt Exp $
The jdk uses tagged pointers on 'this' which clang knows to
be aligned and then optimizes away the tags. Reduce optimization
levels to address this and avoid segfaults with clang 13.
Index: hotspot/make/bsd/makefiles/gcc.make
--- hotspot/make/bsd/makefiles/gcc.make.orig
+++ hotspot/make/bsd/makefiles/gcc.make
@@ -356,6 +356,12 @@ ifeq ($(USE_CLANG), true)
OPT_CFLAGS/bitMap.o += -O1
endif
endif
+ ifeq ($(shell expr $(CC_VER_MAJOR) = 13), 1)
+ ifeq ($(BUILDARCH), aarch64)
+ PCH_FLAG/immediate_aarch64.o = $(PCH_FLAG/NO_PCH)
+ OPT_CFLAGS/immediate_aarch64.o = -O1
+ endif
+ endif
else
# 6835796. Problem in GCC 4.3.0 with mulnode.o optimized compilation.
ifeq ($(shell expr $(CC_VER_MAJOR) = 4 \& $(CC_VER_MINOR) = 3), 1)

View File

@ -0,0 +1,39 @@
$OpenBSD: patch-hotspot_src_cpu_aarch64_vm_register_aarch64_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/cpu/aarch64/vm/register_aarch64.hpp
--- hotspot/src/cpu/aarch64/vm/register_aarch64.hpp.orig
+++ hotspot/src/cpu/aarch64/vm/register_aarch64.hpp
@@ -57,10 +57,16 @@ class RegisterImpl: public AbstractRegisterImpl {
VMReg as_VMReg();
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const { assert(is_valid(), "invalid register"); return (intptr_t)this; }
bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; }
bool has_byte_register() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_byte_registers; }
const char* name() const;
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding_nocheck() const { return (intptr_t)this; }
// Return the bit which represents this register. This is intended
@@ -136,7 +142,13 @@ class FloatRegisterImpl: public AbstractRegisterImpl {
FloatRegister successor() const { return as_FloatRegister(encoding() + 1); }
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const { assert(is_valid(), "invalid register"); return (intptr_t)this; }
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding_nocheck() const { return (intptr_t)this; }
bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; }
const char* name() const;

View File

@ -0,0 +1,38 @@
$OpenBSD: patch-hotspot_src_cpu_x86_vm_register_x86_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/cpu/x86/vm/register_x86.hpp
--- hotspot/src/cpu/x86/vm/register_x86.hpp.orig
+++ hotspot/src/cpu/x86/vm/register_x86.hpp
@@ -62,6 +62,9 @@ class RegisterImpl: public AbstractRegisterImpl {
VMReg as_VMReg();
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const { assert(is_valid(), "invalid register"); return (intptr_t)this; }
bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; }
bool has_byte_register() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_byte_registers; }
@@ -116,6 +119,9 @@ class FloatRegisterImpl: public AbstractRegisterImpl {
FloatRegister successor() const { return as_FloatRegister(encoding() + 1); }
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const { assert(is_valid(), "invalid register"); return (intptr_t)this; }
bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; }
const char* name() const;
@@ -158,6 +164,9 @@ class XMMRegisterImpl: public AbstractRegisterImpl {
XMMRegister successor() const { return as_XMMRegister(encoding() + 1); }
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const { assert(is_valid(), err_msg("invalid register (%d)", (int)(intptr_t)this )); return (intptr_t)this; }
bool is_valid() const { return 0 <= (intptr_t)this && (intptr_t)this < number_of_registers; }
const char* name() const;

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-hotspot_src_cpu_zero_vm_register_zero_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/cpu/zero/vm/register_zero.hpp
--- hotspot/src/cpu/zero/vm/register_zero.hpp.orig
+++ hotspot/src/cpu/zero/vm/register_zero.hpp
@@ -57,6 +57,9 @@ class RegisterImpl : public AbstractRegisterImpl {
}
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const {
assert(is_valid(), "invalid register");
return (intptr_t)this;
@@ -92,6 +95,9 @@ class FloatRegisterImpl : public AbstractRegisterImpl
}
// accessors
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int encoding() const {
assert(is_valid(), "invalid register");
return (intptr_t)this;

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-hotspot_src_share_vm_c1_c1_LIR_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/share/vm/c1/c1_LIR.hpp
--- hotspot/src/share/vm/c1/c1_LIR.hpp.orig
+++ hotspot/src/share/vm/c1/c1_LIR.hpp
@@ -213,6 +213,9 @@ class LIR_OprDesc: public CompilationResourceObj {
friend class LIR_OprFact;
// Conversion
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
intptr_t value() const { return (intptr_t) this; }
bool check_value_mask(intptr_t mask, intptr_t masked_value) const {

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-hotspot_src_share_vm_code_vmreg_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/share/vm/code/vmreg.hpp
--- hotspot/src/share/vm/code/vmreg.hpp.orig
+++ hotspot/src/share/vm/code/vmreg.hpp
@@ -125,6 +125,9 @@ friend class OptoReg; (public)
}
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
intptr_t value() const {return (intptr_t) this; }
void print_on(outputStream* st) const;

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-hotspot_src_share_vm_oops_metadata_hpp,v 1.1 2022/01/08 22:41:06 kurt Exp $
Work around using 'this' as a tagged pointer by preventing optimization
with clang 13.
Index: hotspot/src/share/vm/oops/metadata.hpp
--- hotspot/src/share/vm/oops/metadata.hpp.orig
+++ hotspot/src/share/vm/oops/metadata.hpp
@@ -37,6 +37,9 @@ class Metadata : public MetaspaceObj {
NOT_PRODUCT(Metadata() { _valid = 0; })
NOT_PRODUCT(bool is_valid() const volatile { return _valid == 0; })
+#if defined(__clang_major__) && (__clang_major__ >= 13)
+ NOINLINE
+#endif
int identity_hash() { return (int)(uintptr_t)this; }
// Rehashing support for tables containing pointers to this