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

[riscv][risc-v][riscv64]Cannot build Bazel 7.1.0 on RISC-V 64 (Lichee PI4A) #23018

Open
lazyprogrammerio opened this issue Jul 16, 2024 · 7 comments
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request

Comments

@lazyprogrammerio
Copy link

Description of the bug:

Hello,

I am running Ubuntu 24.04 stock (riscv64) on the LicheePi 4A.

When trying to build bazel from source (7.1.0), I get an error, as it weirdly tries to build Bazel with Bazel (?) and it fails.

My first question is: why is it trying to build Bazel with Bazel -> Building Bazel with Bazel?

Reproduction steps:

# download and unzip / cd into bazel-7.1.0-dist.zip
# apt install java 21 jre and jdk
# dpkg --list |grep -i jdk
# ii  default-jdk-headless                             2:1.21-75+exp1                            riscv64      Standard Java or Java compatible  Development Kit (headless)
#
# ii  libanimal-sniffer-java                           1.16-1                                    all          JDK/API verification tools
#ii  openjdk-21-jdk:riscv64                           21.0.3+9-1ubuntu1                         riscv64      OpenJDK Development Kit (JDK)
#ii  openjdk-21-jdk-headless:riscv64                  21.0.3+9-1ubuntu1                         riscv64      OpenJDK Development Kit (JDK) (headless)
#ii  openjdk-21-jre:riscv64                           21.0.3+9-1ubuntu1                         riscv64      OpenJDK Java runtime, using Hotspot JIT
#ii  openjdk-21-jre-headless:riscv64                  21.0.3+9-1ubuntu1                         riscv64      OpenJDK Java runtime, using Hotspot JIT (headless)

env EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./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.
INFO: Repository rules_python~~python~pythons_hub instantiated at:
  <builtin>: in <toplevel>
Repository rule hub_repo defined at:
  /tmp/bazel_Jag75LiP/out/external/rules_python~/python/extensions/private/pythons_hub.bzl:107:27: in <toplevel>
ERROR: An error occurred during the fetch of repository 'rules_python~~python~pythons_hub':
   Traceback (most recent call last):
        File "/tmp/bazel_Jag75LiP/out/external/rules_python~/python/extensions/private/pythons_hub.bzl", line 86, column 33, in _hub_repo_impl
                platform = get_host_platform(os, arch)
        File "/tmp/bazel_Jag75LiP/out/external/rules_python~/python/private/toolchains_repo.bzl", line 325, column 13, in get_host_platform
                fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS linux on arch riscv64
ERROR: <builtin>: fetching hub_repo rule //:rules_python~~python~pythons_hub: Traceback (most recent call last):
        File "/tmp/bazel_Jag75LiP/out/external/rules_python~/python/extensions/private/pythons_hub.bzl", line 86, column 33, in _hub_repo_impl
                platform = get_host_platform(os, arch)
        File "/tmp/bazel_Jag75LiP/out/external/rules_python~/python/private/toolchains_repo.bzl", line 325, column 13, in get_host_platform
                fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS linux on arch riscv64

Which category does this issue belong to?

Core

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?

No response

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

@lazyprogrammerio
Copy link
Author

For Bazel 6.1.0 I got this error:

🍃  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_cZ6Gd5bJ/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, 10322 targets configured).
INFO: Found 1 target...
[4 / 20] 2 actions, 1 running
    //src:create_embedded_tools; 0s local
    [Prepa] Writing file third_party/ijar/zipper-2.params
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NoClassDefFoundError: Could not initialize class com.google.devtools.build.lib.unsafe.StringUnsafe
        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:957)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1124)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1082)
        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:516)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:827)
        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:1144)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
        at java.base/java.lang.Thread.run(Thread.java:1583)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @6ce2b319 [in thread "skyframe-evaluator 2"]
        at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
        at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:194)
        at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:187)
        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

@lazyprogrammerio
Copy link
Author

For Bazel 7.1.0 and JDK 17:

nv EXTRA_BAZEL_ARGS="--tool_java_runtime_version=local_jdk" bash ./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.
INFO: Repository rules_python~~python~pythons_hub instantiated at:
  <builtin>: in <toplevel>
Repository rule hub_repo defined at:
  /tmp/bazel_AXQaB2i5/out/external/rules_python~/python/extensions/private/pythons_hub.bzl:107:27: in <toplevel>
ERROR: An error occurred during the fetch of repository 'rules_python~~python~pythons_hub':
   Traceback (most recent call last):
        File "/tmp/bazel_AXQaB2i5/out/external/rules_python~/python/extensions/private/pythons_hub.bzl", line 86, column 33, in _hub_repo_impl
                platform = get_host_platform(os, arch)
        File "/tmp/bazel_AXQaB2i5/out/external/rules_python~/python/private/toolchains_repo.bzl", line 325, column 13, in get_host_platform
                fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS linux on arch riscv64
ERROR: <builtin>: fetching hub_repo rule //:rules_python~~python~pythons_hub: Traceback (most recent call last):
        File "/tmp/bazel_AXQaB2i5/out/external/rules_python~/python/extensions/private/pythons_hub.bzl", line 86, column 33, in _hub_repo_impl
                platform = get_host_platform(os, arch)
        File "/tmp/bazel_AXQaB2i5/out/external/rules_python~/python/private/toolchains_repo.bzl", line 325, column 13, in get_host_platform
                fail("No platform declared for host OS {} on arch {}".format(os_name, arch))
