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

Building and running Bazel on SiFive's 64bit RISC-V hardware (OpenJDK 11/Eclipse OpenJ9) #12800

Closed
advancedwebdeveloper opened this issue Jan 10, 2021 · 8 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

I decided to initiate a proposal, for 64bit RISC-V port.
Hence that this issues is not covering any emulation, like under Qemu - this is for real hardware, which could be ASIC or FPGA chips.

So here is what I got, on one of SiFive's boards:

$ ./compile.sh
🍃 Building Bazel from scratch.......
🍃 Building Bazel with Bazel.
DEBUG: /tmp/bazel_s2N9IVqa/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_s2N9IVqa/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_s2N9IVqa/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_s2N9IVqa/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_s2N9IVqa/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_s2N9IVqa/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_s2N9IVqa/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'
INFO: Repository remote_java_tools_linux instantiated at:
/DEFAULT.WORKSPACE.SUFFIX:237:6: in
/tmp/bazel_s2N9IVqa/out/external/bazel_tools/tools/build_defs/repo/utils.bzl:201:18: in maybe
Repository rule http_archive defined at:
/tmp/bazel_s2N9IVqa/out/external/bazel_tools/tools/build_defs/repo/http.bzl:336:31: in
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted: Analysis of target '@local_config_cc//:toolchain' failed
INFO: Elapsed time: 436.903s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (58 packages loaded, 142 targets c
onfigured)
currently loading: src/main/protobuf
Fetching @com_google_protobuf; fetching 42s
Fetching ...otobuf; Extracting /tmp/bazel_s2N9IVqa/out/external/com_google
_protobuf/temp3292787742799813619/v3.13.0.tar.gz 38s

ERROR: Could not build Bazel

Here is the information about 4 available cores:

$ cat /proc/cpuinfo
processor : 0
hart : 1
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 1
hart : 2
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 2
hart : 3
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

processor : 3
hart : 4
isa : rv64imafdc
mmu : sv39
uarch : sifive,rocket0

. Currently operating on

$ uname -a
Linux test-gdams-debian10-riscv64-1.adoptopenjdk.net 5.0.0-rc1-56210-g0a657e0d72f0 #1 SMP Fri May 15 18:05:26 EDT 2020 riscv64 GNU/Linux

@advancedwebdeveloper
Copy link
Author

Some information about the JDK:

$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10-202007292333)
Eclipse OpenJ9 VM AdoptOpenJDK (build master-dc7cbe4bd, JRE 11 Linux riscv-64-Bit Compressed References 20200729_78 (JIT disabled, AOT disabled)
OpenJ9 - dc7cbe4bd
OMR - 1c0299f20
JCL - 94b9d6d2c6 based on jdk-11.0.8+10)
$ javac -version
javac 11.0.8

@ulfjack
Copy link
Contributor

ulfjack commented Jan 11, 2021

In order for Bazel to support RISC-V, the next step is to auto-detect the platform correctly. The failure you are seeing is:

ERROR: /tmp/bazel_s2N9IVqa/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'

I think the auto-detection code is in com.google.devtools.build.lib.util.OS.

@advancedwebdeveloper
Copy link
Author

Thanks, will check that

@olekw
Copy link
Contributor

olekw commented Jan 11, 2021

@advancedwebdeveloper I tried just adding a constraint to the cpu listing and I'm not getting this error anymore on Debian. That's probably an overly-simplistic solution but it's likely a step in the right direction. More info on #12683.

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

Looks like the current summary is as follows:

https://github.com/bazelbuild/bazel/blob/master/src/main/java/com/google/devtools/build/lib/util/OsUtils.java
https://github.com/bazelbuild/bazel/blob/master/tools/platforms/BUILD
https://github.com/bazelbuild/bazel/blob/master/tools/platforms/BUILD.tools
I am able to find platforms/cpu/BUILD only in a bootstrap/dist build.

This

constraint_value(
name = "riscv64",
constraint_setting = ":cpu",
)

looks like some form of override.

@advancedwebdeveloper
Copy link
Author

I suspect that

"cc_toolchain_suite '%s' does not contain a toolchain for cpu '%s'",
is where the above was raised. Why there is no detailed information on CPU/platform identification, for that?

@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
@olekw
Copy link
Contributor

olekw commented Feb 24, 2021

@philwo should this just be merged into #12683? Once @meteorcloudy's PR is accepted there, I believe that this issue will be resolved as well.

@meteorcloudy
Copy link
Member

Yeah, this can be closed as it's a duplicate of #12683

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

No branches or pull requests

6 participants