Building graalvm8 fails with "unable to load native library" error

Tried installing the clj-kondo package which depends on graalvm8 (version 19.2.1) and while building graalvm I get this error

[project jdk.vm.ci.hotspot.jfr was removed as dependency JFR is missing]
[project com.oracle.mxtool.junit.jdk9 was removed as JDK 9 is not available]
[jdk.vm.ci.hotspot.jfr was removed from distribution JVMCI_HOTSPOT]
[com.oracle.mxtool.junit.jdk9 was removed from distribution JUNIT_TOOL]
Traceback (most recent call last):
  File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/internal_mx.py", line 19173, in <module>
    main()
  File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/internal_mx.py", line 19154, in main
    retcode = c(command_args)
  File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/mx_commands.py", line 147, in __call__
    return self.command_function(*args, **kwargs)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1067, in run_vm
    jdk = get_jvmci_jdk(vmbuild=vmbuild)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1613, in get_jvmci_jdk
    jdk = JVMCI8JDKConfig(vmbuild)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1562, in __init__
    mx.JDKConfig.__init__(self, jdkDir, tag=_JVMCI_JDK_TAG)
  File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/internal_mx.py", line 12580, in __init__
    raise JDKConfigException('{}: {}'.format(e.returncode, e.output))
__main__.JDKConfigException: 1: Error occurred during initialization of VM
Unable to load native library: /build/source/openjdk1.8.0_265/linux-amd64/product/jre/lib/amd64/libjava.so: undefined symbol: JVM_BeforeHalt, version SUNWprivate_1.1

EDIT: Seems like the hydra build is failing with the same error

same problem on MacOS, looking for a solution as well

Odd;
I checked out master of nixpkgs and tried to biuld jvmci8 which is the failing attribute.

nix-build . -A jvmci8

Which failed with the same error you listed

 File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/mx_commands.py", line 147, in __call__
    return self.command_function(*args, **kwargs)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1067, in run_vm
    jdk = get_jvmci_jdk(vmbuild=vmbuild)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1613, in get_jvmci_jdk
    jdk = JVMCI8JDKConfig(vmbuild)
  File "/build/source/mx.jvmci/mx_jvmci.py", line 1562, in __init__
    mx.JDKConfig.__init__(self, jdkDir, tag=_JVMCI_JDK_TAG)
  File "/nix/store/5pl355sksmrbvmb811vdq7bjdzbf684c-mx-5.247.1/bin/internal_mx.py", line 12580, in __init__
    raise JDKConfigException('{}: {}'.format(e.returncode, e.output))
__main__.JDKConfigException: 1: Error occurred during initialization of VM
Unable to load native library: /build/source/openjdk1.8.0_265/linux-amd64/product/jre/lib/amd64/libjava.so: undefined symbol: JVM_BeforeHalt, version SUNWprivate_1.1

builder for '/nix/store/vbsbmmb3nphgppj16nq0p3n8b8bpplzb-jvmci-19.3-b05.drv' failed with exit code 1
error: build of '/nix/store/vbsbmmb3nphgppj16nq0p3n8b8bpplzb-jvmci-19.3-b05.drv' failed

For reference (or anyone else who wants to help debug this); I also found libjava.so in my /nix/store at the same version openjdk1.8.0_265; and the symbol does not exist (undefined)

❯ nm -gD /nix/store/yrd7p07f7y46gcpha3yw22icdc6hhkf9-openjdk-8u265-ga/lib/openjdk/jre/lib/amd64/libjava.so \
| grep JVM_BeforeHalt

U JVM_BeforeHalt

Hey!
I looked more into this with a friend (@markrwilliams) – and we made really good progress but I didn’t have time to finish it.

Good news: I know the bug and what you have to do to fix it.
Bad news: Can you do it? I spent all my available hours today on it.

Problem

jvm-ci is a replacement for the OpenJDK HotSpot that is pluggable.

A somewhat recent version of JDK8 included a new introduced symbol BeforeHalt which was not present on the jvm-ci library libjvm.so. This resulted in that awesome error you saw:

undefined symbol: JVM_BeforeHalt, version SUNWprivate_1.1

The jvm-ci library actually mentions which JVM’s it works with in the .hgtags file. At the current version of 19.3-b05 it lists jdk8u262-b09 as the most recent JDK8 version it works with.

❯ cat .hgtags | grep jdk8
...
cf6e3496e19a2957f7d8b28bd0a033cefbf6509f jdk8u262-b09

Solution #1 (easier & more correct)

Include a new JDK8 version in nixpkgs pinned at jdk8u262-b09 and make jvm-ci depend on this version explicitly. This would require making the JDK derivation more general to accept a version & sha256

Solution #2 (Harder)

Try bumping jvm-ci & mx to a more recent version. Newer versions have introduced the BeforeHalt symbol; however I found upgrading jvm-ci & mx challenging.

  1. they move from hg to git
  2. they move from python2 to python3

CC maintainers @volth @hlolli

2 Likes

Is this issue graalvm8: upgrade to 20.0.0 · Issue #83080 · NixOS/nixpkgs · GitHub related ?
This one default graalvm8 build can't find sys/sdt.h · Issue #100021 · NixOS/nixpkgs · GitHub probably is.