xref: /aosp_15_r20/external/pigweed/pw_toolchain/rust/toolchains.bzl (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14"""Rust toolchain configuration"""
15
16HOSTS = [
17    {
18        "cipd_arch": "arm64",
19        "cpu": "aarch64",
20        "dylib_ext": ".so",
21        "os": "linux",
22        "triple": "aarch64-unknown-linux-gnu",
23    },
24    {
25        "cipd_arch": "amd64",
26        "cpu": "x86_64",
27        "dylib_ext": ".so",
28        "os": "linux",
29        "triple": "x86_64-unknown-linux-gnu",
30    },
31    {
32        "cipd_arch": "arm64",
33        "cpu": "aarch64",
34        "dylib_ext": ".dylib",
35        "os": "macos",
36        "triple": "aarch64-apple-darwin",
37    },
38    {
39        "cipd_arch": "amd64",
40        "cpu": "x86_64",
41        "dylib_ext": ".dylib",
42        "os": "macos",
43        "triple": "x86_64-apple-darwin",
44    },
45]
46
47EXTRA_TARGETS = [
48    {
49        "cpu": "armv6-m",
50        "triple": "thumbv6m-none-eabi",
51    },
52    {
53        "cpu": "armv7-m",
54        "triple": "thumbv7m-none-eabi",
55    },
56    {
57        "cpu": "armv7e-m",
58        "triple": "thumbv7m-none-eabi",
59    },
60    {
61        "cpu": "armv8-m",
62        "triple": "thumbv7m-none-eabi",  # TODO: https://pwbug.dev/352342797 - This should be some variant of ARMv8-M.
63    },
64]
65
66CHANNELS = [
67    {
68        "extra_rustc_flags": ["-Dwarnings", "-Zmacro-backtrace"],
69        "name": "nightly",
70        "target_settings": ["@rules_rust//rust/toolchain/channel:nightly"],
71    },
72    {
73        # In order to approximate a stable toolchain with our nightly one, we
74        # disable experimental features with the exception of `proc_macro_span`
75        # because the `proc-marcro2` automatically detects the toolchain
76        # as nightly and dynamically uses this feature.
77        "extra_rustc_flags": ["-Dwarnings", "-Zallow-features=proc_macro_span,rustc_attrs"],
78        "name": "stable",
79        "target_settings": ["@rules_rust//rust/toolchain/channel:stable"],
80    },
81]
82