Error in fail: No platform declared for host OS linux on arch riscv64
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: No platform declared for host OS linux on arch riscv64
INFO: Elapsed time: 30.732s, Critical Path: 0.35s
INFO: 1 process: 1 internal.
ERROR: Build did NOT complete successfully
FAILED:
    Fetching repository @@stardoc~; starting 7s
    Fetching repository @@rules_go~; starting 6s
    Fetching ...B2i5/out/external/stardoc~; Extracting stardoc-0.5.3.tar.gz 5s
    Fetching ...2i5/out/external/rules_go~; Extracting rules_go-v0.39.1.zip 5s
    Fetching repository @@apple_support~; starting
    Fetching ...external/apple_support~; Extracting apple_support.1.8.1.tar.gz

ERROR: Could not build Bazel

@lazyprogrammerio
Copy link
Author

Seems like https://github.com/bazelbuild/rules_python/pull/1907/files is required to be able to build on riscv64.
bazelbuild/rules_python@daf4224 -> present in version 0.33+ of the rules_python.

Which means that only Bazel v8.00+ will be able to properly build, see 01f6dec.

One has to backport this commit 01f6dec to 7.1.0 and hope it builds.

@lazyprogrammerio
Copy link
Author

From the documentation, I do not see a way to bootstrap without having a .dist release, how can I do it though with the git repo? Otherwise, I ll need to wait for a new tag and a release of 8.x.

@lazyprogrammerio
Copy link
Author

RISC-V master is broken because this commit has been reverted/changed b34be09 and it was not applied when it got reverted in the main repo and the functionality was switched to using the bazel_rules repository https://github.com/bazelbuild/rules_java/blame/master/toolchains/BUILD#L141

I opened a PR here: bazelbuild/rules_java#198

hack3ric added a commit to hack3ric/archriscv-packages that referenced this issue Jul 17, 2024
Temporarily use PyPI's source package to build python-protobuf instead of using Bazel to prevent loop makedepends. Will be reverted once Bazel is built (see bazelbuild/bazel#23018)
felixonmars pushed a commit to felixonmars/archriscv-packages that referenced this issue Jul 17, 2024
Temporarily use PyPI's source package to build python-protobuf instead of using Bazel to prevent loop makedepends. Will be reverted once Bazel is built (see bazelbuild/bazel#23018)
@6eanut
Copy link

6eanut commented Jul 26, 2024

@lazyprogrammerio hi
i am working on building tensorflow2.15.0 from source by bazel6.1.0.
i notice that the WORKFILE in tensorflow2.15.0 point to the rules_python is 0.26.0, which not support risc-v.
when i change the 0.26.0 to 0.33.0, i meet the error:

ERROR: /home/tf2150/tensorflow/WORKSPACE:61:10: //external:pypi: no such attribute 'requirements' in 'pip_repository' rule
ERROR: Error computing the main repository mapping: Encountered error while reading extension file 'requirements.bzl': no such package '@pypi//': error loading package 'external': Could not load //external package

you know something about it?
thanks very much!

@haxorz haxorz 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 Aug 1, 2024
lazyprogrammerio added a commit to lazyprogrammerio/bazel that referenced this issue Aug 6, 2024
Required to be able to build rules_java for RISC-V.
Fixes: bazelbuild#23018
@meteorcloudy meteorcloudy added help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request and removed team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website untriaged type: bug labels Aug 13, 2024
@Geremia
Copy link

Geremia commented Feb 21, 2025

@lazyprogrammerio
I get this error, too, when trying to build Bazel 6.5.0 with JAVA_HOME=/usr/lib64/zulu-openjdk21:

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_NSS5PyJI/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 (388 packages loaded, 10504 targets configured).
INFO: Found 1 target...
[0 / 1,032] 13 actions, 0 running
    @bazel_tools//third_party/ijar:zipper; 0s local
    //src:create_embedded_tools; 0s local
    //src/tools/singlejar:singlejar; 0s local
    @com_github_grpc_grpc//src/compiler:grpc_cpp_plugin; 0s local
    Writing file src/embedded_tools_nojdk.params; 0s local
    .../google/devtools/build/buildjar:bootstrap_VanillaJavaBuilder; 0s local
    @bazel_tools//tools/python:_generate_wrappers; 0s local
    @com_google_protobuf//:protoc; 0s local ...
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NoClassDefFoundError: Could not initialize class com.google.devtools.build.lib.unsafe.StringUnsafe
        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:961)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.continueAction(SkyframeActionExecutor.java:1128)
        at com.google.devtools.build.lib.skyframe.SkyframeActionExecutor$ActionRunner.run(SkyframeActionExecutor.java:1086)
        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:519)
        at com.google.devtools.build.lib.skyframe.ActionExecutionFunction.checkCacheAndExecuteIfNeeded(ActionExecutionFunction.java:827)
        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:562)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:365)
        at java.base/java.util.concurrent.ForkJoinTask$AdaptedRunnableAction.exec(ForkJoinTask.java:1403)
        at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
        at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
        at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
        at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
        at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.reflect.InaccessibleObjectException: Unable to make java.lang.String(byte[],byte) accessible: module java.base does not "opens java.lang" to unnamed module @1fc2b765 [in thread "skyframe-evaluator-5"]
        at java.base/java.lang.reflect.AccessibleObject.throwInaccessibleObjectException(AccessibleObject.java:391)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:367)
        at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:315)
        at java.base/java.lang.reflect.Constructor.checkCanSetAccessible(Constructor.java:194)
        at java.base/java.lang.reflect.Constructor.setAccessible(Constructor.java:187)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<init>(StringUnsafe.java:61)
        at com.google.devtools.build.lib.unsafe.StringUnsafe.<clinit>(StringUnsafe.java:36)
        ... 25 more

ERROR: Could not build Bazel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Someone outside the Bazel team could own this P3 We're not considering working on this, but happy to review a PR. (No assignee) type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants