Skip to content

Commit

Permalink
Include all toolchain files in the current toolchain (bazelbuild#2336)
Browse files Browse the repository at this point in the history
rustc assumes it can read things like librustc_driver, and if you don't
include it, it gets sad.
  • Loading branch information
illicitonion authored Dec 18, 2023
1 parent 9e146e5 commit 5ceebc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
11 changes: 1 addition & 10 deletions rust/private/toolchain_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,11 @@ toolchain_files = rule(
def _current_rust_toolchain_impl(ctx):
toolchain = ctx.toolchains[str(Label("@rules_rust//rust:toolchain_type"))]

files = [
toolchain.rustc,
toolchain.rust_doc,
toolchain.cargo,
]

if toolchain.rustfmt:
files.append(toolchain.rustfmt)

return [
toolchain,
toolchain.make_variables,
DefaultInfo(
files = depset(files),
files = toolchain.all_files,
),
]

Expand Down
16 changes: 16 additions & 0 deletions test/toolchain/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
load("@bazel_skylib//rules:build_test.bzl", "build_test")
load(":toolchain_test.bzl", "toolchain_test_suite")

toolchain_test_suite(name = "toolchain_test_suite")

genrule(
name = "inspect",
outs = ["rustc-cfg"],
# rustc assumes it can read things like librustc_driver in order to run this command.
# This is a test to ensure we supply all of the files rustc needs as part of the current_rust_toolchain.
cmd = "$(RUSTC) --print=cfg > $@",
toolchains = ["@rules_rust//rust/toolchain:current_rust_toolchain"],
tools = ["@rules_rust//rust/toolchain:current_rust_toolchain"],
)

build_test(
name = "inspect_build_test",
targets = [":inspect"],
)

0 comments on commit 5ceebc0

Please sign in to comment.