-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
toolchain_vanilla
works with locally defined jdk 11, but toolchain_java11
breaks the jdk compiler
#14533
Comments
toolchain_java11
breaks the jdk compilertoolchain_vanilla
works with locally defined jdk 11, but toolchain_java11
breaks the jdk compiler
Bazel was still using JDK 11.0.6 until relatively recently: 698c17a I think you might be encountering this JDK bug, which has the same stack trace, but wasn't fixed until 11.0.7: https://bugs.openjdk.java.net/browse/JDK-8213908 |
Have you considered upgrading to LTS release? It would be much easier to support those.
I think java_toolchain.java_runtime was added in Bazel release > 4.0.0. Can you provide output of
I think Bazel 1.2.1 is using bazel/tools/jdk/BUILD.java_tools Line 62 in 11deef7
Perhaps you can use the output of the query command above to define your own Java toolchain, that's between vanilla and java11? (On the other hand, this is going to be something you'll need to fix again on Bazel upgrade). |
@comius and @cushon thank y'all for responding. And yes, I dont think we have @comius here's the output of that command
Here's the difference between the 2 toolchains: What's interesting is that the vanilla one still appears to use those same tools. Is it the
|
Or do I need to build up our own java_tools zip that we build on our own that uses the JDK we want? |
The non-vanilla toolchain depends on a custom version of javac, those The customized javac is relatively old, and doesn't have a fix for the crash in One of the customizations in that javac version is a bug fix that is needed for Strict Java Deps to work, which is why you get the dependency failure with those flags removed. The 'vanilla' toolchain works with a stock JDK 11 by disabling some of the features that depend on the modified version of javac, including Strict Java Deps. As of JDK 13, Bazel no longer needs any customizations to javac, so we're not using the (I'm not sure what the best solution is for you here, I'm just trying to provide some context.) |
Thanks @cushon for continuing to look.
I'm wondering if we could build our own version of this thing: https://github.com/bazelbuild/bazel/blob/1.2.1/src/main/java/com/google/devtools/build/lib/bazel/rules/java/jdk.WORKSPACE#L230 Using BOTH an updated JDK that we are using and the javac bug fix you mention here. Although, can you give me more insight into how that javac was "patched" with the bug fix? Is that something easily done? I'd love a simpler answer than this, but just seeing if this is even an option to fix it. |
I think the approach you describe is possible but not easy or well documented :( Here are some breadcrumbs:
There's some context about how to build
From #11262 (comment)
So you could apply those patches to JDK 11 and build a custom JDK, or apply them to javac and use The sources for the custom JDK 11 javac Bazel is using are here: https://github.com/google/error-prone-javac/commits/jdk-11.0.3-1 The incantation to build those sources is something like
And then to package that into the
|
Thinking about this a little more, I'm going to see whether it's possible to backport those JDK patches into JDK 11u, which might allow us to drop the |
That would be amazing @cushon |
I backported those fixes to 11u. The next JDK 11u release is scheduled for April 19, 2022, so I set a reminder to follow up then |
Amazing. Thanks @cushon. We'll check back then as well and try with an upgraded jdk. I assume it still means we would make our own toolchain, but just remove the patch-modules? |
I'm going to look at removing the But yes, if you're still on an older version of Bazel at that point, you could update to the latest JDK 11u release and then define custom toolchains that remove all of the |
The javac changes that Bazel depends on are now available in the latest JDK 11 update release. bazelbuild#14533
@cushon Thanks for all of your work on this. I ran our build with a version of 11.0.15 and it worked!! We are hitting one more issue that I'm not sure if you have any insight into that could help. Just a recap, we are still on Bazel 1.2.1. We created our own java toolchain to remove the
So this all works great! But when I try to use
We get an issue with the now private Unsafe
I saw another ticket over there, but for java 9: protocolbuffers/protobuf#4257 Is there something we can do to get this to compile? Something around overriding the protobuf java_toolchain? Or am I doing something wrong with the above redfin_toolchain_java11? |
@james-deee glad to hear 11.0.15 is (mostly) working! You can also remove the entries from
The |
The new binaries are: ``` e064b61d93304012351242bf0823c6a2e41d9e28add7ea7f05378b7243d34247 https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-linux_x64.tar.gz fc7c41a0005180d4ca471c90d01e049469e0614cf774566d4cf383caa29d1a97 https://cdn.azul.com/zulu-embedded/bin/zulu11.56.19-ca-jdk11.0.15-linux_aarch64.tar.gz 9750e11721282a9afd18a07743f19c699b2b71ce20d02f3f0a906088b9ae6d9a https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1+1/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.14.1_1.tar.gz 79a27a4dc23dff38a5c21e5ba9b7efcf0aa5e14ace1a3b19bec53e255c487521 https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.14.1+1/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.14.1_1.tar.gz 2614e5c5de8e989d4d81759de4c333aa5b867b17ab9ee78754309ba65c7f6f55 https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_x64.tar.gz 6bb0d2c6e8a29dcd9c577bbb2986352ba12481a9549ac2c0bcfd00ed60e538d2 https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-macosx_aarch64.tar.gz a106c77389a63b6bd963a087d5f01171bd32aa3ee7377ecef87531390dcb9050 https://cdn.azul.com/zulu/bin/zulu11.56.19-ca-jdk11.0.15-win_x64.zip ``` This is a step towards #14533 Closes #15302. PiperOrigin-RevId: 443381025
The javac changes that Bazel depends on are now available in the latest JDK 11 update release. bazelbuild#14533
The javac changes that Bazel depends on are now available in the latest JDK 11 update release. bazelbuild#14533
This is the third_party part of 18c17da bazelbuild#14533
@cushon Just wanted to follow up and thank you for all of your time and patience :) The 11.0.15 release of Java fixes everything for us (with the removal of --patch-module). Thank you!!!! |
This is the third_party part of 18c17da #14533 Partial commit for third_party/*, see #15322. Signed-off-by: Yun Peng <[email protected]>
This is the third_party part of bazelbuild#15319 bazelbuild#14533
This is the third_party part of bazelbuild#15319 bazelbuild#14533
Follow-up to 8f3d99a ``` a8fba686f6eb8ae1d1a9566821dbd5a85a1108b96ad857fdbac5c1e4649fc56f https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_ppc64le_linux_hotspot_11.0.15_10.tar.gz a58fc0361966af0a5d5a31a2d8a208e3c9bb0f54f345596fd80b99ea9a39788b https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15+10/OpenJDK11U-jdk_s390x_linux_hotspot_11.0.15_10.tar.gz ``` #14533 Closes #15352. PiperOrigin-RevId: 445074261
This is the third_party part of #15319 #14533 Partial commit for third_party/*, see #15347. Signed-off-by: Sunil Gowroji <[email protected]>
Is this (removing the langtools dependency) something worth bringing back to Bazel 5.2.0 (or the next 5.x release), or would raising the minimum requirement of OpenJDK 11.15 be considered a breaking change? (This is something I'm looking into backporting to 5.1.1/5.2.0 for our internal builds.) |
Description of the problem / feature request:
Building in Java 11 works using
toolchain_vanilla
, but changing totoolchain_java11
does not compile due to a JDK bug (that should be fixed). Does the toolchain_java11 not use a locally definedhost_javabase
andjavabase
?I assume that the vanilla one is using the local, but does that change to remote if i use toolchain_java11? Is there any way to change this so that I can define the jdk to use in that toolchain?
We define things like this in our .bazelrc:
The
jdk11
we use is this (via an alias)Feature requests: what underlying problem are you trying to solve with this feature?
Get our build to work.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
I think that it might have to do with our own giant code base, so it's not easily reproducible that I've found.
What operating system are you running Bazel on?
Linux - Ubuntu 21.04
What's the output of
bazel info release
?Have you found anything relevant by searching the web?
Yes, it looks like the bug we are hitting is a bug in the JDK: https://bugs.openjdk.java.net/browse/JDK-8210483
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: