Skip to content

Commit 2889dfb

Browse files
authored
Avoid marking reproducible on external repos that create non-local symlinks (#86)
Such symlinks cannot work with local repository cache, and Bazel versions prior to this one would cache them there, breaking builds across output bases. With this bazel_feature gate passing, these repos will be eligible for the remote repo contents cache, but not the local one.
1 parent e0f1490 commit 2889dfb

7 files changed

Lines changed: 17 additions & 8 deletions

File tree

BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ license(
2020

2121
platform(
2222
name = "local_gnu_platform",
23-
parents = ["@platforms//host"],
2423
constraint_values = [
2524
"@llvm//constraints/libc:gnu.2.28",
2625
],
26+
parents = ["@platforms//host"],
2727
)

rs/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ bzl_library(
55
srcs = ["extensions.bzl"],
66
visibility = ["//visibility:public"],
77
deps = [
8-
"//rs/private:repository_utils",
98
"//rs/private:annotations",
109
"//rs/private:cargo_credentials",
1110
"//rs/private:cfg_parser",
@@ -14,6 +13,7 @@ bzl_library(
1413
"//rs/private:downloader",
1514
"//rs/private:git_repository",
1615
"//rs/private:lint_flags",
16+
"//rs/private:repository_utils",
1717
"//rs/private:resolver",
1818
"//rs/private:select_utils",
1919
"//rs/private:semver",

rs/experimental/toolchains/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ bzl_library(
5252
"//rs/private:rustfmt_repository",
5353
"//rs/private:stdlib_repository",
5454
"//rs/private:toolchains_repository",
55+
"@bazel_features//:features",
5556
"@rules_rust//rust/platform:bzl_lib",
5657
"@rules_rust//rust/private:bzl_lib",
5758
],

rs/private/clippy_repository.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@bazel_features//:features.bzl", "bazel_features")
12
load("@rules_rust//rust/platform:triple.bzl", "triple")
23
load("@rules_rust//rust/private:repository_utils.bzl", "BUILD_for_clippy")
34
load(":rust_repository_utils.bzl", "download_and_extract", "RUST_REPOSITORY_COMMON_ATTR")
@@ -10,7 +11,9 @@ def _clippy_repository_impl(rctx):
1011
rustc_repo_root = rctx.path(rctx.attr.rustc_repo_build_file).dirname
1112
rctx.symlink(rustc_repo_root.get_child("lib"), "lib")
1213

13-
return rctx.repo_metadata(reproducible = True)
14+
return rctx.repo_metadata(
15+
reproducible = bazel_features.external_deps.repo_rules_relativize_symlinks,
16+
)
1417

1518
clippy_repository = repository_rule(
1619
implementation = _clippy_repository_impl,

rs/private/crate_repository.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@bazel_features//:features.bzl", "bazel_features")
12
load("@bazel_tools//tools/build_defs/repo:cache.bzl", "get_default_canonical_id")
23
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "patch")
34
load(":cargo_credentials.bzl", "load_cargo_credentials", "registry_auth_headers")
@@ -60,7 +61,9 @@ def _local_crate_repository_impl(rctx):
6061

6162
rctx.file("BUILD.bazel", generate_build_file(rctx, cargo_toml))
6263

63-
return rctx.repo_metadata(reproducible = True)
64+
return rctx.repo_metadata(
65+
reproducible = bazel_features.external_deps.repo_rules_relativize_symlinks,
66+
)
6467

6568
local_crate_repository = repository_rule(
6669
implementation = _local_crate_repository_impl,

rs/private/rustfmt_repository.bzl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@bazel_features//:features.bzl", "bazel_features")
12
load("@rules_rust//rust/platform:triple.bzl", "triple")
23
load("@rules_rust//rust/private:repository_utils.bzl", "BUILD_for_rustfmt")
34
load(":rust_repository_utils.bzl", "download_and_extract", "RUST_REPOSITORY_COMMON_ATTR")
@@ -24,7 +25,9 @@ def _rustfmt_repository_impl(rctx):
2425
rustc_repo_root = rctx.path(rctx.attr.rustc_repo_build_file).dirname
2526
rctx.symlink(rustc_repo_root.get_child("lib"), "lib")
2627

27-
return rctx.repo_metadata(reproducible = True)
28+
return rctx.repo_metadata(
29+
reproducible = bazel_features.external_deps.repo_rules_relativize_symlinks,
30+
)
2831

2932
rustfmt_repository = repository_rule(
3033
implementation = _rustfmt_repository_impl,

tools/rust_analyzer/BUILD.bazel

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ rust_binary(
5252
},
5353
toolchains = ["@rules_rust//rust/toolchain:current_rust_analyzer_toolchain"],
5454
deps = [
55-
"@rules_rust//rust/runfiles",
5655
"@rrra//:clap",
5756
"@rrra//:env_logger",
5857
"@rrra//:log",
58+
"@rules_rust//rust/runfiles",
5959
],
6060
)
6161

@@ -71,13 +71,13 @@ rust_library(
7171
],
7272
edition = "2018",
7373
deps = [
74-
"@rules_rust//rust/runfiles",
7574
"@rrra//:anyhow",
7675
"@rrra//:camino",
7776
"@rrra//:clap",
7877
"@rrra//:log",
7978
"@rrra//:serde",
8079
"@rrra//:serde_json",
80+
"@rules_rust//rust/runfiles",
8181
],
8282
)
8383

@@ -99,7 +99,6 @@ rust_clippy(
9999

100100
bzl_library(
101101
name = "bzl_lib",
102-
srcs = ["defs.bzl"],
103102
deps = [
104103
"@bazel_features//:features",
105104
"@rules_rust//rust:bzl_lib",

0 commit comments

Comments
 (0)