Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Build failure] FreeBSD 14-CURRENT/Gentoo Linux amd64 with OpenJDK 17.0 and 18.0 #17103

Open
5 tasks
yesudeep opened this issue Jan 1, 2023 · 21 comments
Open
5 tasks
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug

Comments

@yesudeep
Copy link
Contributor

yesudeep commented Jan 1, 2023

Description of the bug:

Bazel release version 6.0.0 fails to build on FreeBSD 14-CURRENT amd64 with the following error:

Sun Jan 01 03:13 PM yesudeep at mongolia running bash5.2 on FreeBSD 14.0-CURRENT amd64
in ~/src/tmp6   master
>> env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh
🍃  Building Bazel from scratch......
🍃  Building Bazel with Bazel.
.OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
DEBUG: /tmp/bazel_3aV1Io3I/out/external/build_bazel_rules_nodejs/index.bzl:122:10: WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.
INFO: Analyzed target //src:bazel_nojdk (383 packages loaded, 10302 targets configured).
INFO: Found 1 target...
INFO: From Generating Descriptor Set proto_library @com_github_cncf_udpa//xds/service/orca/v3:pkg:
xds/service/orca/v3/orca.proto:14:1: warning: Import validate/validate.proto is unused.
INFO: From Compiling src/core/lib/security/transport/client_auth_filter.cc:
external/com_github_grpc_grpc/src/core/lib/security/transport/client_auth_filter.cc:153:8: warning: initialized lambda captures are a C++14 extension [-Wc++14-extensions]
      [call_args =
       ^
1 warning generated.
INFO: From Compiling src/core/ext/filters/fault_injection/fault_injection_filter.cc:
external/com_github_grpc_grpc/src/core/ext/filters/fault_injection/fault_injection_filter.cc:138:8: warning: initialized lambda captures are a C++14 extension [-Wc++14-extensions]
      [decision = std::move(decision)]() { return decision.MaybeAbort(); },
       ^
1 warning generated.
INFO: From Compiling src/core/ext/filters/channel_idle/channel_idle_filter.cc:
external/com_github_grpc_grpc/src/core/ext/filters/channel_idle/channel_idle_filter.cc:200:8: warning: initialized lambda captures are a C++14 extension [-Wc++14-extensions]
      [decrementer = Decrementer(this),
       ^
external/com_github_grpc_grpc/src/core/ext/filters/channel_idle/channel_idle_filter.cc:201:8: warning: initialized lambda captures are a C++14 extension [-Wc++14-extensions]
       next = next_promise_factory(std::move(call_args))]() mutable
       ^
2 warnings generated.
[1,294 / 1,313] [Prepa] @bazel_tools//third_party/ijar:zip
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
        at com.google.devtools.build.lib.actions.ParameterFile.writeContentLatin1(ParameterFile.java:141)
        at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:120)
        at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:112)
        at com.google.devtools.build.lib.actions.CommandLines$ParamFileActionInput.writeTo(CommandLines.java:319)
        at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.start(LocalSpawnRunner.java:368)
        at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.runOnce(LocalSpawnRunner.java:258)
        at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.run(LocalSpawnRunner.java:229)
        at com.google.devtools.build.lib.exec.local.LocalSpawnRunner.exec(LocalSpawnRunner.java:170)
        at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:299)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
        at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
        at com.google.devtools.build.lib.actions.SpawnStrategy.beginExecution(SpawnStrategy.java:47)
        at com.google.devtools.build.lib.exec.SpawnStrategyResolver.beginExecution(SpawnStrategyResolver.java:64)
        at com.google.devtools.build.lib.analysis.actions.SpawnAction.beginExecution(SpawnAction.java:352)
        at com.google.devtools.build.lib.actions.Action.execute(Action.java:133)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:940)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1107)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1065)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
        at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:507)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:826)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:571)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
        at java.base/java.lang.Thread.run(Thread.java:833)
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 @5b7d6536
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
        at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:191)
        at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:184)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:61)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:36)
        ... 29 more

