rocm-arch / tensorflow-rocm

tensorflow-rocm AUR package
17 stars 12 forks source link

Bazel requires java 11, but this may not be in PATH if another java was installed first. #55

Closed mpeschel10 closed 1 year ago

mpeschel10 commented 1 year ago

By default on Arch, $PATH includes /usr/lib/jvm/default. Since I installed jdk-openjdk before jdk11-openjdk, my default points to java 20:

[mpeschel@suzerain ~]$ ls -l /usr/lib/jvm/default
lrwxrwxrwx 1 root root 15 Jun 29 22:43 /usr/lib/jvm/default -> java-20-openjdk
[mpeschel@suzerain ~]$ java --version
openjdk 20.0.1 2023-04-18
OpenJDK Runtime Environment (build 20.0.1+9)
OpenJDK 64-Bit Server VM (build 20.0.1+9, mixed mode, sharing)

Even though I have java 11 installed, which bazel needs, java 20 is the default. This appears to cause the following error:

[mpeschel@suzerain ~]$ makepkg
...
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
    at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:118)
    at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:111)
    at com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction$ParamFileWriter.writeOutputFile(ParameterFileWriteAction.java:170)
    at com.google.devtools.build.lib.exec.FileWriteStrategy.beginWriteOutputToFile(FileWriteStrategy.java:58)
    at com.google.devtools.build.lib.analysis.actions.FileWriteActionContext.beginWriteOutputToFile(FileWriteActionContext.java:49)
    at com.google.devtools.build.lib.analysis.actions.AbstractFileWriteAction.beginExecution(AbstractFileWriteAction.java:66)
    at com.google.devtools.build.lib.actions.Action.execute(Action.java:133)
    at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:907)
    at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1076)
    at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1031)
    at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:152)
    at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:91)
    at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:492)
    at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:856)
    at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:349)
    at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:169)
    at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:590)
    at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
    at java.base/java.lang.Thread.run(Thread.java:1623)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @63be40d8
    at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:387)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:363)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:311)
    at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:192)
    at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:185)
    at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:75)
    at com.google.devtools.build.lib.unsafe.StringUnsafe.initInstance(StringUnsafe.java:56)
    at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:37)
    ... 21 more
==> ERROR: A failure occurred in build().
    Aborting...

This issue can be fixed by putting java 11 first in PATH:

[mpeschel@suzerain ~]$ export PATH="/usr/lib/jvm/java-11-openjdk/bin:$PATH"
[mpeschel@suzerain ~]$ makepkg
...
A new, different error

Therefore, this pull request adds PATH="/usr/lib/jvm/java-11-openjdk/bin:$PATH" to PKGBUILD. I also remembered to bump pkgrel and .SRCINFO!

lubosz commented 1 year ago

FWIW Upstream Issue in Bazel: https://github.com/bazelbuild/bazel/issues/15531#issuecomment-1146666693

Doing the workaround of setting java 11 manually since 2022, would be great to have this in the PKGBUILD.

acxz commented 1 year ago

Hey @mpeschel10 this is a great idea. Let's loop in the related issue this PR closes. patches #22