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

Supporting 64bit RISC-V #12683

Closed
advancedwebdeveloper opened this issue Dec 10, 2020 · 24 comments
Closed

Supporting 64bit RISC-V #12683

advancedwebdeveloper opened this issue Dec 10, 2020 · 24 comments
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request

Comments

@advancedwebdeveloper
Copy link

Description of the problem / feature request:

Providing support for 64 bit RISC-V

Feature requests: what underlying problem are you trying to solve with this feature?

Ensuring the availability of fully functional RPM, DEB packages on RISC-V ports of Debian/Ubuntu, OpenSUSE and Fedora.
Ordinary VM options assumed, as also as binfmt/nspawn qemu(JeOS)-inside-containers.
As for the hardware support (not under Qemu) - enabling specific RISC-V extensions, to improve the performance on concrete SoC boards.

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

The nearest bug is the lack of properly configured amount of vRAM, required to build a "bootstrapped" version of Bazel, under (specifically) rv64gc (estimation).

What operating system are you running Bazel on?

I only tried to build Bazel on https://en.opensuse.org/openSUSE:RISC-V . I followed those instructions.

@advancedwebdeveloper
Copy link
Author

CC @mzeren-vmw

@advancedwebdeveloper
Copy link
Author

Found first related bug:

oceanfish81@riscv:/home/oceanfish81/bazel> env EXTRA_BAZEL_ARGS='--jvmopt="-Xmx3G" --host_javabase=@local_jdk//:jdk' bash ./compile.sh
🍃 Building Bazel from scratch......
🍃 Building Bazel with Bazel.
.OpenJDK 64-Bit Zero VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
DEBUG: /tmp/bazel_DaaLPRWl/out/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:59:14:
Current running Bazel is not a release version and one was not defined explicitly in rbe_autoconfig target. Falling back to '3.1.0'
DEBUG: /tmp/bazel_DaaLPRWl/out/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:14: rbe_ubuntu1804_java11 not using checked in configs as detect_java_home was set to True
DEBUG: /tmp/bazel_DaaLPRWl/out/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:59:14:
Current running Bazel is not a release version and one was not defined explicitly in rbe_autoconfig target. Falling back to '3.1.0'
DEBUG: /tmp/bazel_DaaLPRWl/out/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:14: rbe_ubuntu1604_java8 not using checked in configs as detect_java_home was set to True
DEBUG: /tmp/bazel_DaaLPRWl/out/external/build_bazel_rules_nodejs/internal/common/check_bazel_version.bzl:47:14:
Current Bazel is not a release version, cannot check for compatibility.
DEBUG: /tmp/bazel_DaaLPRWl/out/external/build_bazel_rules_nodejs/internal/common/check_bazel_version.bzl:49:14: Make sure that you are running at least Bazel 0.21.0.
ERROR: /tmp/bazel_DaaLPRWl/out/external/local_config_cc/BUILD:47:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'unknown'
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed
INFO: Elapsed time: 684.978s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (28 packages loaded, 69 targets co
nfigured)

@advancedwebdeveloper
Copy link
Author

@adrianschroeter , what is the best way to check whether an application is running under systemd-nspawn + qemu-linux-user (JeOS) ?
It makes sense to form such a configuration, for Bazel.

@aiuto aiuto added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request untriaged labels Jan 7, 2021
@olekw
Copy link
Contributor

olekw commented Jan 11, 2021

ERROR: /tmp/bazel_DaaLPRWl/out/external/local_config_cc/BUILD:47:19: in cc_toolchain_suite rule @local_config_cc//:toolchain: cc_toolchain_suite '@local_config_cc//:toolchain' does not contain a toolchain for cpu 'unknown'
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed

@advancedwebdeveloper Have you looked at the Debian packaging of Bazel recently? I tried a trivial fix for this issue as part of my experiments to see if it's possible to support RISC-V. I no longer get this error. However, the build still freezes partway through and I have been unable to determine why. Feel free to take a look at what I have and use the riscv64.Dockerfile to build on any architecture.