ERROR: Could not build Bazel

System information:

>> uname -mrs
FreeBSD 14.0-CURRENT amd64

>> echo $JAVA_HOME
/usr/local/openjdk18

>> java --version
openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment (build 18.0.2+9-1)
OpenJDK 64-Bit Server VM (build 18.0.2+9-1, mixed mode, sharing)

>> java --version
openjdk 17.0.5 
OpenJDK Runtime Environment (build 18.0.2+9-1)
OpenJDK 64-Bit Server VM (build 18.0.2+9-1, mixed mode, sharing)

>> g++ --version
g++ (FreeBSD Ports Collection) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Release file used: https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-dist.zip

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. Download https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-dist.zip
  2. Run unzip bazel-6.0.0-dist.zip
  3. Run env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh

Which operating system are you running Bazel on?

FreeBSD 14-CURRENT amd64

What is the output of bazel info release?

release 5.3.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

Not a git repository.

Have you found anything relevant by searching the web?

Possible related information:

Any other information, logs, or outputs that you want to share?

No response

@yesudeep yesudeep changed the title [Build failure] FreeBSD 14-CURRENT amd64 with OpenJDK 18.0 [Build failure] FreeBSD 14-CURRENT amd64 with OpenJDK 17.0 and 18.0 Jan 2, 2023
@yesudeep
Copy link
Contributor Author

yesudeep commented Jan 2, 2023

Build works with OpenJDK 11.0

>> java --version
openjdk 11.0.17 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-1)
OpenJDK 64-Bit Server VM (build 11.0.17+8-1, mixed mode)

Output:

Target //src:bazel_nojdk up-to-date:
  bazel-bin/src/bazel_nojdk
INFO: Elapsed time: 1473.097s, Critical Path: 173.11s
INFO: 3208 processes: 58 internal, 2363 local, 787 worker.
INFO: Build completed successfully, 3208 total actions
DEBUG: /tmp/bazel_9r4S9X9E/out/external/build_bazel_rules_nodejs/index.bzl:122:10: WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.

Build successful! Binary is here: /home/yesudeep/src/tmp6/output/bazel

OpenJDK 17.0 and 18.0 may break building bazel so leaving this open.

@sgowroji sgowroji added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged type: bug labels Jan 2, 2023
@meteorcloudy meteorcloudy added P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Rules-Java Issues for Java rules and removed untriaged team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website labels Jan 10, 2023
@meteorcloudy
Copy link
Member

/cc @cushon @comius Does Bazel support openjdk 17 and 18?

@cushon
Copy link
Contributor

cushon commented Jan 10, 2023

I agree this is supposed to work, and that it was supposed to be fixed by 81e368f

What is the output of bazel info release?
release 5.3.0

Was this tested with 6.0.0, or with 5.3.0?

@yesudeep
Copy link
Contributor Author

yesudeep commented Jan 10, 2023

Was this tested with 6.0.0, or with 5.3.0?

