-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
bazel: building java targets fails because bazel downloads ijar binary #63096
Comments
I'm having the same issue. They have a new target for the
|
I suspect it's coming from here which is called from here. The absolute_javabase java_runtime defines |
@Profpatsch have you made any progress on this? |
tbh I was hoping someone else would fix it. :P I don’t have much time allocated to bazel work for next week, so it might be ~10 days until I can take an earnest stab. |
I was honestly expecting the following patch to work, but 🤷♂️! I'm not really sure why it's not working. Force Bazel to build ijar locallydiff --git a/tools/jdk/BUILD b/tools/jdk/BUILD
index d99fb7adb9..b582f7ba67 100644
--- a/tools/jdk/BUILD
+++ b/tools/jdk/BUILD
@@ -327,24 +327,12 @@ default_java_toolchain(
alias(
name = "toolchain",
- actual = select({
- "//src/conditions:darwin": "@remote_java_tools_darwin//:toolchain",
- "//src/conditions:darwin_x86_64": "@remote_java_tools_darwin//:toolchain",
- "//src/conditions:windows": "@remote_java_tools_windows//:toolchain",
- "//src/conditions:linux_x86_64": "@remote_java_tools_linux//:toolchain",
- "//conditions:default": "@bazel_tools//tools/jdk:legacy_toolchain",
- }),
+ actual = "@bazel_tools//tools/jdk:legacy_toolchain",
)
alias(
name = "remote_toolchain",
- actual = select({
- "//src/conditions:darwin": "@remote_java_tools_darwin//:toolchain",
- "//src/conditions:darwin_x86_64": "@remote_java_tools_darwin//:toolchain",
- "//src/conditions:windows": "@remote_java_tools_windows//:toolchain",
- "//src/conditions:linux_x86_64": "@remote_java_tools_linux//:toolchain",
- "//conditions:default": "@bazel_tools//tools/jdk:legacy_toolchain",
- }),
+ actual = "@bazel_tools//tools/jdk:legacy_toolchain",
)
# The 'vanilla' toolchain is an unsupported alternative to the default.
diff --git a/tools/jdk/BUILD.java_tools b/tools/jdk/BUILD.java_tools
index 7d4ee45498..30d26ebd5c 100644
--- a/tools/jdk/BUILD.java_tools
+++ b/tools/jdk/BUILD.java_tools
@@ -18,7 +18,7 @@ java_toolchain(
genclass = [":Genclass"],
header_compiler = [":Turbine"],
header_compiler_direct = [":TurbineDirect"],
- ijar = [":ijar"],
+ ijar = [":ijar_cc_binary"],
javabuilder = [":JavaBuilder"],
javac = [":javac_jar"],
javac_supports_workers = 1,
@@ -52,7 +52,7 @@ java_toolchain(
"-g",
"-parameters",
],
- singlejar = [":singlejar"],
+ singlejar = [":singlejar_cc_bin"],
source_version = "8",
target_version = "8",
tools = [
diff --git a/tools/jdk/BUILD.java_tools.old b/tools/jdk/BUILD.java_tools.old
index ff438af752..6b6e2aea3f 100644
--- a/tools/jdk/BUILD.java_tools.old
+++ b/tools/jdk/BUILD.java_tools.old
@@ -10,7 +10,7 @@ java_toolchain(
genclass = [":Genclass"],
header_compiler = [":turbine"],
header_compiler_direct = [":turbine_direct"],
- ijar = [":ijar"],
+ ijar = [":ijar_cc_binary"],
javabuilder = [":javabuilder"],
javac = [":javac_jar"],
tools = [
@@ -52,7 +52,7 @@ java_toolchain(
# Restrict protos to Java 7 so that they are compatible with Android.
"proto": ["-source", "7", "-target", "7"],
},
- singlejar = [":singlejar"],
+ singlejar = [":singlejar_cc_bin"],
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath"],
) |
This issue is typical with bazel on nixos: every "prebuilt" binary fetched by any bazel rule will fail with the same issue. We can fix each issue manually as they arise, but can we do better in a potential more generic way? From what I know, the only place bazel may generate binaries from the outerworld are in repository rules, and especially the following rules:
What are your thoughts about applying a recursive patchelf to patch at least the dynamic loader on the result of these rules? Another option may be to just patch https://docs.bazel.build/versions/master/skylark/lib/repository_ctx.html#execute to rewrite the call to |
It would be wonderful if that would work, as we don't have to keep specifying Nix provided toolchains. Making this work well might not be a trivial task, as you would most likely have to replicate
How would this allow it to find, say |
Yes. That's the most difficult solution.
I don't understand. The only things I'm thinking about is that, instead of using |
I see what you mean now. I think the |
@kalbasit I'm on it. |
Progress: I've built a local package with fixed Hopefully I'll be able to open a PR today. |
That's great news @guibou! Thank you! Please include a Java test (similar to current python test) with your PR. |
AFAIK there is a java test in the |
- Fixs for newly introduced bin/bash hardcoded reference - Bazel now references `remote_java_tools_xxx` which contains prebuilt binaries. We prefetch them, fix them, and force bazel to use the fixed repository. It also closes NixOS#63096
Issue description
Bazel fetches a binary at runtime and tries to execute it, which of course fails on NixOS:
Related to bazelbuild/bazel#8575
Steps to reproduce
Build any Java rule with bazel 0.26.1 in nixpkgs on NixOS.
cc @groodt @kalbasit
The text was updated successfully, but these errors were encountered: