Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 817995 - dev-java/openjdk-11.0.12_p7: failed to compile with clang-13
Summary: dev-java/openjdk-11.0.12_p7: failed to compile with clang-13
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Java team
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2021-10-13 14:47 UTC by 12101111
Modified: 2024-03-06 12:41 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log.xz (build.log.xz,290.81 KB, application/x-xz)
2021-10-13 14:49 UTC, 12101111
Details
hs_err_pid3061021.log (hs_err_pid3061021.log,32.70 KB, text/x-log)
2021-10-13 14:49 UTC, 12101111
Details
Respect user-supplied optlevel for Clang (openjdk-11.0.12_p7-clang-optlevel.patch,571 bytes, patch)
2021-10-16 03:54 UTC, Tee KOBAYASHI
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description 12101111 2021-10-13 14:47:09 UTC
This is tested in a clean glibc no-multilib systemd chroot, although I first find it in a musl system.

Reproducible: Always

Steps to Reproduce:
1. emerge clang:12 clang:13 openjdk-bin:11
2. `CC=clang CXX=clang++` in /etc/portage/make.conf
3. emerge openjdk:11 failed
4. `CC=clang-12 CXX=clang++-12` in /etc/portage/make.conf
5. emerge openjdk:11 succeeded
Actual Results:  
The log say:
Optimizing the exploded image
( /bin/rm -f /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log && /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/bin/java -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1 -cp /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/buildtools/tools_jigsaw_classes --add-exports java.base/jdk.internal.module=ALL-UNNAMED build.tools.jigsaw.AddPackagesAttribute /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk > >(/usr/bin/tee -a /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log) 2> >(/usr/bin/tee -a /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log >&2) || ( exitcode=$? && /bin/cp /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/make-support/failure-logs/jdk__packages_attribute.done.log && /bin/cp /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.cmdline /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/make-support/failure-logs/jdk__packages_attribute.done.cmdline && exit $exitcode ) )
#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f3d02b158c1, pid=3061021, tid=3061026
#
# JRE version:  (11.0.12+7) (build )
# Java VM: OpenJDK 64-Bit Server VM (11.0.12+7, mixed mode, tiered, compressed oops, serial gc, linux-amd64)
# Problematic frame:
# V  [libjvm.so+0xb778c1]  ObjectSynchronizer::inflate(Thread*, oopDesc*, ObjectSynchronizer::InflateCause)+0xf1
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/make/hs_err_pid3061021.log
#
#
/bin/bash: line 1: 3061021 Aborted                 /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/bin/java -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1 -cp /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/buildtools/tools_jigsaw_classes --add-exports java.base/jdk.internal.module=ALL-UNNAMED build.tools.jigsaw.AddPackagesAttribute /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk > >(/usr/bin/tee -a /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log) 2> >(/usr/bin/tee -a /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done.log >&2)
gmake[3]: *** [ExplodedImageOptimize.gmk:41: /var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/build/linux-x86_64-normal-server-release/jdk/_packages_attribute.done] Error 134
gmake[3]: Leaving directory '/var/tmp/portage/dev-java/openjdk-11.0.12_p7/work/jdk11u-jdk-11.0.12-ga/make'
gmake[2]: *** [make/Main.gmk:411: exploded-image-optimize] Error 2

hs_err_pid2632904.log contain more detail of backtrace:
Current thread (0x00007f3cfc027000):  JavaThread "Unknown thread" [_thread_in_vm, id=3061026, stack(0x00007f3d01d55000,0x00007f3d01e56000)]