That is the version of bazel that ships with FreeBSD's pkg and was installed on the system.
However, I built the bazel-*-dist.zip file from source by bootstrapping bazel after a failed attempt
at building it using bazel itself (which didn't work for some other reason IIRC that I could recheck).

@yesudeep
Copy link
Contributor Author

yesudeep commented Jan 10, 2023

Just rechecked the bootstrapped build. Same error with OpenJDK 18:

Tue Jan 10 08:53 AM yesudeep at mongolia running bash5.2 on FreeBSD 14.0-CURRENT amd64
in ~/src/bazel-release   main 
>> env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" ./compile.sh
🍃  Building Bazel from scratch......
🍃  Building Bazel with Bazel.
.OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
DEBUG: /tmp/bazel_sswEAuOv/out/external/build_bazel_rules_nodejs/index.bzl:122:10: WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.
INFO: Analyzed target //src:bazel_nojdk (383 packages loaded, 10302 targets configured).
INFO: Found 1 target...
INFO: From Generating Descriptor Set proto_library @com_github_cncf_udpa//xds/service/orca/v3:pkg:
xds/service/orca/v3/orca.proto:14:1: warning: Import validate/validate.proto is unused.
[555 / 579] 4 actions, 2 running
    Compiling src/main/tools/process-tools.cc; 1s local
    Linking external/bazel_tools/third_party/ijar/zipper [for tool]; 0s local
    [Sched] Linking external/com_google_protobuf/libprotobuf.a; 31s
    [Sched] Linking external/com_google_protobuf/libprotobuf_lite.a
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
	at com.google.devtools.build.lib.actions.ParameterFile.writeContentLatin1(ParameterFile.java:141)
	at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:120)
	at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:112)
	at com.google.devtools.build.lib.actions.CommandLines$ParamFileActionInput.writeTo(CommandLines.java:319)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.start(LocalSpawnRunner.java:368)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.runOnce(LocalSpawnRunner.java:258)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner$SubprocessHandler.run(LocalSpawnRunner.java:229)
	at com.google.devtools.build.lib.exec.local.LocalSpawnRunner.exec(LocalSpawnRunner.java:170)
	at com.google.devtools.build.lib.exec.SpawnRunner.execAsync(SpawnRunner.java:299)
	at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:152)
	at com.google.devtools.build.lib.exec.AbstractSpawnStrategy.exec(AbstractSpawnStrategy.java:112)
	at com.google.devtools.build.lib.actions.SpawnStrategy.beginExecution(SpawnStrategy.java:47)
	at com.google.devtools.build.lib.exec.SpawnStrategyResolver.beginExecution(SpawnStrategyResolver.java:64)
	at com.google.devtools.build.lib.analysis.actions.SpawnAction.beginExecution(SpawnAction.java:352)
	at com.google.devtools.build.lib.actions.Action.execute(Action.java:133)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$5.execute(SkyframeActionExecutor.java:940)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1107)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1065)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:507)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:826)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:571)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
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 @59476e33
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:191)
	at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:184)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:61)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:36)
	... 29 more

ERROR: Could not build Bazel

BTW, bazel continues to work fine with OpenJDK 18 after being built using OpenJDK 11.

And attempting to build bazel using bazel itself generates

Tue Jan 10 09:06 AM yesudeep at mongolia running bash5.2 on FreeBSD 14.0-CURRENT amd64
in ~/src/bazel   master 
>> bazel build //src:bazel-dev
Starting local Bazel server and connecting to it...
INFO: Repository zstd-jni instantiated at:
  /usr/home/yesudeep/src/bazel/WORKSPACE:217:18: in <toplevel>
  /usr/home/yesudeep/src/bazel/distdir.bzl:94:17: in dist_http_archive
Repository rule http_archive defined at:
  /usr/home/yesudeep/src/bazel/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
INFO: Repository remote_java_tools instantiated at:
  /DEFAULT.WORKSPACE.SUFFIX:363:6: in <toplevel>
  /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/bazel_tools/tools/build_defs/repo/utils.bzl:233:18: in maybe
Repository rule http_archive defined at:
  /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/bazel_tools/tools/build_defs/repo/http.bzl:372:31: in <toplevel>
INFO: repository @remote_java_tools' used the following cache hits instead of downloading the corresponding file.
 * Hash '5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d' for https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip
If the definition of 'repository @remote_java_tools' was updated, verify that the hashes were also updated.
INFO: Repository openjdk_linux_vanilla instantiated at:
  /usr/home/yesudeep/src/bazel/WORKSPACE:148:15: in <toplevel>
  /usr/home/yesudeep/src/bazel/distdir.bzl:112:14: in dist_http_file
Repository rule http_file defined at:
  /usr/home/yesudeep/src/bazel/tools/build_defs/repo/http.bzl:466:28: in <toplevel>
