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

Help building Bazel 7.2.0 under Alpine - build succeeds but need help with ijar #22761

Closed
strophy opened this issue Jun 15, 2024 · 4 comments
Closed
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website team-Rules-Java Issues for Java rules type: support / not a bug (process)

Comments

@strophy
Copy link

strophy commented Jun 15, 2024

Description of the bug:

I'm trying to package Bazel 7.2.0 for Alpine Linux: https://gitlab.alpinelinux.org/alpine/aports/-/merge_requests/67730

Compilation passes through the Building Bazel from scratch...... and Building Bazel with Bazel. steps successfully but fails with something related to rules_java and ijar afterwards. Can anyone familiar with Java help me get over this last hurdle? My previous work packaging Bazel 6 modified a number of files relating to ijar but these seem to have moved since, where can I make similar changes in Bazel 7.2.0? Possibly also related #12961

Build error below:

...
INFO: 3956 processes: 375 internal, 2707 local, 874 worker.
[3,956 / 3,956] checking cached actions
INFO: Build completed successfully, 3956 total actions
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.
Build successful! Binary is here: /builds/strophy/aports/testing/bazel7/src/output/bazel
Extracting Bazel installation...
Starting local Bazel server and connecting to it...
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Computing main repo mapping: 
Loading: 
Loading: 0 packages loaded
Analyzing: target //scripts:bazel-complete.bash (1 packages loaded, 0 targets configured)
Analyzing: target //scripts:bazel-complete.bash (1 packages loaded, 0 targets configured)
[0 / 1] [Prepa] BazelWorkspaceStatusAction stable-status.txt
Analyzing: target //scripts:bazel-complete.bash (106 packages loaded, 606 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (143 packages loaded, 660 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (144 packages loaded, 674 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (145 packages loaded, 678 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (145 packages loaded, 678 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (353 packages loaded, 6554 targets configured)
[1 / 1] checking cached actions
DEBUG: /home/buildozer/.cache/bazel/_bazel_buildozer/306f932530c1d3c861b1433c8354e9ac/external/rules_jvm_external~/coursier.bzl:721:18: Found duplicate artifact versions
    com.google.code.gson:gson has multiple versions 2.9.0, 2.8.9
    com.google.errorprone:error_prone_annotations has multiple versions 2.22.0, 2.3.2
    com.google.truth:truth has multiple versions 1.1.3, 1.1.2
    org.mockito:mockito-core has multiple versions 5.4.0, 4.3.1