Stack: [0x00007f3d01d55000,0x00007f3d01e56000],  sp=0x00007f3d01e54580,  free space=1021k
Native frames: (J=compiled Java code, A=aot compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0xb778c1]  ObjectSynchronizer::inflate(Thread*, oopDesc*, ObjectSynchronizer::InflateCause)+0xf1
V  [libjvm.so+0xb77df5]  ObjectLocker::ObjectLocker(Handle, Thread*, bool)+0x95
V  [libjvm.so+0x73d276]  InstanceKlass::link_class_impl(bool, Thread*)+0x306
V  [libjvm.so+0x73d05e]  InstanceKlass::link_class_impl(bool, Thread*)+0xee
V  [libjvm.so+0x73d05e]  InstanceKlass::link_class_impl(bool, Thread*)+0xee
V  [libjvm.so+0x73d05e]  InstanceKlass::link_class_impl(bool, Thread*)+0xee
V  [libjvm.so+0x73da17]  InstanceKlass::link_class_or_fail(Thread*)+0x27
V  [libjvm.so+0xbd4b27]  universe_post_init()+0x327
V  [libjvm.so+0x73b259]  init_globals()+0xc9
V  [libjvm.so+0xbafbd4]  Threads::create_vm(JavaVMInitArgs*, bool*)+0x284
V  [libjvm.so+0x7c2eb7]  JNI_CreateJavaVM+0x57
C  [libjli.so+0x52d2]  JavaMain+0x112
C  [libjli.so+0x8509]  ThreadJavaMain+0x9


siginfo: si_signo: 11 (SIGSEGV), si_code: 1 (SEGV_MAPERR), si_addr: 0x0000000000000001



emerge --info:

Portage 3.0.28 (python 3.9.7-final-0, default/linux/amd64/17.1/no-multilib/systemd, gcc-10.3.0, glibc-2.33-r1, 5.10.0-8-amd64 x86_64)
=================================================================
System uname: Linux-5.10.0-8-amd64-x86_64-Intel-R-_Xeon-R-_Gold_5220R_CPU_@_2.20GHz-with-glibc2.33
KiB Mem:   131490788 total,  65421464 free
KiB Swap:          0 total,         0 free
Timestamp of repository gentoo: Fri, 08 Oct 2021 05:51:27 +0000
Timestamp of repository gentoo-zh: Mon, 04 Oct 2021 01:06:16 +0000
sh bash 5.1_p8
ld GNU ld (Gentoo 2.37_p1 p0) 2.37
app-shells/bash:          5.1_p8::gentoo
dev-java/java-config:     2.3.1::gentoo
dev-lang/perl:            5.34.0-r2::gentoo
dev-lang/python:          3.9.7::gentoo
dev-util/cmake:           3.21.3::gentoo
sys-apps/baselayout:      2.8::gentoo
sys-apps/sandbox:         2.25::gentoo
sys-devel/autoconf:       2.71-r1::gentoo
sys-devel/automake:       1.16.5::gentoo
sys-devel/binutils:       2.37_p1::gentoo
sys-devel/gcc:            10.3.0-r2::gentoo
sys-devel/gcc-config:     2.4::gentoo
sys-devel/libtool:        2.4.6-r6::gentoo
sys-devel/make:           4.3::gentoo
sys-kernel/linux-headers: 5.14::gentoo (virtual/os-headers)
sys-libs/glibc:           2.33-r1::gentoo
Repositories:

gentoo
    location: /usr/portage/gentoo
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo
    priority: -1000

gentoo-zh
    location: /usr/portage/gentoo-zh
    sync-type: git
    sync-uri: https://github.com/gentoo-mirror/gentoo-zh.git
    masters: gentoo

12101111-overlay
    location: /usr/portage/local
    masters: gentoo
    priority: 1000