ERROR: /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/rules_jvm_external/private/tools/java/rules/jvm/external/jar/BUILD:3:12: While resolving toolchains for target @rules_jvm_external//private/tools/java/rules/jvm/external/jar:AddJarManifestEntry: No matching toolchains found for types @bazel_tools//tools/jdk:runtime_toolchain_type.
To debug, rerun with --toolchain_resolution_debug='@bazel_tools//tools/jdk:runtime_toolchain_type'
If platforms or toolchains are a new concept for you, we'd encourage reading https://bazel.build/concepts/platforms-intro.
ERROR: Analysis of target '//src:bazel-dev' failed; build aborted: 
INFO: Elapsed time: 11.199s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (322 packages loaded, 4809 targets configured)
    Fetching /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/remote_java_tools; Extracting java_tools-v11.9.zip
    Fetching https://mirror.bazel.build/cdn.azul.com/zulu/bin/zulu17.38.21-ca-jdk17.0.5-linux_x64.tar.gz; 26.6 MiB (27,859,757B)
    Fetching /usr/home/yesudeep/.cache/bazel/_bazel_yesudeep/7192245415774483c6c2b1470ca28bf8/external/zstd-jni; Extracting v1.5.2-3.zip

@yesudeep yesudeep changed the title [Build failure] FreeBSD 14-CURRENT amd64 with OpenJDK 17.0 and 18.0 [Build failure] FreeBSD 14-CURRENT/Gentoo Linux amd64 with OpenJDK 17.0 and 18.0 Jan 29, 2023
@yesudeep
Copy link
Contributor Author

yesudeep commented Jan 29, 2023

This is not specific to FreeBSD as I previously thought. Bazel doesn't appear to build on Gentoo Linux using OpenJDK 17.0 either:

❯ bin/install_bazel_from_source
... elided ...
Building bazel...
🍃  Building Bazel from scratch......
🍃  Building Bazel with Bazel.
.OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
DEBUG: /tmp/bazel_dIvGzxkR/out/external/build_bazel_rules_nodejs/index.bzl:122:10: WARNING: check_rules_nodejs_version has been removed. This is a no-op, please remove the call.
INFO: Analyzed target //src:bazel_nojdk (383 packages loaded, 10312 targets configured).
INFO: Found 1 target...
[0 / 2] [Prepa] BazelWorkspaceStatusAction stable-status.txt
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.ExceptionInInitializerError
	at com.google.devtools.build.lib.actions.ParameterFile.writeContentLatin1(ParameterFile.java:141)
	at com.google.devtools.build.lib.actions.ParameterFile.writeContent(ParameterFile.java:120)
	at com.google.devtools.build.lib.actions.ParameterFile.writeParameterFile(ParameterFile.java:112)
	at com.google.devtools.build.lib.analysis.actions.ParameterFileWriteAction$ParamFileWriter.writeOutputFile(ParameterFileWriteAction.java:172)
	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:940)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1107)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1065)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.runStateMachine(ActionExecutionState.java:160)
	at com.google.devtools.build.lib.skyframe.ActionExecutionState.getResultOrDependOnFuture(ActionExecutionState.java:93)
	at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor.executeAction(SkyframeActionExecutor.java:507)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:826)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.computeInternal(ActionExecutionFunction.java:323)
	at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.compute(ActionExecutionFunction.java:161)
	at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:571)
	at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)
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 @43c3d622
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
	at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
	at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:188)
	at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:181)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:61)
	at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:36)
	... 22 more

ERROR: Could not build Bazel

Other info

❯ echo $JAVA_HOME
/usr/lib/jvm/openjdk-bin-17

❯ java --version
openjdk 17.0.6 2023-01-17
OpenJDK Runtime Environment Temurin-17.0.6+10 (build 17.0.6+10)
OpenJDK 64-Bit Server VM Temurin-17.0.6+10 (build 17.0.6+10, mixed mode, sharing)

❯ uname -mrs
Linux 5.15.88-gentoo-dist x86_64

@lima-limon-inc
Copy link

lima-limon-inc commented May 10, 2023