cc: @meteorcloudy

@philwo philwo added this to the Platform support: RISC-V milestone Feb 8, 2021
@philwo philwo added P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Feb 8, 2021
@advancedwebdeveloper
Copy link
Author

oceanfish81@riscv:/home/oceanfish81/bazel-4.0.0> env EXTRA_BAZEL_ARGS='--jvmopt="-Xmx3G" --host_javabase=@local_jdk//:jdk' bash ./compile.sh
🍃 Building Bazel from scratch......
🍃 Building Bazel with Bazel.
.OpenJDK 64-Bit Zero VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
DEBUG: /tmp/bazel_PAChtKwT/out/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:59:14:
Current running Bazel is not a release version and one was not defined explicitly in rbe_autoconfig target. Falling back to '3.1.0'
DEBUG: /tmp/bazel_PAChtKwT/out/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:14: rbe_ubuntu1804_java11 not using checked in configs as detect_java_home was set to True
DEBUG: /tmp/bazel_PAChtKwT/out/external/bazel_toolchains/rules/rbe_repo/version_check.bzl:59:14:
Current running Bazel is not a release version and one was not defined explicitly in rbe_autoconfig target. Falling back to '3.1.0'
DEBUG: /tmp/bazel_PAChtKwT/out/external/bazel_toolchains/rules/rbe_repo/checked_in.bzl:103:14: rbe_ubuntu1604_java8 not using checked in configs as detect_java_home was set to True
ERROR: /tmp/bazel_PAChtKwT/out/external/local_config_platform/BUILD.bazel:4:9: no such target '@platforms//cpu:riscv64': target 'riscv64' not declared in package 'cpu' defined by /tmp/bazel_PAChtKwT/out/external/platforms/cpu/BUILD and referenced by '@local_config_platform//:host'
ERROR: While resolving toolchains for target //src:bazel-bin_nojdk: Target @local_config_platform//:host was referenced as a platform, but does not provide PlatformInfo
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: Analysis failed
INFO: Elapsed time: 563.704s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 0 targets conf
igured)

@olekw
Copy link
Contributor

olekw commented Feb 12, 2021

@advancedwebdeveloper If you're not in a huge hurry, I'd wait a little bit. @meteorcloudy and I have been talking about how to move the Debian patches supporting RISC-V 64 (and MIPS 64) to mainline Bazel. Once that happens, (and assuming there are no unanticipated problems!) it will be MUCH easier for you to do this build. :)

@olekw
Copy link
Contributor

olekw commented Feb 15, 2021

@advancedwebdeveloper and other interested parties: We have just had the first successful experimental build of Bazel in Debian for RISC-V. You can download both the source package and the binaries at this link. If it seems to work (I have no easy way of testing it) I will put these changes into unstable and request a freeze exemption for Debian 11. Feedback welcome!

meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Feb 17, 2021
Upstream some patches from the Bazel Debian package to make Bazel build
on mips64 and riscv64

https://salsa.debian.org/bazel-team/bazel-bootstrap/-/tree/olek-mips-riscv-3/debian/patches

Fixes bazelbuild#12683
@olekw
Copy link
Contributor

olekw commented Feb 24, 2021

Today I uploaded a version of Bazel (as bazel-bootstrap) to Debian unstable with support for 64bit RISC-V. It is still building but should be available for download in the next day or two. It is currently slated for release with Debian 11 (Bullseye) on amd64. arm64, ppc64el, s390x, ppc64, and riscv64. (and mips64el if we can address an OpenJDK bug on that architecture). Thanks to the Bazel team (and especially @meteorcloudy) for their advice and assistance with helping to make this happen!

@advancedwebdeveloper
Copy link
Author

@gdams, would you test it?

meteorcloudy added a commit to meteorcloudy/bazel that referenced this issue Feb 26, 2021
Upstream some patches from the Bazel Debian package to make Bazel build
on mips64 and riscv64

https://salsa.debian.org/bazel-team/bazel-bootstrap/-/tree/olek-mips-riscv-3/debian/patches

