Does bazel support mips64el architecture?

34 views
Skip to first unread message

zbq9...@gmail.com

unread,
Jul 13, 2020, 10:23:41 PM7/13/20
to bazel-discuss
Hi, I am build bazel from source on mips64el. But I enconter some problem and it seems bazel doesn't support mips64el. 
Bazel version is 3.3.1 and OS version is debian:stretch by the way

I tried to add some code like s390x does, for example in `thirdparty/BUILD` I add 
config_setting(
    name
= "mips64el",
    values
= {"host_cpu": "mips64el"},
)
Finally I got the following problem :
ERROR: /tmp/bazel_XVczA3pi/out/external/local_config_platform/BUILD.bazel:4:9: no such target '@platforms//cpu:mips64el': target 'mips64el' not declared in package 'cpu' defined by /tmp/bazel_XVczA3pi/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: 307.367s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (4 packages loaded, 0 targets conf\

Please help


John Cater

unread,
Jul 14, 2020, 8:20:03 AM7/14/20
to zbq9...@gmail.com, bazel-discuss
Can you share your in-progress changes where we can see them? It's unclear from your error what changes you've made.

Places you may need to update:
The external @platforms repo (not part of Bazel source): https://github.com/bazelbuild/platforms/blob/master/cpu/BUILD
This would need to be added back into the Bazel WORKSPACE: https://cs.opensource.google/bazel/bazel/+/master:WORKSPACE


I don't actually know which, if any, of these are required, but they're all related to CPU support.



--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/89dd569e-252b-470d-9427-7f1a058e0dcdo%40googlegroups.com.

懂得★珍惜

unread,
Jul 15, 2020, 12:47:37 AM7/15/20
to John Cater, zbq930713, bazel-discuss
Hi, thank you for your reply!

Acturally I modified the following files:
./platforms/cpu/BUILD
./tools/platforms/BUILD.tools
./tools/platforms/BUILD
./tools/cpp/BUILD.tools
./tools/cpp/lib_cc_configure.bzl
./tools/jdk/BUILD
./src/main/java/com/google/devtools/build/lib/analysis/config/AutoCpuConverter.java
./src/main/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunction.java
./src/main/java/com/google/devtools/build/lib/syntax/BUILD
./src/main/java/com/google/devtools/build/lib/util/CPU.java
./src/conditions/BUILD.tools
./src/conditions/BUILD
./src/test/java/com/google/devtools/build/lib/bazel/repository/LocalConfigPlatformFunctionTest.java
./third_party/BUILD

In these files, I add the mips64 code just like s390x does. I also tried use mips64el instead because the result of the command `uname -m` is mips64el. However it didn't work.



------------------ 原始邮件 ------------------
发件人: "John Cater" <jca...@google.com>;
发送时间: 2020年7月14日(星期二) 晚上8:19
收件人: "zbq930713"<zbq9...@gmail.com>;
抄送: "bazel-discuss"<bazel-...@googlegroups.com>;
主题: Re: Does bazel support mips64el architecture?

John Cater

unread,
Jul 15, 2020, 8:19:48 AM7/15/20
to 懂得★珍惜, zbq930713, bazel-discuss
That list of files seems good, but without seeing the code I can't actually comment.

The error message you report mentions the @platforms repo. If your change to LocalConfigPlatformFunction added a reference to @platforms//cpu:mips64el, but you didn't update the actual @platforms repo  it would explain the problem. I would suggest that in LocalConfigPlatformFunction you instead reference @bazel_tools//platforms:mips64el (and make sure that is present in tools/platforms/BUILD.tools.

Unfortunately, I don't have a mips machine to test with, so I'm not sure how much more help I can provide you.

懂得★珍惜

unread,
Jul 20, 2020, 9:45:08 PM7/20/20
to John Cater, zbq930713, bazel-discuss
Hi, I use the reference @bazel_tools//platforms:mips64 in LocalConfigPlatformFunction. The content of the file is as follows:
```
 @Nullable
  static String cpuToConstraint(CPU cpu) {
    switch (cpu) {
      case X86_32:
        return "@platforms//cpu:x86_32";
      case X86_64:
        return "@platforms//cpu:x86_64";
      case PPC:
        return "@platforms//cpu:ppc";
      case ARM:
        return "@platforms//cpu:arm";
      case AARCH64:
        return "@platforms//cpu:aarch64";
      case S390X:
        return "@platforms//cpu:s390x";
      case MIPS64:
        return "@bazel_tools//platforms:mips64";
      default:
        // Unknown, so skip it.
        return null;
    }
  }
```
And the content of tools/platforms/BUILD.tools is as follows:
```
alias(
    name = "mips64",
    actual = "@bazel_tools//platforms:mips64",
)
```
And then I execute `env EXTRA_BAZEL_ARGS="--host_javabase=@local_jdk//:jdk" bash ./compile.sh`. A new problem occurs:
```
ERROR: Cycle detected but could not be properly displayed due to an internal problem. Please file an issue. Raw display: topLevelKey: //src:bazel_nojdk BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5]
alreadyReported: false
path to cycle:
//src:bazel_nojdk BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5]
//src:bazel-bin_nojdk BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5]
ToolchainContextKey{configurationKey=BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5], requiredToolchainTypeLabels=[], execConstraintLabels=[], shouldSanityCheckConfiguration=false}
@local_config_platform//:host BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5]
cycle:
@bazel_tools//platforms:mips64 BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5]
ERROR: Analysis of target '//src:bazel_nojdk' failed; build aborted
```


------------------ 原始邮件 ------------------
发件人: "John Cater" <jca...@google.com>;
发送时间: 2020年7月15日(星期三) 晚上8:19
收件人: "懂得★珍惜"<www.38...@qq.com>;
抄送: "zbq930713"<zbq9...@gmail.com>;"bazel-discuss"<bazel-...@googlegroups.com>;

John Cater

unread,
Jul 21, 2020, 8:17:30 AM7/21/20
to 懂得★珍惜, zbq930713, bazel-discuss
I suspect the alias in tools/platforms/BUILD.tools is the problem: that file becomes the BUILD for @bazel_tools//platforms, and so this is a circular reference.

懂得★珍惜

unread,
Jul 21, 2020, 10:59:17 PM7/21/20
to John Cater, bazel-discuss
So how can I solve this problem? It seems that I need to learn how to use bazel. Thank you!


------------------ 原始邮件 ------------------
发件人: "John Cater" <jca...@google.com>;
发送时间: 2020年7月21日(星期二) 晚上8:17

John Cater

unread,
Jul 22, 2020, 9:32:30 AM7/22/20
to 懂得★珍惜, bazel-discuss
I think that tools/platforms/BUILD.tools should just have:
constraint_value(name = "mips64", constraint_setting = ":cpu")

But I'm not sure, and it's not possible for me to test anything without you sharing your repository (and possibly having a mips device to test on, which I don't have).

You should probably have a deeper knowledge of Bazel before trying to port to a new CPU architecture, have you been using Bazel on a supported platform? 

‪www.384785525@qq.com‬

unread,
Jul 22, 2020, 10:03:16 AM7/22/20
to John Cater, bazel-discuss
Actually I am a beginner for using bazel. I will
learn more before solve the problem. Thanks for your help!


-------- 原始邮件 --------
发件人: John Cater <jca...@google.com>
日期: 2020年7月22日周三 晚上9:32
收件人: 懂得★珍惜 <www.38...@qq.com>
抄送: bazel-discuss <bazel-...@googlegroups.com>
主 题: Re: Does bazel support mips64el architecture?
ToolchainContextKey{configurationKey=BuildConfigurationValue.Key[6aaa5ad37201d3073d374fc153694f27fc6135867f40d46e5326de0aac1ac6f5], requiredToolchainTypeLabels=[], execConstraintLabels=[], shouldSanityCheckConfiguration�lse}
```
Reply all
Reply to author
Forward
0 new messages