Hi, I am having the same problem with trying to build tensorflow using bazel with open jdk17
Have you found any solution?

OS: Gentoo Linux

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) labels May 10, 2023
@meteorcloudy
Copy link
Member

While upgrading testing platforms for Bazel to ubuntu2204 with JDK 17, we are also encountering this problem:

@lima-limon-inc
Copy link

Switching to Open JDK 11 seems to continue the compilation.
Are there any major problems in using this approach?

@meteorcloudy
Copy link
Member

Are there any major problems in using this approach?

No problem, but eventually we should also support newer JDK versions.

@lima-limon-inc
Copy link

Thank you for the reply 😊

@fmeum
Copy link
Collaborator

fmeum commented May 10, 2023

The version of Bazel used to build (not the version of Bazel that is being built) has to include 81e368f for it to work with JDK 17, so it's expected that 5.3.0 won't work.

@meteorcloudy The CI issue you are facing is a different one, but can probably be fixed along the lines of the commit @cushon and I linked, just with java.lang.invoke instead of java.lang.

@lima-limon-inc
Copy link

lima-limon-inc commented May 10, 2023

81e368f is included in the latest release 6.2.0, right?

@meteorcloudy
Copy link
Member

meteorcloudy commented May 10, 2023

During bootstrapping Bazel, we are running the Bazel server directly without client:

run_bazel_jar $command \
, I guess that's why 81e368f didn't work.

Maybe adding the same flag here could work:

-XX:HeapDumpPath=${OUTPUT_DIR} \

@lima-limon-inc
Copy link

Switching to Open JDK 11 seems to continue the compilation. Are there any major problems in using this approach?

Can confirm, Open JDK indeed worked and tensorflow was compiled correclty (or so I hope 😅 )

@lima-limon-inc
Copy link

New bazel version 6.2.0 compiles correctly with openJDK 17
Tensorflow compiles correctly as well.
Thanks @fmeum !

@lima-limon-inc
Copy link

As of today, version 6.2.0 has been included into Gentoo's main tree!
Thanks for the help!

@yesudeep
Copy link
Contributor Author

yesudeep commented Oct 23, 2023

This still appears to be the case for the aarch64 architecture on the latest version of Ubuntu, which no longer ships with OpenJDK 11, and Debian testing making it hard to bootstrap on those platforms/architectures.

@blackgnezdo
Copy link
Contributor

FWIW, I neutered this code to get past the problem on OpenBSD with jdk-17:

Index: src/main/java/com/google/devtools/build/lib/actions/ParameterFile.java
--- src/main/java/com/google/devtools/build/lib/actions/ParameterFile.java.orig
+++ src/main/java/com/google/devtools/build/lib/actions/ParameterFile.java
@@ -116,11 +116,6 @@ public class ParameterFile {
 
   private static void writeContent(
       OutputStream outputStream, Iterable<String> arguments, Charset charset) throws IOException {
-    if (charset.equals(ISO_8859_1)) {
-      writeContentLatin1(outputStream, arguments);
-    } else if (charset.equals(UTF_8)) {
-      writeContentUtf8(outputStream, arguments);
-    } else {
       // Generic charset support
       OutputStreamWriter out = new OutputStreamWriter(outputStream, charset);
       for (String line : arguments) {
@@ -128,7 +123,6 @@ public class ParameterFile {
         out.write('\n');
       }
       out.flush();
-    }
   }
 
   /**

@rikenm1
Copy link

rikenm1 commented Mar 11, 2024

This still happens with Bazel 6.5.0 with JDK 17. We recently just updated our OpenJDK and we are getting this error now. Everything was building fine with OpenJDK 11 prior.

-Azure Linux

@meteorcloudy
Copy link
Member

Note that we are dropping support for building Bazel with JDK < 21: #21446

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P2 We'll consider working on this in future. (Assignee optional) team-Rules-Java Issues for Java rules type: bug
Projects
None yet
Development

No branches or pull requests

8 participants