Fixes bazelbuild#12683
@advancedwebdeveloper
Copy link
Author

@olekw
Copy link
Contributor

olekw commented Feb 28, 2021

@advancedwebdeveloper Ubuntu pulled the latest version of bazel-bootstrap a few days ago. On the 25th, if I remember correctly. So if that's a daily CD image then it should be on there.

If you're asking for the package to be included on Ubuntu's default install media, and if it currently is not, then I can't help you. You would probably need to discuss that with a member of Ubuntu's release team.

@olekw
Copy link
Contributor

olekw commented Feb 28, 2021

Oh, also, the RISC-V version is available through the Debian Unstable link above as of about a day ago.

@advancedwebdeveloper
Copy link
Author

advancedwebdeveloper commented Feb 28, 2021

root@ubuntu:/mc# apt search bazel
Sorting... Done
Full Text Search... Done
root@ubuntu:
/mc# uname -a
Linux ubuntu 5.8.0-16-generic #18+21.04.3-Ubuntu SMP Wed Feb 10 14:27:31 UTC 2021 riscv64 riscv64 riscv64 GNU/Linux

@advancedwebdeveloper
Copy link
Author

cat /etc/release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=21.04
DISTRIB_CODENAME=hirsute
DISTRIB_DESCRIPTION="Ubuntu Hirsute Hippo (development branch)"

@olekw
Copy link
Contributor

olekw commented Feb 28, 2021

root@ubuntu:/mc# apt search bazel
Sorting... Done
Full Text Search... Done
root@ubuntu:
/mc# uname -a
Linux ubuntu 5.8.0-16-generic #18+21.04.3-Ubuntu SMP Wed Feb 10 14:27:31 UTC 2021 riscv64 riscv64 riscv64 GNU/Linux

Looking at Ubuntu's package page, the riscv64 architecture is showing a "Pending publication" status. I would assume that means it will be available soon.

@advancedwebdeveloper
Copy link
Author

Could I compile your package now, via sbuild?

@olekw
Copy link
Contributor

olekw commented Mar 1, 2021

Could I compile your package now, via sbuild?

Absolutely! If it's working on the build daemons it should work just fine on your machine as well. Feel free to file a bug with Debian if you run into any problems.

@olekw
Copy link
Contributor

olekw commented Mar 1, 2021

And looks like the vanilla Bazel should build now as well!

@advancedwebdeveloper
Copy link
Author

I shall check that, today

@jesec jesec mentioned this issue Jun 26, 2021
9 tasks
@6eanut
Copy link

6eanut commented Jul 19, 2024

Now I want to compile bazel6.1.0 on risc-v, is there a way?

@meteorcloudy
Copy link
Member

Check how support was added for "s390x" https://cs.opensource.google/search?q=%22s390x%22&ss=bazel%2Fbazel and make sure the same code exists for "rsicv64". PRs are welcome!

@6eanut
Copy link

6eanut commented Jul 21, 2024

@meteorcloudy
thanks for answering!
i am working on building tensorflow from source on risc-v. when building the tensorflow(2.15.0)'s wheel, bazel(6.1.0) is needed.
i download the dist file. and then, there are two ways:
1.bazel build bazel:
i can dnf install bazel. but when run bazel build //src:bazel, meet the trobule [tf@openeuler-riscv64-worker1 bazel-source]$ bazel build //src:bazel Extracting Bazel installation... Starting local Bazel server and connecting to it... ... still trying to connect to local Bazel server after 10 seconds ... Illegal instruction (core dumped)
2.build from source:
when i run ./compile, i can get the binary file. but when i run ./bazel , i meet the trouble Illegal instruction (core dumped)

@meteorcloudy
Copy link
Member

meteorcloudy commented Jul 22, 2024

Yeah, unfortunately, we don't officially support risc-v yet. The fix submitted for this issue may no longer work anymore.

@6eanut
Copy link

6eanut commented Jul 23, 2024

@meteorcloudy thanks for help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 We're not considering working on this, but happy to review a PR. (No assignee) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants