Closed Bug 1663837 Opened 5 years ago Closed 5 years ago

Arch Linux: handle java8 being non-default

Categories

(Firefox Build System :: Bootstrap Configuration, defect, P3)

Other
Linux
defect

Tracking

(firefox82 fixed)

RESOLVED FIXED
82 Branch
Tracking Status
firefox82 --- fixed

People

(Reporter: mt, Assigned: mhentges)

References

Details

(Keywords: in-triage)

Attachments

(4 files)

I have jdk10-openjdk installed (for some reason I can't remember) on my machine, so when bootstrap installs java 8 it doesn't change the version of java that /usr/bin/java points to. The result is that bootstrap fails.

One option here is to set the default, but that is pretty disruptive and likely unwanted (java 8 is old):

sudo archlinux-java set java-8-openjdk

It might be better to overwrite JAVA_HOME to /usr/lib/jvm/java-8-openjdk if java is installed manually. This appears to work so far (the NDK download is currently eating the remainder of my download quota for the month). I don't know how to make that stick for future invocations of mach though, or I'd provide a patch.

Severity: -- → S3
Keywords: in-triage
Priority: -- → P3
Assignee: nobody → mhentges
Status: NEW → ASSIGNED

When multiple java versions are in use, some OSes have a mechanism to
change the "default"/system Java.
This can cause unexpected build failures if the system Java changes.
So, in bootstrap, if the Java version found is valid, then its path
should be encoded into mozconfig.

Pushed by mhentges@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7ed098e08991 bootstrap should store java path in mozconfig r=firefox-build-system-reviewers,rstewart
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch

I'm on Fedora 32 and hit this while running mach bootstap for android this morning.

Executing as root: sudo dnf install java-1.8.0-openjdk-devel wget ncurses-compat-libs
Last metadata expiration check: 0:49:43 ago on Fri 18 Sep 2020 06:46:30 AM PDT.
Package java-1.8.0-openjdk-devel-1:1.8.0.265.b01-1.fc32.x86_64 is already installed.
...
Exception: The "java" and "jarsigner" binaries on the PATH are currently coming from two different JDKs. Please resolve this, or explicitly set JAVA_HOME.

As far as I can tell, I don't have multiple JDKs installed.

$ which java
/usr/bin/java

$ which jarsigner
/usr/bin/jarsigner

$ find /usr -name jarsigner 2> /dev/null | xargs ls -la
lrwxrwxrwx. 1 root root    27 Aug  4 06:42 /usr/bin/jarsigner -> /etc/alternatives/jarsigner
-rwxr-xr-x. 1 root root 18816 Jul 27 20:05 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/jarsigner
-rw-r--r--. 1 root root  1661 Sep 21  2017 /usr/share/bash-completion/completions/jarsigner
$ ls -la /etc/alternatives/jarsigner
lrwxrwxrwx. 1 root root 73 Aug  4 06:42 /etc/alternatives/jarsigner -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/jarsigner

Fwiw, $ export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64 fixed this for me.

Hmm, I'm guessing that perhaps your /etc/alternatives/[java|jarsigner] are pointing to different JDKs?

Can you run the following for me?

$ realpath /usr/bin/jarsigner # based on your comment, this'll probably go to that 1.8.0 JDK
$ realpath /usr/bin/java
Flags: needinfo?(bob)
$ realpath /usr/bin/jarsigner
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/jarsigner

$ realpath /usr/bin/java
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/jre/bin/java
Flags: needinfo?(bob)

Hey, I've made a small local patch to print some debug log information.
Can you download this file and run

$ hg import --no-commit $path_to_downloaded_patch_file
$ ./mach bootstrap # Select an Android-y option so the `ensure_java()` function is run

Thanks for reporting this, I'm really surprised you're running into an error here :)

Flags: needinfo?(bob)
which(java) = /usr/bin/java
which(jarsigner) = /usr/bin/jarsigner
jdk_bin_dir = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin
os.path.realpath(java) = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/jre/bin/java
which(java, path=jdk_bin_dir) = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java
os.path.realpath(which(java, path=jdk_bin_dir)) = /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java
...
Exception: The "java" and "jarsigner" binaries on the PATH are currently coming from two different JDKs. Please resolve this, or explicitly set JAVA_HOME.
Flags: needinfo?(bob)

Woah, does your distro not symlink $JDK/bin/java => $JDK/jre/bin/java?
Can you do the following for me?

$ /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java
$ /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/jre/bin/java
Flags: needinfo?(bob)
Attached file java output
Flags: needinfo?(bob)
$ ls -la /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/jre/bin/java
-rwxr-xr-x. 1 root root 18688 Jul 27 20:05 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/bin/java
-rwxr-xr-x. 1 root root 18688 Jul 27 20:05 /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.265.b01-1.fc32.x86_64/jre/bin/java

I'm so sorry, I was multitasking and missed the first part - I'm trying to find out if they're separate binaries or if one links to the other. There should be an ls -al in front 😓

EDIT - it looks like you were one step ahead of me and provided that info, thanks!
They don't link to each other, interesting. I'll create a new bug and resolve this. Thanks again!

Regressions: 1666032

In the build process, there's two ways that java is used:

  • From the path
  • From the java-bin-path specified in the mozconfig

Before, to assert that both "java" usages would be consistent, the
implementation assumed that there was only a single "java" binary
per-JDK-version, and all duplicate "binaries" were symlinks to the
original.

However, in Fedora, it has two identical full binaries: one in
$JDK/bin, and one in $JDK/jre/bin. The symlink theory was incorrect.

So instead, we can assert that both "java" usages are consistent
by checking their versions and asserting that they are equivalent.

Pushed by mhentges@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/fded12622108 ensure java from PATH == java from JDK_BIN_DIR r=firefox-build-system-reviewers,rstewart

Backed out changeset fded12622108 (bug 1663837) as requested by dev. CLOSED TREE

Backout:
https://hg.mozilla.org/integration/autoland/rev/482e3a1e39cc2b3b824dbc459c6aad260a5f9562

Flags: needinfo?(mhentges)

Thanks! The patch has moved to 1666032, as expected :)

Flags: needinfo?(mhentges)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: