xref: /aosp_15_r20/external/bazelbuild-rules_rust/docs/rust_repositories.md (revision d4726bddaa87cc4778e7472feed243fa4b6c267f)
1*d4726bddSHONG Yifan<!-- Generated with Stardoc: http://skydoc.bazel.build -->
2*d4726bddSHONG Yifan# Rust Repositories
3*d4726bddSHONG Yifan
4*d4726bddSHONG Yifan* [rules_rust_dependencies](#rules_rust_dependencies)
5*d4726bddSHONG Yifan* [rust_analyzer_toolchain_repository](#rust_analyzer_toolchain_repository)
6*d4726bddSHONG Yifan* [rust_register_toolchains](#rust_register_toolchains)
7*d4726bddSHONG Yifan* [rust_repositories](#rust_repositories)
8*d4726bddSHONG Yifan* [rust_repository_set](#rust_repository_set)
9*d4726bddSHONG Yifan* [rust_stdlib_filegroup](#rust_stdlib_filegroup)
10*d4726bddSHONG Yifan* [rust_toolchain_repository_proxy](#rust_toolchain_repository_proxy)
11*d4726bddSHONG Yifan* [rust_toolchain_repository](#rust_toolchain_repository)
12*d4726bddSHONG Yifan* [rust_toolchain_tools_repository](#rust_toolchain_tools_repository)
13*d4726bddSHONG Yifan* [rust_toolchain](#rust_toolchain)
14*d4726bddSHONG Yifan
15*d4726bddSHONG Yifan<a id="rust_stdlib_filegroup"></a>
16*d4726bddSHONG Yifan
17*d4726bddSHONG Yifan## rust_stdlib_filegroup
18*d4726bddSHONG Yifan
19*d4726bddSHONG Yifan<pre>
20*d4726bddSHONG Yifanrust_stdlib_filegroup(<a href="#rust_stdlib_filegroup-name">name</a>, <a href="#rust_stdlib_filegroup-srcs">srcs</a>)
21*d4726bddSHONG Yifan</pre>
22*d4726bddSHONG Yifan
23*d4726bddSHONG YifanA dedicated filegroup-like rule for Rust stdlib artifacts.
24*d4726bddSHONG Yifan
25*d4726bddSHONG Yifan**ATTRIBUTES**
26*d4726bddSHONG Yifan
27*d4726bddSHONG Yifan
28*d4726bddSHONG Yifan| Name  | Description | Type | Mandatory | Default |
29*d4726bddSHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
30*d4726bddSHONG Yifan| <a id="rust_stdlib_filegroup-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
31*d4726bddSHONG Yifan| <a id="rust_stdlib_filegroup-srcs"></a>srcs |  The list of targets/files that are components of the rust-stdlib file group   | <a href="https://bazel.build/concepts/labels">List of labels</a> | required |  |
32*d4726bddSHONG Yifan
33*d4726bddSHONG Yifan
34*d4726bddSHONG Yifan<a id="rust_toolchain"></a>
35*d4726bddSHONG Yifan
36*d4726bddSHONG Yifan## rust_toolchain
37*d4726bddSHONG Yifan
38*d4726bddSHONG Yifan<pre>
39*d4726bddSHONG Yifanrust_toolchain(<a href="#rust_toolchain-name">name</a>, <a href="#rust_toolchain-allocator_library">allocator_library</a>, <a href="#rust_toolchain-binary_ext">binary_ext</a>, <a href="#rust_toolchain-cargo">cargo</a>, <a href="#rust_toolchain-cargo_clippy">cargo_clippy</a>, <a href="#rust_toolchain-clippy_driver">clippy_driver</a>, <a href="#rust_toolchain-debug_info">debug_info</a>,
40*d4726bddSHONG Yifan               <a href="#rust_toolchain-default_edition">default_edition</a>, <a href="#rust_toolchain-dylib_ext">dylib_ext</a>, <a href="#rust_toolchain-env">env</a>, <a href="#rust_toolchain-exec_triple">exec_triple</a>, <a href="#rust_toolchain-experimental_link_std_dylib">experimental_link_std_dylib</a>,
41*d4726bddSHONG Yifan               <a href="#rust_toolchain-experimental_use_cc_common_link">experimental_use_cc_common_link</a>, <a href="#rust_toolchain-extra_exec_rustc_flags">extra_exec_rustc_flags</a>, <a href="#rust_toolchain-extra_rustc_flags">extra_rustc_flags</a>,
42*d4726bddSHONG Yifan               <a href="#rust_toolchain-extra_rustc_flags_for_crate_types">extra_rustc_flags_for_crate_types</a>, <a href="#rust_toolchain-global_allocator_library">global_allocator_library</a>, <a href="#rust_toolchain-llvm_cov">llvm_cov</a>, <a href="#rust_toolchain-llvm_profdata">llvm_profdata</a>,
43*d4726bddSHONG Yifan               <a href="#rust_toolchain-llvm_tools">llvm_tools</a>, <a href="#rust_toolchain-opt_level">opt_level</a>, <a href="#rust_toolchain-per_crate_rustc_flags">per_crate_rustc_flags</a>, <a href="#rust_toolchain-rust_doc">rust_doc</a>, <a href="#rust_toolchain-rust_std">rust_std</a>, <a href="#rust_toolchain-rustc">rustc</a>, <a href="#rust_toolchain-rustc_lib">rustc_lib</a>,
44*d4726bddSHONG Yifan               <a href="#rust_toolchain-rustfmt">rustfmt</a>, <a href="#rust_toolchain-staticlib_ext">staticlib_ext</a>, <a href="#rust_toolchain-stdlib_linkflags">stdlib_linkflags</a>, <a href="#rust_toolchain-strip_level">strip_level</a>, <a href="#rust_toolchain-target_json">target_json</a>, <a href="#rust_toolchain-target_triple">target_triple</a>)
45*d4726bddSHONG Yifan</pre>
46*d4726bddSHONG Yifan
47*d4726bddSHONG YifanDeclares a Rust toolchain for use.
48*d4726bddSHONG Yifan
49*d4726bddSHONG YifanThis is for declaring a custom toolchain, eg. for configuring a particular version of rust or supporting a new platform.
50*d4726bddSHONG Yifan
51*d4726bddSHONG YifanExample:
52*d4726bddSHONG Yifan
53*d4726bddSHONG YifanSuppose the core rust team has ported the compiler to a new target CPU, called `cpuX`. This support can be used in Bazel by defining a new toolchain definition and declaration:
54*d4726bddSHONG Yifan
55*d4726bddSHONG Yifan```python
56*d4726bddSHONG Yifanload('@rules_rust//rust:toolchain.bzl', 'rust_toolchain')
57*d4726bddSHONG Yifan
58*d4726bddSHONG Yifanrust_toolchain(
59*d4726bddSHONG Yifan    name = "rust_cpuX_impl",
60*d4726bddSHONG Yifan    binary_ext = "",
61*d4726bddSHONG Yifan    dylib_ext = ".so",
62*d4726bddSHONG Yifan    exec_triple = "cpuX-unknown-linux-gnu",
63*d4726bddSHONG Yifan    rust_doc = "@rust_cpuX//:rustdoc",
64*d4726bddSHONG Yifan    rust_std = "@rust_cpuX//:rust_std",
65*d4726bddSHONG Yifan    rustc = "@rust_cpuX//:rustc",
66*d4726bddSHONG Yifan    rustc_lib = "@rust_cpuX//:rustc_lib",
67*d4726bddSHONG Yifan    staticlib_ext = ".a",
68*d4726bddSHONG Yifan    stdlib_linkflags = ["-lpthread", "-ldl"],
69*d4726bddSHONG Yifan    target_triple = "cpuX-unknown-linux-gnu",
70*d4726bddSHONG Yifan)
71*d4726bddSHONG Yifan
72*d4726bddSHONG Yifantoolchain(
73*d4726bddSHONG Yifan    name = "rust_cpuX",
74*d4726bddSHONG Yifan    exec_compatible_with = [
75*d4726bddSHONG Yifan        "@platforms//cpu:cpuX",
76*d4726bddSHONG Yifan        "@platforms//os:linux",
77*d4726bddSHONG Yifan    ],
78*d4726bddSHONG Yifan    target_compatible_with = [
79*d4726bddSHONG Yifan        "@platforms//cpu:cpuX",
80*d4726bddSHONG Yifan        "@platforms//os:linux",
81*d4726bddSHONG Yifan    ],
82*d4726bddSHONG Yifan    toolchain = ":rust_cpuX_impl",
83*d4726bddSHONG Yifan)
84*d4726bddSHONG Yifan```
85*d4726bddSHONG Yifan
86*d4726bddSHONG YifanThen, either add the label of the toolchain rule to `register_toolchains` in the WORKSPACE, or pass it to the `"--extra_toolchains"` flag for Bazel, and it will be used.
87*d4726bddSHONG Yifan
88*d4726bddSHONG YifanSee `@rules_rust//rust:repositories.bzl` for examples of defining the `@rust_cpuX` repository with the actual binaries and libraries.
89*d4726bddSHONG Yifan
90*d4726bddSHONG Yifan**ATTRIBUTES**
91*d4726bddSHONG Yifan
92*d4726bddSHONG Yifan
93*d4726bddSHONG Yifan| Name  | Description | Type | Mandatory | Default |
94*d4726bddSHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
95*d4726bddSHONG Yifan| <a id="rust_toolchain-name"></a>name |  A unique name for this target.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
96*d4726bddSHONG Yifan| <a id="rust_toolchain-allocator_library"></a>allocator_library |  Target that provides allocator functions when rust_library targets are embedded in a cc_binary.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_rust//ffi/cc/allocator_library"`  |
97*d4726bddSHONG Yifan| <a id="rust_toolchain-binary_ext"></a>binary_ext |  The extension for binaries created from rustc.   | String | required |  |
98*d4726bddSHONG Yifan| <a id="rust_toolchain-cargo"></a>cargo |  The location of the `cargo` binary. Can be a direct source or a filegroup containing one item.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
99*d4726bddSHONG Yifan| <a id="rust_toolchain-cargo_clippy"></a>cargo_clippy |  The location of the `cargo_clippy` binary. Can be a direct source or a filegroup containing one item.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
100*d4726bddSHONG Yifan| <a id="rust_toolchain-clippy_driver"></a>clippy_driver |  The location of the `clippy-driver` binary. Can be a direct source or a filegroup containing one item.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
101*d4726bddSHONG Yifan| <a id="rust_toolchain-debug_info"></a>debug_info |  Rustc debug info levels per opt level   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{"dbg": "2", "fastbuild": "0", "opt": "0"}`  |
102*d4726bddSHONG Yifan| <a id="rust_toolchain-default_edition"></a>default_edition |  The edition to use for rust_* rules that don't specify an edition. If absent, every rule is required to specify its `edition` attribute.   | String | optional |  `""`  |
103*d4726bddSHONG Yifan| <a id="rust_toolchain-dylib_ext"></a>dylib_ext |  The extension for dynamic libraries created from rustc.   | String | required |  |
104*d4726bddSHONG Yifan| <a id="rust_toolchain-env"></a>env |  Environment variables to set in actions.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
105*d4726bddSHONG Yifan| <a id="rust_toolchain-exec_triple"></a>exec_triple |  The platform triple for the toolchains execution environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations   | String | required |  |
106*d4726bddSHONG Yifan| <a id="rust_toolchain-experimental_link_std_dylib"></a>experimental_link_std_dylib |  Label to a boolean build setting that controls whether whether to link libstd dynamically.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_rust//rust/settings:experimental_link_std_dylib"`  |
107*d4726bddSHONG Yifan| <a id="rust_toolchain-experimental_use_cc_common_link"></a>experimental_use_cc_common_link |  Label to a boolean build setting that controls whether cc_common.link is used to link rust binaries.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_rust//rust/settings:experimental_use_cc_common_link"`  |
108*d4726bddSHONG Yifan| <a id="rust_toolchain-extra_exec_rustc_flags"></a>extra_exec_rustc_flags |  Extra flags to pass to rustc in exec configuration   | List of strings | optional |  `[]`  |
109*d4726bddSHONG Yifan| <a id="rust_toolchain-extra_rustc_flags"></a>extra_rustc_flags |  Extra flags to pass to rustc in non-exec configuration. Subject to location expansion with respect to the srcs of the `rust_std` attribute.   | List of strings | optional |  `[]`  |
110*d4726bddSHONG Yifan| <a id="rust_toolchain-extra_rustc_flags_for_crate_types"></a>extra_rustc_flags_for_crate_types |  Extra flags to pass to rustc based on crate type   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> List of strings</a> | optional |  `{}`  |
111*d4726bddSHONG Yifan| <a id="rust_toolchain-global_allocator_library"></a>global_allocator_library |  Target that provides allocator functions for when a global allocator is present.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `"@rules_rust//ffi/cc/global_allocator_library"`  |
112*d4726bddSHONG Yifan| <a id="rust_toolchain-llvm_cov"></a>llvm_cov |  The location of the `llvm-cov` binary. Can be a direct source or a filegroup containing one item. If None, rust code is not instrumented for coverage.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
113*d4726bddSHONG Yifan| <a id="rust_toolchain-llvm_profdata"></a>llvm_profdata |  The location of the `llvm-profdata` binary. Can be a direct source or a filegroup containing one item. If `llvm_cov` is None, this can be None as well and rust code is not instrumented for coverage.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
114*d4726bddSHONG Yifan| <a id="rust_toolchain-llvm_tools"></a>llvm_tools |  LLVM tools that are shipped with the Rust toolchain.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
115*d4726bddSHONG Yifan| <a id="rust_toolchain-opt_level"></a>opt_level |  Rustc optimization levels.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{"dbg": "0", "fastbuild": "0", "opt": "3"}`  |
116*d4726bddSHONG Yifan| <a id="rust_toolchain-per_crate_rustc_flags"></a>per_crate_rustc_flags |  Extra flags to pass to rustc in non-exec configuration   | List of strings | optional |  `[]`  |
117*d4726bddSHONG Yifan| <a id="rust_toolchain-rust_doc"></a>rust_doc |  The location of the `rustdoc` binary. Can be a direct source or a filegroup containing one item.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
118*d4726bddSHONG Yifan| <a id="rust_toolchain-rust_std"></a>rust_std |  The Rust standard library.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
119*d4726bddSHONG Yifan| <a id="rust_toolchain-rustc"></a>rustc |  The location of the `rustc` binary. Can be a direct source or a filegroup containing one item.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
120*d4726bddSHONG Yifan| <a id="rust_toolchain-rustc_lib"></a>rustc_lib |  The libraries used by rustc during compilation.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
121*d4726bddSHONG Yifan| <a id="rust_toolchain-rustfmt"></a>rustfmt |  **Deprecated**: Instead see [rustfmt_toolchain](#rustfmt_toolchain)   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
122*d4726bddSHONG Yifan| <a id="rust_toolchain-staticlib_ext"></a>staticlib_ext |  The extension for static libraries created from rustc.   | String | required |  |
123*d4726bddSHONG Yifan| <a id="rust_toolchain-stdlib_linkflags"></a>stdlib_linkflags |  Additional linker flags to use when Rust standard library is linked by a C++ linker (rustc will deal with these automatically). Subject to location expansion with respect to the srcs of the `rust_std` attribute.   | List of strings | required |  |
124*d4726bddSHONG Yifan| <a id="rust_toolchain-strip_level"></a>strip_level |  Rustc strip levels. For all potential options, see https://doc.rust-lang.org/rustc/codegen-options/index.html#strip   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{"dbg": "none", "fastbuild": "none", "opt": "debuginfo"}`  |
125*d4726bddSHONG Yifan| <a id="rust_toolchain-target_json"></a>target_json |  Override the target_triple with a custom target specification. For more details see: https://doc.rust-lang.org/rustc/targets/custom.html   | String | optional |  `""`  |
126*d4726bddSHONG Yifan| <a id="rust_toolchain-target_triple"></a>target_triple |  The platform triple for the toolchains target environment. For more details see: https://docs.bazel.build/versions/master/skylark/rules.html#configurations   | String | optional |  `""`  |
127*d4726bddSHONG Yifan
128*d4726bddSHONG Yifan
129*d4726bddSHONG Yifan<a id="rules_rust_dependencies"></a>
130*d4726bddSHONG Yifan
131*d4726bddSHONG Yifan## rules_rust_dependencies
132*d4726bddSHONG Yifan
133*d4726bddSHONG Yifan<pre>
134*d4726bddSHONG Yifanrules_rust_dependencies()
135*d4726bddSHONG Yifan</pre>
136*d4726bddSHONG Yifan
137*d4726bddSHONG YifanDependencies used in the implementation of `rules_rust`.
138*d4726bddSHONG Yifan
139*d4726bddSHONG Yifan
140*d4726bddSHONG Yifan
141*d4726bddSHONG Yifan<a id="rust_analyzer_toolchain_repository"></a>
142*d4726bddSHONG Yifan
143*d4726bddSHONG Yifan## rust_analyzer_toolchain_repository
144*d4726bddSHONG Yifan
145*d4726bddSHONG Yifan<pre>
146*d4726bddSHONG Yifanrust_analyzer_toolchain_repository(<a href="#rust_analyzer_toolchain_repository-name">name</a>, <a href="#rust_analyzer_toolchain_repository-version">version</a>, <a href="#rust_analyzer_toolchain_repository-exec_compatible_with">exec_compatible_with</a>, <a href="#rust_analyzer_toolchain_repository-target_compatible_with">target_compatible_with</a>,
147*d4726bddSHONG Yifan                                   <a href="#rust_analyzer_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_analyzer_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_analyzer_toolchain_repository-urls">urls</a>, <a href="#rust_analyzer_toolchain_repository-auth">auth</a>, <a href="#rust_analyzer_toolchain_repository-netrc">netrc</a>, <a href="#rust_analyzer_toolchain_repository-auth_patterns">auth_patterns</a>)
148*d4726bddSHONG Yifan</pre>
149*d4726bddSHONG Yifan
150*d4726bddSHONG YifanAssemble a remote rust_analyzer_toolchain target based on the given params.
151*d4726bddSHONG Yifan
152*d4726bddSHONG Yifan**PARAMETERS**
153*d4726bddSHONG Yifan
154*d4726bddSHONG Yifan
155*d4726bddSHONG Yifan| Name  | Description | Default Value |
156*d4726bddSHONG Yifan| :------------- | :------------- | :------------- |
157*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-name"></a>name |  The name of the toolchain proxy repository contianing the registerable toolchain.   |  none |
158*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-version"></a>version |  The version of the tool among "nightly", "beta', or an exact version.   |  none |
159*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-exec_compatible_with"></a>exec_compatible_with |  A list of constraints for the execution platform for this toolchain.   |  `[]` |
160*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-target_compatible_with"></a>target_compatible_with |  A list of constraints for the target platform for this toolchain.   |  `[]` |
161*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-iso_date"></a>iso_date |  The date of the tool.   |  `None` |
162*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-sha256s"></a>sha256s |  A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details.   |  `None` |
163*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-urls"></a>urls |  A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.xz']   |  `None` |
164*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-auth"></a>auth |  Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details.   |  `None` |
165*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-netrc"></a>netrc |  .netrc file to use for authentication; mirrors the eponymous attribute from http_archive   |  `None` |
166*d4726bddSHONG Yifan| <a id="rust_analyzer_toolchain_repository-auth_patterns"></a>auth_patterns |  Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive   |  `None` |
167*d4726bddSHONG Yifan
168*d4726bddSHONG Yifan**RETURNS**
169*d4726bddSHONG Yifan
170*d4726bddSHONG Yifanstr: The name of a registerable rust_analyzer_toolchain.
171*d4726bddSHONG Yifan
172*d4726bddSHONG Yifan
173*d4726bddSHONG Yifan<a id="rust_register_toolchains"></a>
174*d4726bddSHONG Yifan
175*d4726bddSHONG Yifan## rust_register_toolchains
176*d4726bddSHONG Yifan
177*d4726bddSHONG Yifan<pre>
178*d4726bddSHONG Yifanrust_register_toolchains(<a href="#rust_register_toolchains-dev_components">dev_components</a>, <a href="#rust_register_toolchains-edition">edition</a>, <a href="#rust_register_toolchains-allocator_library">allocator_library</a>, <a href="#rust_register_toolchains-global_allocator_library">global_allocator_library</a>,
179*d4726bddSHONG Yifan                         <a href="#rust_register_toolchains-iso_date">iso_date</a>, <a href="#rust_register_toolchains-register_toolchains">register_toolchains</a>, <a href="#rust_register_toolchains-rustfmt_version">rustfmt_version</a>, <a href="#rust_register_toolchains-rust_analyzer_version">rust_analyzer_version</a>,
180*d4726bddSHONG Yifan                         <a href="#rust_register_toolchains-sha256s">sha256s</a>, <a href="#rust_register_toolchains-extra_target_triples">extra_target_triples</a>, <a href="#rust_register_toolchains-extra_rustc_flags">extra_rustc_flags</a>, <a href="#rust_register_toolchains-extra_exec_rustc_flags">extra_exec_rustc_flags</a>,
181*d4726bddSHONG Yifan                         <a href="#rust_register_toolchains-urls">urls</a>, <a href="#rust_register_toolchains-version">version</a>, <a href="#rust_register_toolchains-versions">versions</a>)
182*d4726bddSHONG Yifan</pre>
183*d4726bddSHONG Yifan
184*d4726bddSHONG YifanEmits a default set of toolchains for Linux, MacOS, and Freebsd
185*d4726bddSHONG Yifan
186*d4726bddSHONG YifanSkip this macro and call the `rust_repository_set` macros directly if you need a compiler for     other hosts or for additional target triples.
187*d4726bddSHONG Yifan
188*d4726bddSHONG YifanThe `sha256s` attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:
189*d4726bddSHONG Yifan```python
190*d4726bddSHONG Yifan{
191*d4726bddSHONG Yifan    "rust-1.46.0-x86_64-unknown-linux-gnu": "e3b98bc3440fe92817881933f9564389eccb396f5f431f33d48b979fa2fbdcf5",
192*d4726bddSHONG Yifan    "rustfmt-1.4.12-x86_64-unknown-linux-gnu": "1894e76913303d66bf40885a601462844eec15fca9e76a6d13c390d7000d64b0",
193*d4726bddSHONG Yifan    "rust-std-1.46.0-x86_64-unknown-linux-gnu": "ac04aef80423f612c0079829b504902de27a6997214eb58ab0765d02f7ec1dbc",
194*d4726bddSHONG Yifan}
195*d4726bddSHONG Yifan```
196*d4726bddSHONG YifanThis would match for `exec_triple = "x86_64-unknown-linux-gnu"`.  If not specified, rules_rust pulls from a non-exhaustive     list of known checksums..
197*d4726bddSHONG Yifan
198*d4726bddSHONG YifanSee `load_arbitrary_tool` in `@rules_rust//rust:repositories.bzl` for more details.
199*d4726bddSHONG Yifan
200*d4726bddSHONG Yifan
201*d4726bddSHONG Yifan**PARAMETERS**
202*d4726bddSHONG Yifan
203*d4726bddSHONG Yifan
204*d4726bddSHONG Yifan| Name  | Description | Default Value |
205*d4726bddSHONG Yifan| :------------- | :------------- | :------------- |
206*d4726bddSHONG Yifan| <a id="rust_register_toolchains-dev_components"></a>dev_components |  Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".   |  `False` |
207*d4726bddSHONG Yifan| <a id="rust_register_toolchains-edition"></a>edition |  The rust edition to be used by default (2015, 2018, or 2021). If absent, every target is required to specify its `edition` attribute.   |  `None` |
208*d4726bddSHONG Yifan| <a id="rust_register_toolchains-allocator_library"></a>allocator_library |  Target that provides allocator functions when rust_library targets are embedded in a cc_binary.   |  `None` |
209*d4726bddSHONG Yifan| <a id="rust_register_toolchains-global_allocator_library"></a>global_allocator_library |  Target that provides allocator functions when global allocator is used with cc_common.link.   |  `None` |
210*d4726bddSHONG Yifan| <a id="rust_register_toolchains-iso_date"></a>iso_date |  **Deprecated**: Use `versions` instead.   |  `None` |
211*d4726bddSHONG Yifan| <a id="rust_register_toolchains-register_toolchains"></a>register_toolchains |  If true, repositories will be generated to produce and register `rust_toolchain` targets.   |  `True` |
212*d4726bddSHONG Yifan| <a id="rust_register_toolchains-rustfmt_version"></a>rustfmt_version |  The version of rustfmt. If none is supplied and only a single version in `versions` is given, then this defaults to that version, otherwise will default to the default nightly version.   |  `None` |
213*d4726bddSHONG Yifan| <a id="rust_register_toolchains-rust_analyzer_version"></a>rust_analyzer_version |  The version of Rustc to pair with rust-analyzer.   |  `None` |
214*d4726bddSHONG Yifan| <a id="rust_register_toolchains-sha256s"></a>sha256s |  A dict associating tool subdirectories to sha256 hashes.   |  `None` |
215*d4726bddSHONG Yifan| <a id="rust_register_toolchains-extra_target_triples"></a>extra_target_triples |  Additional rust-style targets that rust toolchains should support.   |  `["wasm32-unknown-unknown", "wasm32-wasi"]` |
216*d4726bddSHONG Yifan| <a id="rust_register_toolchains-extra_rustc_flags"></a>extra_rustc_flags |  Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.   |  `None` |
217*d4726bddSHONG Yifan| <a id="rust_register_toolchains-extra_exec_rustc_flags"></a>extra_exec_rustc_flags |  Extra flags to pass to rustc in exec configuration.   |  `None` |
218*d4726bddSHONG Yifan| <a id="rust_register_toolchains-urls"></a>urls |  A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).   |  `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
219*d4726bddSHONG Yifan| <a id="rust_register_toolchains-version"></a>version |  **Deprecated**: Use `versions` instead.   |  `None` |
220*d4726bddSHONG Yifan| <a id="rust_register_toolchains-versions"></a>versions |  A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`.   |  `[]` |
221*d4726bddSHONG Yifan
222*d4726bddSHONG Yifan
223*d4726bddSHONG Yifan<a id="rust_repositories"></a>
224*d4726bddSHONG Yifan
225*d4726bddSHONG Yifan## rust_repositories
226*d4726bddSHONG Yifan
227*d4726bddSHONG Yifan<pre>
228*d4726bddSHONG Yifanrust_repositories(<a href="#rust_repositories-kwargs">kwargs</a>)
229*d4726bddSHONG Yifan</pre>
230*d4726bddSHONG Yifan
231*d4726bddSHONG Yifan**Deprecated**: Use [rules_rust_dependencies](#rules_rust_dependencies)     and [rust_register_toolchains](#rust_register_toolchains) directly.
232*d4726bddSHONG Yifan
233*d4726bddSHONG Yifan**PARAMETERS**
234*d4726bddSHONG Yifan
235*d4726bddSHONG Yifan
236*d4726bddSHONG Yifan| Name  | Description | Default Value |
237*d4726bddSHONG Yifan| :------------- | :------------- | :------------- |
238*d4726bddSHONG Yifan| <a id="rust_repositories-kwargs"></a>kwargs |  Keyword arguments for the `rust_register_toolchains` macro.   |  none |
239*d4726bddSHONG Yifan
240*d4726bddSHONG Yifan
241*d4726bddSHONG Yifan<a id="rust_repository_set"></a>
242*d4726bddSHONG Yifan
243*d4726bddSHONG Yifan## rust_repository_set
244*d4726bddSHONG Yifan
245*d4726bddSHONG Yifan<pre>
246*d4726bddSHONG Yifanrust_repository_set(<a href="#rust_repository_set-name">name</a>, <a href="#rust_repository_set-exec_triple">exec_triple</a>, <a href="#rust_repository_set-target_settings">target_settings</a>, <a href="#rust_repository_set-version">version</a>, <a href="#rust_repository_set-versions">versions</a>, <a href="#rust_repository_set-allocator_library">allocator_library</a>,
247*d4726bddSHONG Yifan                    <a href="#rust_repository_set-global_allocator_library">global_allocator_library</a>, <a href="#rust_repository_set-extra_target_triples">extra_target_triples</a>, <a href="#rust_repository_set-iso_date">iso_date</a>, <a href="#rust_repository_set-rustfmt_version">rustfmt_version</a>,
248*d4726bddSHONG Yifan                    <a href="#rust_repository_set-edition">edition</a>, <a href="#rust_repository_set-dev_components">dev_components</a>, <a href="#rust_repository_set-extra_rustc_flags">extra_rustc_flags</a>, <a href="#rust_repository_set-extra_exec_rustc_flags">extra_exec_rustc_flags</a>, <a href="#rust_repository_set-opt_level">opt_level</a>,
249*d4726bddSHONG Yifan                    <a href="#rust_repository_set-sha256s">sha256s</a>, <a href="#rust_repository_set-urls">urls</a>, <a href="#rust_repository_set-auth">auth</a>, <a href="#rust_repository_set-netrc">netrc</a>, <a href="#rust_repository_set-auth_patterns">auth_patterns</a>, <a href="#rust_repository_set-register_toolchain">register_toolchain</a>,
250*d4726bddSHONG Yifan                    <a href="#rust_repository_set-exec_compatible_with">exec_compatible_with</a>, <a href="#rust_repository_set-default_target_compatible_with">default_target_compatible_with</a>)
251*d4726bddSHONG Yifan</pre>
252*d4726bddSHONG Yifan
253*d4726bddSHONG YifanAssembles a remote repository for the given toolchain params, produces a proxy repository     to contain the toolchain declaration, and registers the toolchains.
254*d4726bddSHONG Yifan
255*d4726bddSHONG Yifan**PARAMETERS**
256*d4726bddSHONG Yifan
257*d4726bddSHONG Yifan
258*d4726bddSHONG Yifan| Name  | Description | Default Value |
259*d4726bddSHONG Yifan| :------------- | :------------- | :------------- |
260*d4726bddSHONG Yifan| <a id="rust_repository_set-name"></a>name |  The name of the generated repository   |  none |
261*d4726bddSHONG Yifan| <a id="rust_repository_set-exec_triple"></a>exec_triple |  The Rust-style target that this compiler runs on   |  none |
262*d4726bddSHONG Yifan| <a id="rust_repository_set-target_settings"></a>target_settings |  A list of config_settings that must be satisfied by the target configuration in order for this set of toolchains to be selected during toolchain resolution.   |  `[]` |
263*d4726bddSHONG Yifan| <a id="rust_repository_set-version"></a>version |  The version of the tool among "nightly", "beta', or an exact version.   |  `None` |
264*d4726bddSHONG Yifan| <a id="rust_repository_set-versions"></a>versions |  A list of toolchain versions to download. This paramter only accepts one versions per channel. E.g. `["1.65.0", "nightly/2022-11-02", "beta/2020-12-30"]`.   |  `[]` |
265*d4726bddSHONG Yifan| <a id="rust_repository_set-allocator_library"></a>allocator_library |  Target that provides allocator functions when rust_library targets are embedded in a cc_binary.   |  `None` |
266*d4726bddSHONG Yifan| <a id="rust_repository_set-global_allocator_library"></a>global_allocator_library |  Target that provides allocator functions a global allocator is used with cc_common.link.   |  `None` |
267*d4726bddSHONG Yifan| <a id="rust_repository_set-extra_target_triples"></a>extra_target_triples |  Additional rust-style targets that this set of toolchains should support. If a map, values should be (optional) target_compatible_with lists for that particular target triple.   |  `{}` |
268*d4726bddSHONG Yifan| <a id="rust_repository_set-iso_date"></a>iso_date |  The date of the tool.   |  `None` |
269*d4726bddSHONG Yifan| <a id="rust_repository_set-rustfmt_version"></a>rustfmt_version |  The version of rustfmt to be associated with the toolchain.   |  `None` |
270*d4726bddSHONG Yifan| <a id="rust_repository_set-edition"></a>edition |  The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.   |  `None` |
271*d4726bddSHONG Yifan| <a id="rust_repository_set-dev_components"></a>dev_components |  Whether to download the rustc-dev components. Requires version to be "nightly".   |  `False` |
272*d4726bddSHONG Yifan| <a id="rust_repository_set-extra_rustc_flags"></a>extra_rustc_flags |  Dictionary of target triples to list of extra flags to pass to rustc in non-exec configuration.   |  `None` |
273*d4726bddSHONG Yifan| <a id="rust_repository_set-extra_exec_rustc_flags"></a>extra_exec_rustc_flags |  Extra flags to pass to rustc in exec configuration.   |  `None` |
274*d4726bddSHONG Yifan| <a id="rust_repository_set-opt_level"></a>opt_level |  Dictionary of target triples to optimiztion config.   |  `None` |
275*d4726bddSHONG Yifan| <a id="rust_repository_set-sha256s"></a>sha256s |  A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details.   |  `None` |
276*d4726bddSHONG Yifan| <a id="rust_repository_set-urls"></a>urls |  A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).   |  `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
277*d4726bddSHONG Yifan| <a id="rust_repository_set-auth"></a>auth |  Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details.   |  `None` |
278*d4726bddSHONG Yifan| <a id="rust_repository_set-netrc"></a>netrc |  .netrc file to use for authentication; mirrors the eponymous attribute from http_archive   |  `None` |
279*d4726bddSHONG Yifan| <a id="rust_repository_set-auth_patterns"></a>auth_patterns |  Override mapping of hostnames to authorization patterns; mirrors the eponymous attribute from http_archive   |  `None` |
280*d4726bddSHONG Yifan| <a id="rust_repository_set-register_toolchain"></a>register_toolchain |  If True, the generated `rust_toolchain` target will become a registered toolchain.   |  `True` |
281*d4726bddSHONG Yifan| <a id="rust_repository_set-exec_compatible_with"></a>exec_compatible_with |  A list of constraints for the execution platform for this toolchain.   |  `None` |
282*d4726bddSHONG Yifan| <a id="rust_repository_set-default_target_compatible_with"></a>default_target_compatible_with |  A list of constraints for the target platform for this toolchain when the exec platform is the same as the target platform.   |  `None` |
283*d4726bddSHONG Yifan
284*d4726bddSHONG Yifan
285*d4726bddSHONG Yifan<a id="rust_toolchain_repository"></a>
286*d4726bddSHONG Yifan
287*d4726bddSHONG Yifan## rust_toolchain_repository
288*d4726bddSHONG Yifan
289*d4726bddSHONG Yifan<pre>
290*d4726bddSHONG Yifanrust_toolchain_repository(<a href="#rust_toolchain_repository-name">name</a>, <a href="#rust_toolchain_repository-version">version</a>, <a href="#rust_toolchain_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_repository-exec_compatible_with">exec_compatible_with</a>,
291*d4726bddSHONG Yifan                          <a href="#rust_toolchain_repository-target_compatible_with">target_compatible_with</a>, <a href="#rust_toolchain_repository-target_settings">target_settings</a>, <a href="#rust_toolchain_repository-channel">channel</a>, <a href="#rust_toolchain_repository-allocator_library">allocator_library</a>,
292*d4726bddSHONG Yifan                          <a href="#rust_toolchain_repository-global_allocator_library">global_allocator_library</a>, <a href="#rust_toolchain_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_repository-edition">edition</a>,
293*d4726bddSHONG Yifan                          <a href="#rust_toolchain_repository-dev_components">dev_components</a>, <a href="#rust_toolchain_repository-extra_rustc_flags">extra_rustc_flags</a>, <a href="#rust_toolchain_repository-extra_exec_rustc_flags">extra_exec_rustc_flags</a>, <a href="#rust_toolchain_repository-opt_level">opt_level</a>,
294*d4726bddSHONG Yifan                          <a href="#rust_toolchain_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_repository-urls">urls</a>, <a href="#rust_toolchain_repository-auth">auth</a>, <a href="#rust_toolchain_repository-netrc">netrc</a>, <a href="#rust_toolchain_repository-auth_patterns">auth_patterns</a>)
295*d4726bddSHONG Yifan</pre>
296*d4726bddSHONG Yifan
297*d4726bddSHONG YifanAssembles a remote repository for the given toolchain params, produces a proxy repository     to contain the toolchain declaration, and registers the toolchains.
298*d4726bddSHONG Yifan
299*d4726bddSHONG Yifan**PARAMETERS**
300*d4726bddSHONG Yifan
301*d4726bddSHONG Yifan
302*d4726bddSHONG Yifan| Name  | Description | Default Value |
303*d4726bddSHONG Yifan| :------------- | :------------- | :------------- |
304*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-name"></a>name |  The name of the generated repository   |  none |
305*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-version"></a>version |  The version of the tool among "nightly", "beta", or an exact version.   |  none |
306*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-exec_triple"></a>exec_triple |  The Rust-style target that this compiler runs on.   |  none |
307*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-target_triple"></a>target_triple |  The Rust-style target to build for.   |  none |
308*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-exec_compatible_with"></a>exec_compatible_with |  A list of constraints for the execution platform for this toolchain.   |  `None` |
309*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-target_compatible_with"></a>target_compatible_with |  A list of constraints for the target platform for this toolchain.   |  `None` |
310*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-target_settings"></a>target_settings |  A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.   |  `[]` |
311*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-channel"></a>channel |  The channel of the Rust toolchain.   |  `None` |
312*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-allocator_library"></a>allocator_library |  Target that provides allocator functions when rust_library targets are embedded in a cc_binary.   |  `None` |
313*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-global_allocator_library"></a>global_allocator_library |  Target that provides allocator functions when a global allocator is used with cc_common.link.   |  `None` |
314*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-iso_date"></a>iso_date |  The date of the tool.   |  `None` |
315*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-rustfmt_version"></a>rustfmt_version |  The version of rustfmt to be associated with the toolchain.   |  `None` |
316*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-edition"></a>edition |  The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.   |  `None` |
317*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-dev_components"></a>dev_components |  Whether to download the rustc-dev components. Requires version to be "nightly". Defaults to False.   |  `False` |
318*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-extra_rustc_flags"></a>extra_rustc_flags |  Extra flags to pass to rustc in non-exec configuration.   |  `None` |
319*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags |  Extra flags to pass to rustc in exec configuration.   |  `None` |
320*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-opt_level"></a>opt_level |  Optimization level config for this toolchain.   |  `None` |
321*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-sha256s"></a>sha256s |  A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details.   |  `None` |
322*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-urls"></a>urls |  A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format). Defaults to ['https://static.rust-lang.org/dist/{}.tar.xz']   |  `["https://static.rust-lang.org/dist/{}.tar.xz"]` |
323*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-auth"></a>auth |  Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details.   |  `None` |
324*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-netrc"></a>netrc |  .netrc file to use for authentication; mirrors the eponymous attribute from http_archive   |  `None` |
325*d4726bddSHONG Yifan| <a id="rust_toolchain_repository-auth_patterns"></a>auth_patterns |  A list of patterns to match against urls for which the auth object should be used.   |  `None` |
326*d4726bddSHONG Yifan
327*d4726bddSHONG Yifan**RETURNS**
328*d4726bddSHONG Yifan
329*d4726bddSHONG Yifanstr: The name of the registerable toolchain created by this rule.
330*d4726bddSHONG Yifan
331*d4726bddSHONG Yifan
332*d4726bddSHONG Yifan<a id="rust_toolchain_repository_proxy"></a>
333*d4726bddSHONG Yifan
334*d4726bddSHONG Yifan## rust_toolchain_repository_proxy
335*d4726bddSHONG Yifan
336*d4726bddSHONG Yifan<pre>
337*d4726bddSHONG Yifanrust_toolchain_repository_proxy(<a href="#rust_toolchain_repository_proxy-name">name</a>, <a href="#rust_toolchain_repository_proxy-exec_compatible_with">exec_compatible_with</a>, <a href="#rust_toolchain_repository_proxy-repo_mapping">repo_mapping</a>, <a href="#rust_toolchain_repository_proxy-target_compatible_with">target_compatible_with</a>,
338*d4726bddSHONG Yifan                                <a href="#rust_toolchain_repository_proxy-target_settings">target_settings</a>, <a href="#rust_toolchain_repository_proxy-toolchain">toolchain</a>, <a href="#rust_toolchain_repository_proxy-toolchain_type">toolchain_type</a>)
339*d4726bddSHONG Yifan</pre>
340*d4726bddSHONG Yifan
341*d4726bddSHONG YifanGenerates a toolchain-bearing repository that declares the toolchains from some other rust_toolchain_repository.
342*d4726bddSHONG Yifan
343*d4726bddSHONG Yifan**ATTRIBUTES**
344*d4726bddSHONG Yifan
345*d4726bddSHONG Yifan
346*d4726bddSHONG Yifan| Name  | Description | Type | Mandatory | Default |
347*d4726bddSHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
348*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-name"></a>name |  A unique name for this repository.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
349*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-exec_compatible_with"></a>exec_compatible_with |  A list of constraints for the execution platform for this toolchain.   | List of strings | optional |  `[]`  |
350*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-repo_mapping"></a>repo_mapping |  In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function).   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  |
351*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-target_compatible_with"></a>target_compatible_with |  A list of constraints for the target platform for this toolchain.   | List of strings | optional |  `[]`  |
352*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-target_settings"></a>target_settings |  A list of config_settings that must be satisfied by the target configuration in order for this toolchain to be selected during toolchain resolution.   | List of strings | optional |  `[]`  |
353*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-toolchain"></a>toolchain |  The name of the toolchain implementation target.   | String | required |  |
354*d4726bddSHONG Yifan| <a id="rust_toolchain_repository_proxy-toolchain_type"></a>toolchain_type |  The toolchain type of the toolchain to declare   | String | required |  |
355*d4726bddSHONG Yifan
356*d4726bddSHONG Yifan
357*d4726bddSHONG Yifan<a id="rust_toolchain_tools_repository"></a>
358*d4726bddSHONG Yifan
359*d4726bddSHONG Yifan## rust_toolchain_tools_repository
360*d4726bddSHONG Yifan
361*d4726bddSHONG Yifan<pre>
362*d4726bddSHONG Yifanrust_toolchain_tools_repository(<a href="#rust_toolchain_tools_repository-name">name</a>, <a href="#rust_toolchain_tools_repository-allocator_library">allocator_library</a>, <a href="#rust_toolchain_tools_repository-auth">auth</a>, <a href="#rust_toolchain_tools_repository-auth_patterns">auth_patterns</a>, <a href="#rust_toolchain_tools_repository-dev_components">dev_components</a>,
363*d4726bddSHONG Yifan                                <a href="#rust_toolchain_tools_repository-edition">edition</a>, <a href="#rust_toolchain_tools_repository-exec_triple">exec_triple</a>, <a href="#rust_toolchain_tools_repository-extra_exec_rustc_flags">extra_exec_rustc_flags</a>, <a href="#rust_toolchain_tools_repository-extra_rustc_flags">extra_rustc_flags</a>,
364*d4726bddSHONG Yifan                                <a href="#rust_toolchain_tools_repository-global_allocator_library">global_allocator_library</a>, <a href="#rust_toolchain_tools_repository-iso_date">iso_date</a>, <a href="#rust_toolchain_tools_repository-netrc">netrc</a>, <a href="#rust_toolchain_tools_repository-opt_level">opt_level</a>, <a href="#rust_toolchain_tools_repository-repo_mapping">repo_mapping</a>,
365*d4726bddSHONG Yifan                                <a href="#rust_toolchain_tools_repository-rustfmt_version">rustfmt_version</a>, <a href="#rust_toolchain_tools_repository-sha256s">sha256s</a>, <a href="#rust_toolchain_tools_repository-target_triple">target_triple</a>, <a href="#rust_toolchain_tools_repository-urls">urls</a>, <a href="#rust_toolchain_tools_repository-version">version</a>)
366*d4726bddSHONG Yifan</pre>
367*d4726bddSHONG Yifan
368*d4726bddSHONG YifanComposes a single workspace containing the toolchain components for compiling on a given platform to a series of target platforms.
369*d4726bddSHONG Yifan
370*d4726bddSHONG YifanA given instance of this rule should be accompanied by a toolchain_repository_proxy invocation to declare its toolchains to Bazel; the indirection allows separating toolchain selection from toolchain fetching.
371*d4726bddSHONG Yifan
372*d4726bddSHONG Yifan**ATTRIBUTES**
373*d4726bddSHONG Yifan
374*d4726bddSHONG Yifan
375*d4726bddSHONG Yifan| Name  | Description | Type | Mandatory | Default |
376*d4726bddSHONG Yifan| :------------- | :------------- | :------------- | :------------- | :------------- |
377*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-name"></a>name |  A unique name for this repository.   | <a href="https://bazel.build/concepts/labels#target-names">Name</a> | required |  |
378*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-allocator_library"></a>allocator_library |  Target that provides allocator functions when rust_library targets are embedded in a cc_binary.   | String | optional |  `"@rules_rust//ffi/cc/allocator_library"`  |
379*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-auth"></a>auth |  Auth object compatible with repository_ctx.download to use when downloading files. See [repository_ctx.download](https://docs.bazel.build/versions/main/skylark/lib/repository_ctx.html#download) for more details.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
380*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-auth_patterns"></a>auth_patterns |  A list of patterns to match against urls for which the auth object should be used.   | List of strings | optional |  `[]`  |
381*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-dev_components"></a>dev_components |  Whether to download the rustc-dev components (defaults to False). Requires version to be "nightly".   | Boolean | optional |  `False`  |
382*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-edition"></a>edition |  The rust edition to be used by default (2015, 2018, or 2021). If absent, every rule is required to specify its `edition` attribute.   | String | optional |  `""`  |
383*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-exec_triple"></a>exec_triple |  The Rust-style target that this compiler runs on   | String | required |  |
384*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags |  Extra flags to pass to rustc in exec configuration   | List of strings | optional |  `[]`  |
385*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-extra_rustc_flags"></a>extra_rustc_flags |  Extra flags to pass to rustc in non-exec configuration   | List of strings | optional |  `[]`  |
386*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-global_allocator_library"></a>global_allocator_library |  Target that provides allocator functions when a global allocator is used with cc_common.link.   | String | optional |  `"@rules_rust//ffi/cc/global_allocator_library"`  |
387*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-iso_date"></a>iso_date |  The date of the tool (or None, if the version is a specific version).   | String | optional |  `""`  |
388*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-netrc"></a>netrc |  .netrc file to use for authentication; mirrors the eponymous attribute from http_archive   | String | optional |  `""`  |
389*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-opt_level"></a>opt_level |  Rustc optimization levels. For more details see the documentation for `rust_toolchain.opt_level`.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
390*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-repo_mapping"></a>repo_mapping |  In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function).   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  |
391*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-rustfmt_version"></a>rustfmt_version |  The version of the tool among "nightly", "beta", or an exact version.   | String | optional |  `""`  |
392*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-sha256s"></a>sha256s |  A dict associating tool subdirectories to sha256 hashes. See [rust_register_toolchains](#rust_register_toolchains) for more details.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
393*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-target_triple"></a>target_triple |  The Rust-style target that this compiler builds for.   | String | required |  |
394*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-urls"></a>urls |  A list of mirror urls containing the tools from the Rust-lang static file server. These must contain the '{}' used to substitute the tool being fetched (using .format).   | List of strings | optional |  `["https://static.rust-lang.org/dist/{}.tar.xz"]`  |
395*d4726bddSHONG Yifan| <a id="rust_toolchain_tools_repository-version"></a>version |  The version of the tool among "nightly", "beta", or an exact version.   | String | required |  |
396*d4726bddSHONG Yifan
397*d4726bddSHONG Yifan
398