perf build: Fix detection of latest openjdk
Namhyung Kim
maintainerPATCH 1/1 perf build: Fix detection of latest openjdk
My fedora system fails to find openjdk even if I installed the 'java-latest-openjdk-devel' package as in the warning message. It turns out that the directory path is different than what's in the output of alternatives.
Makefile.config:1122: No openjdk development package found, please install JDK package,
e.g. openjdk-8-jdk, java-latest-openjdk-devel
The Makefile.config has the rule like below to detect the installed directory with a version number.
$ alternatives --display java | tail -1 | cut -d ' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g' /usr/lib/jvm/java-21-openjdk
This is to find a directory where the header file (jvmti.h) is like /usr/lib/jvm/java-21-openjdk/include/jvmti.h. However the header file was in a different directory.
$ rpm -ql java-latest-openjdk-devel | grep jvmti.h /usr/lib/jvm/java-latest-openjdk/include/jvmti.h
It seems the directory name is fixed to provide the latest version. Let's check the directory name before using the parsed name. With this change, the warning is gone on my system.
--- tools/perf/Makefile.config | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
tools/perf/Makefile.config +6 -2
@@ -1096,8 +1096,12 @@ ifndef NO_JVMTI ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') else - ifneq (,$(wildcard /usr/sbin/alternatives)) - JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g') + ifneq (,$(wildcard /usr/lib/jvm/java-latest-openjdk/include)) + JDIR=/usr/lib/jvm/java-latest-openjdk + else + ifneq (,$(wildcard /usr/sbin/alternatives)) + JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g') + endif endif endif ifndef JDIR
Signature · 1 line
2.53.0
Arnaldo Carvalho de Melo
maintainerQuoted 18 lines · Namhyung Kim
My fedora system fails to find openjdk even if I installed the 'java-latest-openjdk-devel' package as in the warning message. It turns out that the directory path is different than what's in the output of alternatives.
Makefile.config:1122: No openjdk development package found, please install JDK package,
e.g. openjdk-8-jdk, java-latest-openjdk-develThe Makefile.config has the rule like below to detect the installed directory with a version number.
$ alternatives --display java | tail -1 | cut -d ' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g' /usr/lib/jvm/java-21-openjdkThis is to find a directory where the header file (
jvmti.h) is like/usr/lib/jvm/java-21-openjdk/include/jvmti.h. However the header file was in a different directory.
Quoted 6 lines
$ rpm -ql java-latest-openjdk-devel | grep jvmti.h /usr/lib/jvm/java-latest-openjdk/include/jvmti.hIt seems the directory name is fixed to provide the latest version. Let's check the directory name before using the parsed name. With this change, the warning is gone on my system.
Interesting, I'm not noticing this on Fedora rawhide (44), I created a fresh toolbox container with fedora:rawhide and had, as you, this:
⬢ [acme@toolbx perf-tools-next]$ m
make: Entering directory '/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j32' parallel build
Warning: Kernel ABI header differences:
diff -u tools/arch/x86/include/uapi/asm/svm.h arch/x86/include/uapi/asm/svm.h
Makefile.config:1070: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:1122: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-latest-openjdk-devel
Then I just followed the suggestion and did a:
$ sudo dnf install java-latest-openjdk-devel
And after that the 1122 warning vanished and:
⬢ [acme@toolbx perf-tools-next]$ ls -la /tmp/build/perf-tools-next/feature/test-jvmti*
-rwxr-xr-x. 1 acme acme 12384 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.bin -rwxr-xr-x. 1 acme acme 12392 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.bin -rw-r--r--. 1 acme acme 1188 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.d -rw-r--r--. 1 acme acme 0 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.make.output -rw-r--r--. 1 acme acme 1122 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.d -rw-r--r--. 1 acme acme 0 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.make.output
⬢ [acme@toolbx perf-tools-next]$ cat /tmp/build/perf-tools-next/feature/test-jvmti.make.output ⬢ [acme@toolbx perf-tools-next]$
⬢ [acme@toolbx perf-tools-next]$ alternatives --display java | tail -1 | cut -d ' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g' /usr/lib/jvm/java-latest-openjdk
⬢ [acme@toolbx perf-tools-next]$
⬢ [acme@toolbx perf-tools-next]$ alternatives --display java
java - status is auto.
link currently points to /usr/lib/jvm/java-latest-openjdk/bin/java/usr/lib/jvm/java-latest-openjdk/bin/java - priority 1
follower jre: /usr/lib/jvm/java-latest-openjdk
follower alt-java: /usr/lib/jvm/java-latest-openjdk/bin/alt-java follower jcmd: /usr/lib/jvm/java-latest-openjdk/bin/jcmd
follower keytool: /usr/lib/jvm/java-latest-openjdk/bin/keytool follower rmiregistry: /usr/lib/jvm/java-latest-openjdk/bin/rmiregistry follower java.1.gz: /usr/lib/jvm/java-latest-openjdk/man/man1/java.1 follower alt-java.1.gz: /usr/lib/jvm/java-latest-openjdk/man/man1/alt-java.1 follower jcmd.1.gz: /usr/lib/jvm/java-latest-openjdk/man/man1/jcmd.1 follower keytool.1.gz: /usr/lib/jvm/java-latest-openjdk/man/man1/keytool.1 follower rmiregistry.1.gz: /usr/lib/jvm/java-latest-openjdk/man/man1/rmiregistry.1
Current `best' version is /usr/lib/jvm/java-latest-openjdk/bin/java.
⬢ [acme@toolbx perf-tools-next]$
- Arnaldo
Quoted 26 lines
Signed-off-by Namhyung Kim <[email protected]>--- tools/perf/Makefile.config | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)tools/perf/Makefile.config +6
-2@@ -1096,8 +1096,12 @@ ifndef NO_JVMTI ifneq (,$(wildcard /usr/sbin/update-java-alternatives)) JDIR=$(shell /usr/sbin/update-java-alternatives -l | head -1 | awk '{print $$3}') else - ifneq (,$(wildcard /usr/sbin/alternatives)) - JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g') + ifneq (,$(wildcard /usr/lib/jvm/java-latest-openjdk/include)) + JDIR=/usr/lib/jvm/java-latest-openjdk + else + ifneq (,$(wildcard /usr/sbin/alternatives)) + JDIR=$(shell /usr/sbin/alternatives --display java | tail -1 | cut -d' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g') + endif endif endif ifndef JDIRSignature · 1 line
2.53.0
Namhyung Kim
maintainerQuoted 58 lines · Arnaldo Carvalho de Melo
Quoted 18 lines · Namhyung Kim
My fedora system fails to find openjdk even if I installed the 'java-latest-openjdk-devel' package as in the warning message. It turns out that the directory path is different than what's in the output of alternatives.
Makefile.config:1122: No openjdk development package found, please install JDK package,
e.g. openjdk-8-jdk, java-latest-openjdk-develThe Makefile.config has the rule like below to detect the installed directory with a version number.
$ alternatives --display java | tail -1 | cut -d ' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g' /usr/lib/jvm/java-21-openjdkThis is to find a directory where the header file (
jvmti.h) is like/usr/lib/jvm/java-21-openjdk/include/jvmti.h. However the header file was in a different directory.Quoted 6 lines
$ rpm -ql java-latest-openjdk-devel | grep jvmti.h /usr/lib/jvm/java-latest-openjdk/include/jvmti.hIt seems the directory name is fixed to provide the latest version. Let's check the directory name before using the parsed name. With this change, the warning is gone on my system.
Interesting, I'm not noticing this on Fedora rawhide (44), I created a fresh toolbox container with fedora:rawhide and had, as you, this:
⬢ [acme@toolbx perf-tools-next]$ m
make: Entering directory '/home/acme/git/linux/tools/perf'
BUILD: Doing 'make -j32' parallel build
Warning: Kernel ABI header differences:
diff -utools/arch/x86/include/uapi/asm/svm.harch/x86/include/uapi/asm/svm.h
Makefile.config:1070: No libbabeltrace found, disables 'perf data' CTF format support, please install libbabeltrace-dev[el]/libbabeltrace-ctf-dev Makefile.config:1122: No openjdk development package found, please install JDK package, e.g. openjdk-8-jdk, java-latest-openjdk-develThen I just followed the suggestion and did a:
$ sudo dnf install java-latest-openjdk-develAnd after that the 1122 warning vanished and:
⬢ [acme@toolbx perf-tools-next]$ ls -la
/tmp/build/perf-tools-next/feature/test-jvmti*(quoted diff) +0
-6-rwxr-xr-x. 1 acme acme 12384 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.bin -rwxr-xr-x. 1 acme acme 12392 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.bin -rw-r--r--. 1 acme acme 1188 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.d -rw-r--r--. 1 acme acme 0 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti-cmlr.make.output -rw-r--r--. 1 acme acme 1122 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.d -rw-r--r--. 1 acme acme 0 Apr 7 09:14 /tmp/build/perf-tools-next/feature/test-jvmti.make.output⬢ [acme@toolbx perf-tools-next]$ cat
/tmp/build/perf-tools-next/feature/test-jvmti.make.output⬢ [acme@toolbx perf-tools-next]$⬢ [acme@toolbx perf-tools-next]$ alternatives --display java | tail -1 | cut -d ' ' -f 5 | sed -e 's%/jre/bin/java.%%g' -e 's%/bin/java.%%g'
/usr/lib/jvm/java-latest-openjdk
⬢ [acme@toolbx perf-tools-next]$
Quoted 16 lines
⬢ [acme@toolbx perf-tools-next]$ alternatives --display java
java - status is auto.
link currently points to/usr/lib/jvm/java-latest-openjdk/bin/java/usr/lib/jvm/java-latest-openjdk/bin/java- priority 1
follower jre:/usr/lib/jvm/java-latest-openjdk
follower alt-java:/usr/lib/jvm/java-latest-openjdk/bin/alt-javafollower jcmd:/usr/lib/jvm/java-latest-openjdk/bin/jcmd
follower keytool:/usr/lib/jvm/java-latest-openjdk/bin/keytoolfollower rmiregistry:/usr/lib/jvm/java-latest-openjdk/bin/rmiregistryfollower java.1.gz:/usr/lib/jvm/java-latest-openjdk/man/man1/java.1follower alt-java.1.gz:/usr/lib/jvm/java-latest-openjdk/man/man1/alt-java.1follower jcmd.1.gz:/usr/lib/jvm/java-latest-openjdk/man/man1/jcmd.1follower keytool.1.gz:/usr/lib/jvm/java-latest-openjdk/man/man1/keytool.1follower rmiregistry.1.gz:/usr/lib/jvm/java-latest-openjdk/man/man1/rmiregistry.1
Current `best' version is/usr/lib/jvm/java-latest-openjdk/bin/java.
⬢ [acme@toolbx perf-tools-next]$
Thanks for checking this. Looks like a local issue on my system. I've updated the alternatives to point to the latest version.
Thanks,
Namhyung