openjdk-21.0.3_p9 fails to build with error: ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__cxa_unexpected_handler'; recompile with -fPIC Reproducible: Always Steps to Reproduce: 1. emerge '=openjdk-21.0.3_p9' 2. Observe error Actual Results: openjdk fails to build with error ld.lld: error: relocation R_X86_64_PC32 cannot be used against symbol '__cxa_unexpected_handler'; recompile with -fPIC Expected Results: openjdk should build $ emerge --info Portage 3.0.65 (python 3.12.4-final-0, default/linux/amd64/23.0/llvm, gcc-14, glibc-2.39-r9, 6.9.7-gentoo x86_64) ================================================================= System uname: Linux-6.9.7-gentoo-x86_64-AMD_Ryzen_9_7950X_16-Core_Processor-with-glibc2.39 KiB Mem: 130996332 total, 10693568 free KiB Swap: 7340028 total, 7339772 free Timestamp of repository gentoo: Tue, 09 Jul 2024 19:06:09 +0000 Head commit of repository gentoo: e1029b770272f6547d153e1bc05eb95c1e099b2e Timestamp of repository brother-overlay: Mon, 08 Jul 2024 10:19:15 +0000 Head commit of repository brother-overlay: 181663c2a3e34a3fbac384c7173c3986ba5f7bb8 Head commit of repository magpie: d54e8880c691e42204a0302e22a7d1b9ae433221 sh bash 5.2_p26-r8 ld GNU ld (Gentoo 2.42 p6) 2.42.0 app-misc/pax-utils: 1.3.7::gentoo app-shells/bash: 5.2_p26-r8::gentoo dev-build/autoconf: 2.13-r8::gentoo, 2.72-r1::gentoo dev-build/automake: 1.16.5-r2::gentoo dev-build/cmake: 3.30.0::gentoo dev-build/libtool: 2.4.7-r4::gentoo dev-build/make: 4.4.1-r1::gentoo dev-build/meson: 1.4.1::gentoo dev-java/java-config: 2.3.4::gentoo dev-lang/perl: 5.40.0::gentoo dev-lang/python: 3.12.4_p2::gentoo, 3.13.0_beta3_p1::gentoo dev-lang/rust: 1.77.1::gentoo sys-apps/baselayout: 2.15::gentoo sys-apps/openrc: 0.54.2::gentoo sys-apps/sandbox: 2.39::gentoo sys-devel/binutils: 2.42-r2::gentoo sys-devel/binutils-config: 5.5::gentoo sys-devel/clang: 17.0.6::gentoo, 18.1.8::gentoo sys-devel/gcc: 14.1.1_p20240622::gentoo sys-devel/gcc-config: 2.11::gentoo sys-devel/lld: 17.0.6::gentoo, 18.1.8::gentoo sys-devel/llvm: 17.0.6::gentoo, 18.1.8::gentoo sys-kernel/linux-headers: 6.9::gentoo (virtual/os-headers) sys-libs/glibc: 2.39-r9::gentoo Repositories: gentoo location: /var/db/repos/gentoo sync-type: git sync-uri: https://github.com/gentoo-mirror/gentoo.git priority: -1000 volatile: False brother-overlay location: /var/db/repos/brother-overlay sync-type: git sync-uri: https://github.com/gentoo-mirror/brother-overlay.git masters: gentoo volatile: False magpie location: /var/db/repos/magpie sync-type: git sync-uri: https://github.com/nvinson/magpie.git masters: gentoo volatile: False Binary Repositories: gentoobinhost priority: 1 sync-uri: https://distfiles.gentoo.org/releases/amd64/binpackages/23.0/x86-64 ACCEPT_KEYWORDS="amd64 ~amd64" ACCEPT_LICENSE="* -@EULA" ADDR2LINE="llvm-addr2line" AR="llvm-ar" AS="clang -c" CBUILD="x86_64-pc-linux-gnu" CC="clang" CFLAGS="-march=native -O3 -pipe -flto=thin" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /opt/brother/scanner/brscan4/brsanenetdevice4.cfg /usr/lib64/libreoffice/program/sofficerc /usr/share/gnupg/qualified.txt" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c" CPP="clang-cpp" CXX="clang++" CXXFLAGS="-march=native -O3 -pipe -flto=thin" DISTDIR="/var/cache/portage/distfiles" EMERGE_DEFAULT_OPTS="--quiet-build" ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE 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 XDG_STATE_HOME" FCFLAGS="-march=native -O3 -pipe" FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs binpkg-multi-instance buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync merge-wait multilib-strict network-sandbox news parallel-fetch pid-sandbox pkgdir-index-trusted preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr" FFLAGS="-march=native -O3 -pipe" GENTOO_MIRRORS="http://distfiles.gentoo.org" LANG="en_US.utf8" LD="ld.lld" LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--as-needed" LEX="flex" MAKEOPTS="-j32" NM="llvm-nm" OBJCOPY="llvm-objcopy" OBJDUMP="llvm-objdump" 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" RANLIB="llvm-ranlib" READELF="llvm-readelf" SHELL="/bin/zsh" STRINGS="llvm-strings" STRIP="llvm-strip" USE="X a52 aac acl acpi alsa amd64 branding bzip2 cairo cdda cdr cet clang cleartype corefonts crypt cups dbus dri dts dvd dvdr elogind encode exif flac gdbm gif glamor gpm gtk gui iconv icu ipv6 jpeg kf6compat lcms libnotify libtirpc llvm-libunwind lto mad mng mp3 mp4 mpeg multilib ncurses nls ogg opengl openmp pam pango pcre pdf png policykit ppds qt5 readline sdl seccomp sound spell ssl startup-notification svg test-rust theora tiff truetype udev udisks unicode upower usb vaapi vorbis vpx vulkan wxwidgets x264 xattr xcb xft xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gcc_12" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_anon authn_dbm authn_file authz_dbm authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir env expires ext_filter file_cache filter headers include info log_config logio 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="aes avx avx2 avx512_bf16 avx512_bitalg avx512_vbmi2 avx512_vnni avx512_vpopcntdq avx512bw avx512cd avx512dq avx512f avx512ifma avx512vbmi avx512vl f16c fma3 mmx mmxext pclmul popcnt rdrand sha sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 vpclmulqdq" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 ntrip navcom oceanserver oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 tsip tripmate tnt ublox" INPUT_DEVICES="libinput" KERNEL="linux" L10N="en-US en" LCD_DEVICES="bayrad cfontz glk hd44780 lb216 lcdm001 mtxorb text" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-2" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_12" PYTHON_TARGETS="python3_12" RUBY_TARGETS="ruby31 ruby32" VIDEO_CARDS="amdgpu radeonsi" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipp2p iface geoip fuzzy condition tarpit sysrq proto logmark ipmark dhcpmac delude chaos account" Unset: ARFLAGS, ASFLAGS, CCLD, CONFIG_SHELL, CPPFLAGS, CTARGET, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LFLAGS, LIBTOOL, LINGUAS, MAKE, MAKEFLAGS, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, PYTHONPATH, RUSTFLAGS, SIZE, YACC, YFLAGS
Created attachment 897382 [details] build.log.xz build log
From /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/make-support/failure-logs/support_native_java.base_libjimage_BUILD_LIBJIMAGE_link.cmdline the failed command is: /usr/lib/llvm/18/bin/clang++ -m64 -Wl,-O1 -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,--as-needed -L/var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/modules_libs/java.base -L/var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/modules_libs/java.base/server -shared -Wl,-z,origin -Wl,-rpath,\$ORIGIN -Wl,-soname=libjimage.so --sysroot=/ -o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/modules_libs/java.base/libjimage.so /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/NativeImageBuffer.o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/endian.o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/imageDecompressor.o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/imageFile.o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/jimage.o /var/tmp/portage/dev-java/openjdk-21.0.3_p9/work/jdk21u-jdk-21.0.3-ga/build/linux-x86_64-server-release/support/native/java.base/libjimage/osSupport_unix.o -ljvm -ldl -static-libstdc++ -static-libgcc If the flag '-static-libstdc++' is removed the command succeeds.
The problem is that by default, the package will try to statically link libstdc++ and libgcc regardless of what toolchain you are using. On any clang system using libc++ this does not work. The openjdk ebuilds need fixed to work with clang w/libc++ systems. A libstdc++ check needs added to all of the openjdk ebuilds so they work on all systems: if [[ $(tc-get-cxx-stdlib) == libc++ ]]; then myconf+=( --with-stdc++lib=dynamic ) fi The package will not compile without that configure flag on a clang w/libc++ system. With that configure flag, the package also will no longer try to link libgcc. I'm on a musl, clang-only system and have openjdk 11,17, and 21 compiled on my system. I had to edit ebuilds for compilation to succeed, including the above flag. I don't know what the user patch you are using but you shouldn't need user patches to get the package to build.
Version 21.0.3_p9 is already gone. Could you please create a PR to be tested/merged before the next version bump?