You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updated repository rules to notify users about non-reproducible repos. (#2593)
This change updates rules_rust repository rules to report when the rules
are not guaranteed to be reproducible due to missing sha256 values when
fetching Rust artifacts. A common case for this is when users request
newer versions of Rust than the ones referenced in
[@rules_rust//rust:known_shas.bzl](https://github.com/bazelbuild/rules_rust/blob/0.41.0/rust/known_shas.bzl),
thus leading to unnecessary downloads or potential security issues.
After this PR, users will see warnings similar to when `integrity` is
omitted from `http_archive` definitions
```
DEBUG: Rule 'rust_analyzer_1.77.1_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rust-src-1.77.1.tar.xz": "ad2064aa4a444ae35d55b8b57bec837b90c4f10fe6d721f8fce86d7a1992f607", "rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77"}
DEBUG: Repository rust_analyzer_1.77.1_tools instantiated at:
/Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
/Users/user/rules_rust/rust/repositories.bzl:202:10: in rust_register_toolchains
/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
/Users/user/rules_rust/rust/repositories.bzl:737:45: in rust_analyzer_toolchain_repository
Repository rule rust_analyzer_toolchain_tools_repository defined at:
/Users/user/rules_rust/rust/repositories.bzl:705:59: in <toplevel>
DEBUG: Rule 'rust_darwin_aarch64__aarch64-apple-darwin__stable_tools' indicated that a canonical reproducible form can be obtained by modifying arguments sha256s = {"rustc-1.77.1-aarch64-apple-darwin.tar.xz": "8da1814eb8358236e88ceb155e32f0f34bbe71cb19cd9700c7eb40e675738d77", "clippy-1.77.1-aarch64-apple-darwin.tar.xz": "343f125b0c05dd756e71992c04fb5a4a29ce705c50a739d76eb7f38b088103ac", "cargo-1.77.1-aarch64-apple-darwin.tar.xz": "c0249b6c247953cbe3b01e276988b6ca600aeba4e91332cd2ddaa0b7eee4dfb7", "llvm-tools-1.77.1-aarch64-apple-darwin.tar.xz": "dfee0aaed6b24d34362f229f2926e6b1805f2a8ec4a090c7c28837b82a9bdfd1", "rust-std-1.77.1-aarch64-apple-darwin.tar.xz": "3b5b71e40d934de25dcb553b9df28289d38640e6fa2654b42410f4cc8d9bed2a"}
DEBUG: Repository rust_darwin_aarch64__aarch64-apple-darwin__stable_tools instantiated at:
/Users/user/rules_rust/WORKSPACE.bazel:7:25: in <toplevel>
/Users/user/rules_rust/rust/repositories.bzl:230:14: in rust_register_toolchains
/private/var/tmp/_bazel_user/76282c66b0dfe3c5cb9a230bdc913a52/external/bazel_tools/tools/build_defs/repo/utils.bzl:240:18: in maybe
/Users/user/rules_rust/rust/repositories.bzl:1043:61: in rust_repository_set
/Users/user/rules_rust/rust/repositories.bzl:601:36: in rust_toolchain_repository
Repository rule rust_toolchain_tools_repository defined at:
/Users/user/rules_rust/rust/repositories.bzl:475:50: in <toplevel>
```
The above was produced by running `bazel test //...` after applying the
following diff:
```diff
diff --git a/rust/private/common.bzl b/rust/private/common.bzl
index 52728fe..c035ad5 100644
--- a/rust/private/common.bzl
+++ b/rust/private/common.bzl
@@ -31,7 +31,7 @@ load(":providers.bzl", "CrateGroupInfo", "CrateInfo", "DepInfo", "DepVariantInfo
#
# Note: Code in `.github/workflows/crate_universe.yaml` looks for this line, if
# you remove it or change its format, you will also need to update that code.
-DEFAULT_RUST_VERSION = "1.77.0"
+DEFAULT_RUST_VERSION = "1.77.1"
DEFAULT_NIGHTLY_ISO_DATE = "2024-03-21"
```
closes#1825
Copy file name to clipboardExpand all lines: docs/flatten.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1321,7 +1321,7 @@ A given instance of this rule should be accompanied by a toolchain_repository_pr
1321
1321
| <aid="rust_toolchain_tools_repository-opt_level"></a>opt_level | Rustc optimization levels. For more details see the documentation for <code>rust_toolchain.opt_level</code>. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
1322
1322
| <aid="rust_toolchain_tools_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required ||
1323
1323
| <aid="rust_toolchain_tools_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | <code>""</code> |
1324
-
| <aid="rust_toolchain_tools_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
1324
+
| <aid="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. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
1325
1325
| <aid="rust_toolchain_tools_repository-target_triple"></a>target_triple | The Rust-style target that this compiler builds for. | String | required ||
1326
1326
| <aid="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 | <code>["https://static.rust-lang.org/dist/{}.tar.xz"]</code> |
1327
1327
| <aid="rust_toolchain_tools_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required ||
@@ -1740,7 +1740,7 @@ Assemble a remote rust_analyzer_toolchain target based on the given params.
1740
1740
| <aid="rust_analyzer_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. |`[]`|
1741
1741
| <aid="rust_analyzer_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. |`[]`|
1742
1742
| <aid="rust_analyzer_toolchain_repository-iso_date"></a>iso_date | The date of the tool. |`None`|
1743
-
| <aid="rust_analyzer_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
1743
+
| <aid="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`|
1744
1744
| <aid="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`|
1745
1745
| <aid="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`|
1746
1746
@@ -1929,7 +1929,7 @@ Emits a default set of toolchains for Linux, MacOS, and Freebsd
1929
1929
1930
1930
Skip this macro and call the `rust_repository_set` macros directly if you need a compiler for other hosts or for additional target triples.
1931
1931
1932
-
The `sha256` attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:
1932
+
The `sha256s` attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:
@@ -2016,7 +2016,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
2016
2016
| <aid="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`|
2017
2017
| <aid="rust_repository_set-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. |`None`|
2018
2018
| <aid="rust_repository_set-opt_level"></a>opt_level | Dictionary of target triples to optimiztion config. |`None`|
2019
-
| <aid="rust_repository_set-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
2019
+
| <aid="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`|
2020
2020
| <aid="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"]`|
2021
2021
| <aid="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`|
2022
2022
| <aid="rust_repository_set-register_toolchain"></a>register_toolchain | If True, the generated <code>rust_toolchain</code> target will become a registered toolchain. |`True`|
@@ -2124,7 +2124,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
2124
2124
| <aid="rust_toolchain_repository-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration. |`None`|
2125
2125
| <aid="rust_toolchain_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. |`None`|
2126
2126
| <aid="rust_toolchain_repository-opt_level"></a>opt_level | Optimization level config for this toolchain. |`None`|
2127
-
| <aid="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
2127
+
| <aid="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`|
2128
2128
| <aid="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"]`|
2129
2129
| <aid="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`|
Copy file name to clipboardExpand all lines: docs/rust_repositories.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -183,7 +183,7 @@ A given instance of this rule should be accompanied by a toolchain_repository_pr
183
183
| <aid="rust_toolchain_tools_repository-opt_level"></a>opt_level | Rustc optimization levels. For more details see the documentation for <code>rust_toolchain.opt_level</code>. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
184
184
| <aid="rust_toolchain_tools_repository-repo_mapping"></a>repo_mapping | A dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<p>For example, an entry <code>"@foo": "@bar"</code> declares that, for any time this repository depends on <code>@foo</code> (such as a dependency on <code>@foo//some:target</code>, it should actually resolve that dependency within globally-declared <code>@bar</code> (<code>@bar//some:target</code>). | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | required ||
185
185
| <aid="rust_toolchain_tools_repository-rustfmt_version"></a>rustfmt_version | The version of the tool among "nightly", "beta", or an exact version. | String | optional | <code>""</code> |
186
-
| <aid="rust_toolchain_tools_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
186
+
| <aid="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. | <ahref="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional | <code>{}</code> |
187
187
| <aid="rust_toolchain_tools_repository-target_triple"></a>target_triple | The Rust-style target that this compiler builds for. | String | required ||
188
188
| <aid="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 | <code>["https://static.rust-lang.org/dist/{}.tar.xz"]</code> |
189
189
| <aid="rust_toolchain_tools_repository-version"></a>version | The version of the tool among "nightly", "beta", or an exact version. | String | required ||
@@ -222,7 +222,7 @@ Assemble a remote rust_analyzer_toolchain target based on the given params.
222
222
| <aid="rust_analyzer_toolchain_repository-exec_compatible_with"></a>exec_compatible_with | A list of constraints for the execution platform for this toolchain. |`[]`|
223
223
| <aid="rust_analyzer_toolchain_repository-target_compatible_with"></a>target_compatible_with | A list of constraints for the target platform for this toolchain. |`[]`|
224
224
| <aid="rust_analyzer_toolchain_repository-iso_date"></a>iso_date | The date of the tool. |`None`|
225
-
| <aid="rust_analyzer_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
225
+
| <aid="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`|
226
226
| <aid="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`|
227
227
| <aid="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`|
228
228
@@ -246,7 +246,7 @@ Emits a default set of toolchains for Linux, MacOS, and Freebsd
246
246
247
247
Skip this macro and call the `rust_repository_set` macros directly if you need a compiler for other hosts or for additional target triples.
248
248
249
-
The `sha256` attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:
249
+
The `sha256s` attribute represents a dict associating tool subdirectories to sha256 hashes. As an example:
@@ -333,7 +333,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
333
333
| <aid="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`|
334
334
| <aid="rust_repository_set-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. |`None`|
335
335
| <aid="rust_repository_set-opt_level"></a>opt_level | Dictionary of target triples to optimiztion config. |`None`|
336
-
| <aid="rust_repository_set-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
336
+
| <aid="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`|
337
337
| <aid="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"]`|
338
338
| <aid="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`|
339
339
| <aid="rust_repository_set-register_toolchain"></a>register_toolchain | If True, the generated <code>rust_toolchain</code> target will become a registered toolchain. |`True`|
@@ -377,7 +377,7 @@ Assembles a remote repository for the given toolchain params, produces a proxy r
377
377
| <aid="rust_toolchain_repository-extra_rustc_flags"></a>extra_rustc_flags | Extra flags to pass to rustc in non-exec configuration. |`None`|
378
378
| <aid="rust_toolchain_repository-extra_exec_rustc_flags"></a>extra_exec_rustc_flags | Extra flags to pass to rustc in exec configuration. |`None`|
379
379
| <aid="rust_toolchain_repository-opt_level"></a>opt_level | Optimization level config for this toolchain. |`None`|
380
-
| <aid="rust_toolchain_repository-sha256s"></a>sha256s | A dict associating tool subdirectories to sha256 hashes. See [rust_repositories](#rust_repositories) for more details. |`None`|
380
+
| <aid="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`|
381
381
| <aid="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"]`|
382
382
| <aid="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`|
0 commit comments