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

Bare-Metal #256

Open
wpieterse2825 opened this issue Oct 14, 2019 · 1 comment
Open

Bare-Metal #256

wpieterse2825 opened this issue Oct 14, 2019 · 1 comment

Comments

@wpieterse2825
Copy link

Hi there, I have been trying out Rust with Bazel for while now and must say the experience is quite nice.

I want to start developing firmware utilities with Rust and Bazel. I'm trying to target the UEFI platform for now. I see there is a way to register toolchains for Rust inside Bazel, but it keeps giving me errors. The target triple I'm going for is x86_64-unknown-uefi but it keeps on throwing an error that it's not supported.

Is it possible to develop bare metal targets with rules_rust?

The full error log is below:

INFO: Call stack for the definition of repository 'rust_uefi_x86_64_toolchains' which is a rust_toolchain_repository_proxy (rule definition at /home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl:354:35):
 - /home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl:389:5
 - /home/wpieterse/scrapbook/packages/WORKSPACE:30:1
ERROR: An error occurred during the fetch of repository 'rust_uefi_x86_64_toolchains':
   Traceback (most recent call last):
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302
                BUILD_components.append(BUILD_for_toolchain(name = "{too...))
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302, in BUILD_components.append                BUILD_for_toolchain(name = "{toolchain_prefix}_{targ...), <3 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 153, in BUILD_for_toolchain
                "\ntoolchain(\n    name = \"{name}\",\n    exec_compatible_with = {exec_constraint_sets_serialized},\n    target_compatible_with = {target_constraint_sets_serialized},\n    toolchain = \"@{parent_workspace_name}//:{name}_impl\",\n    toolchain_type = \"@io_bazel_rules_rust//rust:toolchain\",\n)\n".format(name = name, exec_constraint_sets_...), <2 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 164, in "\ntoolchain
                serialized_constraint_set_from_triple(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 49, in serialized_constraint_set_from_triple
                triple_to_constraint_set(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 126, in triple_to_constraint_set
                system_to_constraints(system)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 82, in system_to_constraints
                _SYSTEM_TO_BUILTIN_SYS_SUFFIX[system]
key "uefi" not found in dictionary
ERROR: While resolving toolchains for target //supervisor/firmware/uefi/bootloader:bootloader: invalid registered toolchain '@rust_uefi_x86_64_toolchains//:toolchain_for_x86_64-unknown-linux-gnu': no such package '@rus
t_uefi_x86_64_toolchains//': Traceback (most recent call last):
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302
                BUILD_components.append(BUILD_for_toolchain(name = "{too...))
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302, in BUILD_components.append
                BUILD_for_toolchain(name = "{toolchain_prefix}_{targ...), <3 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 153, in BUILD_for_toolchain
                "\ntoolchain(\n    name = \"{name}\",\n    exec_compatible_with = {exec_constraint_sets_serialized},\n    target_compatible_with = {target_constraint_sets_serialized},\n    toolchain = \"@{parent_workspace_name}//:{name}_impl\",\n    toolchain_type = \"@io_bazel_rules_rust//rust:toolchain\",\n)\n".format(name = name, exec_constraint_sets_...), <2 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 164, in "\ntoolchain
                serialized_constraint_set_from_triple(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 49, in serialized_constraint_set_from_triple
                triple_to_constraint_set(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 126, in triple_to_constraint_set
                system_to_constraints(system)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 82, in system_to_constraints
                _SYSTEM_TO_BUILTIN_SYS_SUFFIX[system]
key "uefi" not found in dictionary
ERROR: Analysis of target '//supervisor/firmware/uefi/bootloader:bootloader' failed; build aborted: invalid registered toolchain '@rust_uefi_x86_64_toolchains//:toolchain_for_x86_64-unknown-linux-gnu': no such package 
'@rust_uefi_x86_64_toolchains//': Traceback (most recent call last):
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302
                BUILD_components.append(BUILD_for_toolchain(name = "{too...))
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 302, in BUILD_components.append
                BUILD_for_toolchain(name = "{toolchain_prefix}_{targ...), <3 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 153, in BUILD_for_toolchain
                "\ntoolchain(\n    name = \"{name}\",\n    exec_compatible_with = {exec_constraint_sets_serialized},\n    target_compatible_with = {target_constraint_sets_serialized},\n    toolchain = \"@{parent_workspace_name}//:{name}_impl\",\n    toolchain_type = \"@io_bazel_rules_rust//rust:toolchain\",\n)\n".format(name = name, exec_constraint_sets_...), <2 more arguments>)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 164, in "\ntoolchain
                serialized_constraint_set_from_triple(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/repositories.bzl", line 49, in serialized_constraint_set_from_triple
                triple_to_constraint_set(target_triple)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 126, in triple_to_constraint_set
                system_to_constraints(system)
        File "/home/wpieterse/.cache/bazel/_bazel_wpieterse/5d5c7017fe3d9875cbde17824b0654e6/external/io_bazel_rules_rust/rust/platform/triple_mappings.bzl", line 82, in system_to_constraints
                _SYSTEM_TO_BUILTIN_SYS_SUFFIX[system]
key "uefi" not found in dictionary
INFO: Elapsed time: 0.108s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded, 0 targets configured)
    currently loading: @bazel_tools//tools/jdk
@damienmg
Copy link
Collaborator

Hi,

Sorry for answering so late. Glad you are looking into that. We have a bunch of bindings here that defines the mapping between rust platform and various other property. uefi is unknown so either you need to update the system or (most probably) add it to the triple_mappings.

cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 3, 2021
Pursuand to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 3, 2021
Pursuand to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 17, 2021
Pursuand to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 30, 2021
Pursuand to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 30, 2021
Pursuant to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
cceckman added a commit to cceckman/rules_rust that referenced this issue Jan 30, 2021
Pursuant to bazelbuild#256.

- Add "cpu" constraint fulfillments for "riscv32imac" and "riscv64imac",
  matching the CPU strings available in the Rust toolchain for
  bare-metal builds.
- Add mappings for the "none" OS constraint, which is available upstream
  in bazelbuild/platforms.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants