Bootstrapping Bazel-6.0.0 from source in QEMU with RISCV image
- Dominant language
- Java
- Stars
- 25.8k
- Forks
- 4.6k
- Avg merge
- 2d 20h
- Merged PRs (30d)
- 72
Description
### Description of the bug:
I am trying to build the bazel from source on RISCV64 host device inside qemu. During compilation, I could see that compile.sh and bootstrap.sh scripts inside scripts/bootstrap/ directory got completed. Facing issue while running bazel_build command of compile.sh script. I could see that target was being build and throwing following error only when building **//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:starlark-deps** and facing following error:
```
ERROR: /home/ubuntu/bazel-.0.0/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD:169:23: JavacBootstrap src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libstarlark-deps.jar [for tool] failed: (Exit 3): bash failed: error executing command (from target
//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:starlark-deps)
```
After we get the above error, we encounter the following error:
```
The system is out of resources.
Consult the following stack trace for details.
java.lang.OutOfMemoryError: Java heap space
at java.base/java.util.Spliterators.spliterator(Spliterators.java:178)
at java.base/java.util.Arrays.spliterator(Arrays.java:5482)
at java.base/java.util.Arrays.stream(Arrays.java:5633)
at java.base/java.util.Arrays.stream(Arrays.java:5614)
at java.base/java.util.stream.Stream.of(Stream.java:1188)
```
I even increased to HeapSize to 500G by using export BAZEL_JAVAC_OPTS="-J-Xmx500g" but still issue persists.
### What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
_No response_
### Which operating system are you running Bazel on?
Linux ubuntu 6.2.0-19-generic #19.1-Ubuntu SMP Fri Mar 31 12:41:53 UTC 2023 riscv64 riscv64 riscv64 GNU/Linux
### 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.
1. # prerequisite dependencies
sudo apt-get install build-essential openjdk-11-jdk python zip unzip
2. # get bootstrapped distribution archive
wget https://github.com/bazelbuild/bazel/releases/download/6.0.0/bazel-6.0.0-dist.zip
3. # Unzip the zip file
mkdir bazel-6.0.0 && unzip -d ./bazel-6.0.0 bazel-6.0.0-dist.zip && cd bazel-6.0.0
5. # set the JAVA_HOME:
export JAVA_HOME="$(dirname $(dirname $(realpath $(which javac))))"
6. # set the heap size to maximum to resolve HeapSize error:
export BAZEL_JAVAC_OPTS="-J-Xmx500g"
7. # run the compile.sh
env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./compile.sh
### What's the output of `git remote get-url origin; git rev-parse master; git rev-parse HEAD` ?
_No response_
### Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
_No response_
### Have you found anything relevant by searching the web?
_No response_
### Any other information, logs, or outputs that you want to share?
```
# Execution platform: //:default_host_platform
INFO: From Compiling src/core/lib/channel/promise_based_filter.cc:
In constructor 'grpc_core::promise_filter_detail::ServerCallData::PollContext::PollContext(grpc_core::promise_filter_detail::ServerCallData*, gr
pc_core::promise_filter_detail::BaseCallData::Flusher*)',
inlined from 'void grpc_core::promise_filter_detail::ServerCallData::WakeInsideCombiner(grpc_core::promise_filter_detail::BaseCallData::Flus
her*)' at external/com_github_grpc_grpc/src/core/lib/channel/promise_based_filter.cc:1183:37:
external/com_github_grpc_grpc/src/core/lib/channel/promise_based_filter.cc:890:22: warning: storing the address of local variable 'poll_ctx' in
'*this.grpc_core::promise_filter_detail::ServerCallData::poll_ctx_' [-Wdangling-pointer=]
890 | self_->poll_ctx_ = this;
| ~~~~~~~~~~~~~~~~~^~~~~~
external/com_github_grpc_grpc/src/core/lib/channel/promise_based_filter.cc: In member function 'void grpc_core::promise_filter_detail::ServerCal
lData::WakeInsideCombiner(grpc_core::promise_filter_detail::BaseCallData::Flusher*)':
external/com_github_grpc_grpc/src/core/lib/channel/promise_based_filter.cc:1183:15: note: 'poll_ctx' declared here
1183 | PollContext poll_ctx(this, flusher);
| ^~~~~~~~
external/com_github_grpc_grpc/src/core/lib/channel/promise_based_filter.cc:1183:15: note: '' declared here
SUBCOMMAND: # @com_github_grpc_grpc//:grpc_base [action 'Linking external/com_github_grpc_grpc/libgrpc_base.a', configuration: 2752f6466326ffa9a
1e16b67062896a2c767d69a70c4fe03239d5bcfe1259886, execution platform: //:default_host_platform]
(cd /tmp/bazel_yR4anOqC/out/execroot/io_bazel && \
exec env - \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \
PWD=/proc/self/cwd \
/usr/bin/ar @bazel-out/riscv64-opt/bin/external/com_github_grpc_grpc/libgrpc_base.a-2.params)
# Configuration: 2752f6466326ffa9a1e16b67062896a2c767d69a70c4fe03239d5bcfe1259886
# Execution platform: //:default_host_platform
SUBCOMMAND: # //src/main/cpp:client [action 'Linking src/main/cpp/client', configuration: 2752f6466326ffa9a1e16b67062896a2c767d69a70c4fe03239d5b
cfe1259886, execution platform: //:default_host_platform]
(cd /tmp/bazel_yR4anOqC/out/execroot/io_bazel && \
exec env - \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \
PWD=/proc/self/cwd \
/usr/bin/gcc @bazel-out/riscv64-opt/bin/src/main/cpp/client-2.params)
# Configuration: 2752f6466326ffa9a1e16b67062896a2c767d69a70c4fe03239d5bcfe1259886
# Execution platform: //:default_host_platform
ERROR: /home/ubuntu/bazel-6.0.0/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD:169:23: JavacBootstrap src/java_tools/buil
djar/java/com/google/devtools/build/buildjar/libstarlark-deps.jar [for tool] failed: (Exit 3): bash failed: error executing command (from target
//src/java_tools/buildjar/java/com/google/devtools/build/buildjar:starlark-deps)
(cd /tmp/bazel_yR4anOqC/out/execroot/io_bazel && \
exec env - \
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin \
/bin/bash -c 'set -e;rm -rf bazel-out/riscv64-opt-exec-EDC14992/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libstarlar
k-deps.jar.build_output bazel-out/riscv64-opt-exec-EDC14992/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libstarlark-deps
.jar.build_java bazel-out/riscv64-opt-exec-EDC14992/bin/src/java_tools/buildjar/java/com/google/devtools/build/buildjar/libstarlark-deps.jar.bui
ld_java_list
```
Contributor guide
Research direction
Start by reproducing the command from compile.sh with EXTRA_BAZEL_ARGS and inspect scripts/bootstrap/. Trace the failing target at src/java_tools/buildjar/java/com/google/devtools/build/buildjar/BUILD:169 and compare the JavacBootstrap output on the RISCV64 QEMU environment. Done means identifying a minimal reproducible cause and confirming a successful bootstrap or documenting the required platform fix.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, linux
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 24/100