ACCEPT_KEYWORDS="amd64 ~amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CC="clang"
CFLAGS="-O2 -pipe -march=skylake"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/sandbox.d /etc/terminfo"
CXX="clang++"
CXXFLAGS="-O2 -pipe -march=skylake"
DISTDIR="/var/cache/distfiles"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
FCFLAGS="-O2 -pipe -march=skylake"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync multilib-strict network-sandbox news parallel-fetch preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe -march=skylake"
GENTOO_MIRRORS="https://mirrors.tuna.tsinghua.edu.cn/gentoo"
LANG="zh_CN.UTF-8"
LC_ALL="zh_CN.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j96"
PKGDIR="/var/cache/binpkgs"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
USE="acl amd64 bzip2 cli crypt dri fortran gdbm iconv ipv6 libglvnd libtirpc ncurses nls nptl openmp pam pcre readline seccomp split-usr ssl systemd tcpd udev unicode xattr zlib" ABI_X86="64" ADA_TARGET="gnat_2019" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="mmx mmxext sse sse2" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="libinput" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php7-3 php7-4" POSTGRES_TARGETS="postgres12 postgres13" PYTHON_SINGLE_TARGET="python3_9" PYTHON_TARGETS="python3_9" RUBY_TARGETS="ruby26" USERLAND="GNU" VIDEO_CARDS="amdgpu fbdev intel nouveau radeon radeonsi vesa dummy v4l" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  CPPFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LINGUAS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RUSTFLAGS
Comment 1 12101111 2021-10-13 14:49:06 UTC
Created attachment 744768 [details]
build.log.xz
Comment 2 12101111 2021-10-13 14:49:36 UTC
Created attachment 744771 [details]
hs_err_pid3061021.log
Comment 3 Georgy Yakovlev archtester gentoo-dev 2021-10-15 20:05:21 UTC
reports or check upstream for possible patches, I'll add those as needed if they don't break everything else.
Comment 4 Tee KOBAYASHI 2021-10-16 03:54:20 UTC
Created attachment 745089 [details, diff]
Respect user-supplied optlevel for Clang

One thing that can be an obstacle to tackling this is that OpenJDK's build system does not respect user-supplied optlevel. Regardless of what is specified in C(XX)?FLAGS, most objects are compiled with the -O3 optimization level.

A patch is attached against this situation for Clang. Note that this patch assumes that the user-supplied optlevel is -O2 or lower. Otherwise C_O_FLAG_NORM="-O2" has to be specified.
Comment 5 Tee KOBAYASHI 2021-10-20 04:27:49 UTC
JDK Bug System has an apparently related issue: https://bugs.openjdk.java.net/browse/JDK-8229258, the author of which points out undefined behaviors with regard to markOop{,Desc}. I suspect that the UBs are actually hit by Clang/LLVM 13.

The fix is reported to have been merged in JDK 14, and in fact dev-java/openjdk-17_p35 in Gentoo repo seems to be free from this issue.
Comment 6 Georgy Yakovlev archtester gentoo-dev 2021-10-20 17:26:03 UTC
xtkoba@gmail.com thanks for looking and chiming in openjdk bugs lately, competent help is really appreciated.

I don't have much time lately, but I'll try building it with clang with/without patch and maybe improve overall *flag situation too.

openjdk sets flags for a reason, usually, it's quite sensitive code, so I'm a bit hesitant to force user's preferences blindly.
Comment 7 James Beddek 2021-11-01 12:26:33 UTC
(In reply to Tee KOBAYASHI from comment #5)
> JDK Bug System has an apparently related issue:
> https://bugs.openjdk.java.net/browse/JDK-8229258, the author of which points
> out undefined behaviors with regard to markOop{,Desc}. I suspect that the
> UBs are actually hit by Clang/LLVM 13.
> 
> The fix is reported to have been merged in JDK 14, and in fact
> dev-java/openjdk-17_p35 in Gentoo repo seems to be free from this issue.

It is indeed from Clang 13, see: https://reviews.llvm.org/D99790#2678384
Comment 8 Campbell Jones 2021-12-19 03:01:00 UTC
I created a patch for JDK 11 that fixes this issue. I just created this account, so I can't link the patch here, but it's !23 on the jdk11u GitHub repository.
Comment 9 Georgy Yakovlev archtester gentoo-dev 2021-12-20 08:06:59 UTC
thanks!

adding patch link here

https://github.com/openjdk/jdk11u/pull/23

it's quite a large patch, let's see what maintainers say.
if they approve it I'll add it to gentoo quickly.

meanwhile users could use /etc/portage/patches I guess.
Comment 10 12101111 2023-08-05 09:11:27 UTC
FreeBSD have a simple fix for this issue: https://github.com/battleblow/jdk11u/commit/305a68a90c722aa7a7b75589e24d5b5d554c96c1