···1+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+From: Luke Granger-Brown <git@lukegb.com>
3+Date: Thu, 17 Apr 2025 02:44:24 +0100
4+Subject: [PATCH] rules_rust base
5+6+Signed-off-by: Luke Granger-Brown <git@lukegb.com>
7+---
8+ cargo/private/cargo_bootstrap.bzl | 8 ++++----
9+ crate_universe/extensions.bzl | 10 +++++-----
10+ crate_universe/src/lockfile.rs | 4 ++--
11+ rust/private/rustc.bzl | 4 ++--
12+ 4 files changed, 13 insertions(+), 13 deletions(-)
13+14+diff --git cargo/private/cargo_bootstrap.bzl cargo/private/cargo_bootstrap.bzl
15+index a8021c49d62037ef32c7c64d5bb4a5efe3a8b4aa..f63d7c23ae0bddc9f3fece347a3a2b5b0afe6d8d 100644
16+--- cargo/private/cargo_bootstrap.bzl
17++++ cargo/private/cargo_bootstrap.bzl
18+@@ -173,13 +173,13 @@ def _detect_changes(repository_ctx):
19+ # 'consumed' which means changes to it will trigger rebuilds
20+21+ for src in repository_ctx.attr.srcs:
22+- repository_ctx.watch(src)
23++ repository_ctx.path(src)
24+25+- repository_ctx.watch(repository_ctx.attr.cargo_lockfile)
26+- repository_ctx.watch(repository_ctx.attr.cargo_toml)
27++ repository_ctx.path(repository_ctx.attr.cargo_lockfile)
28++ repository_ctx.path(repository_ctx.attr.cargo_toml)
29+30+ if repository_ctx.attr.cargo_config:
31+- repository_ctx.watch(repository_ctx.attr.cargo_config)
32++ repository_ctx.path(repository_ctx.attr.cargo_config)
33+34+ def _cargo_bootstrap_repository_impl(repository_ctx):
35+ # Pretend to Bazel that this rule's input files have been used, so that it will re-run the rule if they change.
36+diff --git crate_universe/extensions.bzl crate_universe/extensions.bzl
37+index a749b10c8d469bd316d78034059c94b1fd98dbef..8f8c84dac1ec330d5e8e6abbd930387cb6c9f29e 100644
38+--- crate_universe/extensions.bzl
39++++ crate_universe/extensions.bzl
40+@@ -957,17 +957,17 @@ def _crate_impl(module_ctx):
41+ fail("Spec specified for repo {}, but the module defined repositories {}".format(repo, local_repos))
42+43+ for cfg in mod.tags.from_cargo + mod.tags.from_specs:
44+- # Preload all external repositories. Calling `module_ctx.watch` will cause restarts of the implementation
45++ # Preload all external repositories. Calling `module_ctx.path` will cause restarts of the implementation
46+ # function of the module extension when the file has changed.
47+ if cfg.cargo_lockfile:
48+- module_ctx.watch(cfg.cargo_lockfile)
49++ module_ctx.path(cfg.cargo_lockfile)
50+ if cfg.lockfile:
51+- module_ctx.watch(cfg.lockfile)
52++ module_ctx.path(cfg.lockfile)
53+ if cfg.cargo_config:
54+- module_ctx.watch(cfg.cargo_config)
55++ module_ctx.path(cfg.cargo_config)
56+ if hasattr(cfg, "manifests"):
57+ for m in cfg.manifests:
58+- module_ctx.watch(m)
59++ module_ctx.path(m)
60+61+ cargo_path, rustc_path = _get_host_cargo_rustc(module_ctx, host_triple, cfg.host_tools_repo)
62+ cargo_bazel_fn = new_cargo_bazel_fn(
63+diff --git crate_universe/src/lockfile.rs crate_universe/src/lockfile.rs
64+index 3e0ce6265fda6fbdd9e3e989e3e4e4443b615b8c..0fafcea8fbc7a590676d34d2c4ca8c413b953955 100644
65+--- crate_universe/src/lockfile.rs
66++++ crate_universe/src/lockfile.rs
67+@@ -146,10 +146,10 @@ impl Digest {
68+ ));
69+ hasher.update(b"\0");
70+71+- hasher.update(Digest::compute_single_hash(cargo_version, "Cargo version"));
72++ hasher.update(Digest::compute_single_hash("hermetic", "Cargo version"));
73+ hasher.update(b"\0");
74+75+- hasher.update(Digest::compute_single_hash(rustc_version, "Rustc version"));
76++ hasher.update(Digest::compute_single_hash("hermetic", "Rustc version"));
77+ hasher.update(b"\0");
78+79+ let hash = hasher.finalize().encode_hex::<String>();
80+diff --git rust/private/rustc.bzl rust/private/rustc.bzl
81+index d78c28902c8f73ae655b8f6b5df3db5a1805aa19..321a24a946c33d5e3452758a72a77b52d5a3eccf 100644
82+--- rust/private/rustc.bzl
83++++ rust/private/rustc.bzl
84+@@ -1059,7 +1059,7 @@ def construct_arguments(
85+86+ if toolchain.llvm_cov and ctx.configuration.coverage_enabled:
87+ # https://doc.rust-lang.org/rustc/instrument-coverage.html
88+- rustc_flags.add("--codegen=instrument-coverage")
89++ pass
90+91+ if toolchain._experimental_link_std_dylib:
92+ rustc_flags.add("--codegen=prefer-dynamic")
93+@@ -1563,7 +1563,7 @@ def rustc_compile_action(
94+ })
95+ crate_info = rust_common.create_crate_info(**crate_info_dict)
96+97+- if crate_info.type in ["staticlib", "cdylib"]:
98++ if crate_info.type in ["staticlib", "cdylib"] and not out_binary:
99+ # These rules are not supposed to be depended on by other rust targets, and
100+ # as such they shouldn't provide a CrateInfo. However, one may still want to
101+ # write a rust_test for them, so we provide the CrateInfo wrapped in a provider