Please remove duplicate artifacts from the artifact list so you do not get unexpected artifact versions
Analyzing: target //scripts:bazel-complete.bash (454 packages loaded, 7148 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (477 packages loaded, 9049 targets configured)
[1 / 1] checking cached actions
Analyzing: target //scripts:bazel-complete.bash (498 packages loaded, 9629 targets configured)
[1 / 1] checking cached actions
INFO: Analyzed target //scripts:bazel-complete.bash (501 packages loaded, 10832 targets configured).
[1 / 13] [Prepa] Writing file src/main/cpp/client-2.params [for tool]
ERROR: /builds/strophy/aports/testing/bazel7/src/third_party/BUILD:491:20: Extracting interface for jar bazel-out/k8-opt-exec-ST-fad1763555eb/bin/external/rules_jvm_external~~maven~maven/io/netty/netty-resolver/4.1.93.Final/netty-resolver-4.1.93.Final.jar [for tool] failed: (Exit 1): ijar failed: error executing JavaIjar command (from target //third_party:netty_checked_in) external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar ... (remaining 4 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/main/tools/process-wrapper-legacy.cc:80: "execvp(external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar, ...)": No such file or directory
ERROR: /builds/strophy/aports/testing/bazel7/src/third_party/BUILD:491:20: Extracting interface for jar bazel-out/k8-opt-exec-ST-fad1763555eb/bin/external/rules_jvm_external~~maven~maven/io/netty/netty-codec-http2/4.1.93.Final/netty-codec-http2-4.1.93.Final.jar [for tool] failed: (Exit 1): ijar failed: error executing JavaIjar command (from target //third_party:netty_checked_in) external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar ... (remaining 4 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/main/tools/process-wrapper-legacy.cc:80: "execvp(external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar, ...)": No such file or directory
ERROR: /builds/strophy/aports/testing/bazel7/src/third_party/BUILD:491:20: Extracting interface for jar bazel-out/k8-opt-exec-ST-fad1763555eb/bin/external/rules_jvm_external~~maven~maven/io/netty/netty-codec-http/4.1.93.Final/netty-codec-http-4.1.93.Final.jar [for tool] failed: (Exit 1): ijar failed: error executing JavaIjar command (from target //third_party:netty_checked_in) external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar ... (remaining 4 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
src/main/tools/process-wrapper-legacy.cc:80: "execvp(external/rules_java~~toolchains~remote_java_tools_linux/java_tools/ijar/ijar, ...)": No such file or directory
Target //scripts:bazel-complete.bash failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 18.042s, Critical Path: 0.17s
INFO: 297 processes: 252 internal, 1 local, 44 processwrapper-sandbox.
ERROR: Build did NOT complete successfully

Which category does this issue belong to?

Core, Java Rules

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

Check out https://gitlab.alpinelinux.org/strophy/aports/-/tree/bazel7-7.2.0 then

cd testing/bazel7-7.2.0
docker run \
	-e RSA_PRIVATE_KEY="$(cat ~/.abuild/mykey.rsa)" \
	-e RSA_PRIVATE_KEY_NAME="mykey.rsa" \
	-v "$PWD:/home/builder/package" \
	-v "$HOME/.abuild/packages:/packages" \
	-v "$HOME/.abuild/mykey.rsa.pub:/etc/apk/keys/mykey.rsa.pub" \
	-v "$HOME/.abuild:/home/builder/.abuild" \
	sgerrand/alpine-abuild:latest

Which operating system are you running Bazel on?

Alpine Linux 3.19/3.20/edge

What is the output of bazel info release?

No response

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 HEAD ?

No response

If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

No response

Have you found anything relevant by searching the web?

No response

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

No response

@github-actions github-actions bot added team-Core Skyframe, bazel query, BEP, options parsing, bazelrc team-Rules-Java Issues for Java rules labels Jun 15, 2024
@meisterT meisterT added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website and removed team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Jun 17, 2024
@hvadehra
Copy link
Member

I think this just needs to use a java_toolchain that uses the ijar/singlejar tools compiled from source as discussed in the linked issue. So an additional patch with these changes should do it:

diff --git a/.bazelrc b/.bazelrc
index 89de37ca21..2100ccf01c 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -92,3 +92,5 @@ test:ci-windows --test_env=JAVA_HOME
 test:ci-windows --test_env=TEST_INSTALL_BASE=C:/b/bazeltest_install_base
 test:ci-windows --test_env=REPOSITORY_CACHE=C:/b/bazeltest_repo_cache
 test:ci-windows --test_tag_filters=-no_windows,-slow
+
+common --extra_toolchains=//abuild:non_prebuilt_java_21_toolchain_definition
diff --git a/abuild/BUILD.bazel b/abuild/BUILD.bazel
index e69de29bb2..23a349134b 100644
--- a/abuild/BUILD.bazel
+++ b/abuild/BUILD.bazel
@@ -0,0 +1,11 @@
+load("@rules_java//toolchains:default_java_toolchain.bzl", "default_java_toolchain")
+
+default_java_toolchain(
+    name = "non_prebuilt_java_21_toolchain",
+    header_compiler_direct = "@remote_java_tools//:TurbineDirect",
+    ijar = "//third_party/ijar:ijar",
+    java_runtime = "@local_jdk//:jdk",
+    singlejar = "//src/tools/singlejar:singlejar",
+    source_version = "21",
+    target_version = "21",
+)
diff --git a/scripts/BUILD b/scripts/BUILD
index 6f872a4a8d..a6d8ba77b0 100644
--- a/scripts/BUILD
+++ b/scripts/BUILD
@@ -12,7 +12,7 @@ genrule(
     outs = ["bazel-complete.bash"],
     cmd = " ".join([
         "$(location :generate_bash_completion.sh)",
-        "--bazel=$(location //src:bazel)",
+        "--bazel=$(location //src:bazel_nojdk)",
         "--output=$@",
         "--prepend=$(location bazel-complete-header.bash)",
         "--prepend=$(location bazel-complete-template.bash)",
@@ -20,7 +20,7 @@ genrule(
     output_to_bindir = 1,
     tools = [
         ":generate_bash_completion.sh",
-        "//src:bazel",
+        "//src:bazel_nojdk",
     ],
     visibility = [
         "//scripts/packages:__subpackages__",

@strophy
Copy link
Author

strophy commented Jun 27, 2024

Thanks @hvadehra this was incredibly useful to me! Bazel 7.2.0 now builds successfully and is available as an Alpine package here: https://pkgs.alpinelinux.org/package/edge/testing/x86_64/bazel7

I'll try to add arm64 support next when I get time. Would some of the changes in the Alpine patch be upstreamable, specifically bumping abseil-cpp to include their various musl build fixes in newer versions, and the typedef conditional statements? Happy to attempt a PR if you think it can be included in Bazel.

@hvadehra
Copy link
Member

hvadehra commented Jul 1, 2024

Bazel 7.2.0 now builds successfully and is available as an Alpine package

🎉

specifically bumping abseil-cpp to include their various musl build fixes in newer versions, and the typedef conditional statements

There were some issues recently around abseil-cpp. See #22692 / #22719

cc @meteorcloudy

@strophy
Copy link
Author

strophy commented Jul 2, 2024

Thanks, I've subscribed to #22719. Let's close this issue, I'll open a new one referencing the others if I get stuck again.

@strophy strophy closed this as completed Jul 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website team-Rules-Java Issues for Java rules type: support / not a bug (process)
Projects
None yet
Development

No branches or pull requests

6 participants