Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions rust/private/providers.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ StdLibInfo = provider(
"between_core_and_std_files": "List[File]: `.a` files related to all modules except `adler`, `alloc`, `compiler_builtins`, `core`, and `std`.",
"core_files": "List[File]: `.a` files related to the `core` and `adler` modules",
"dot_a_files": "Depset[File]: Generated `.a` files",
"has_profiler_builtins": "bool: Whether the sysroot contains the profiler_builtins rlib, required for -Cinstrument-coverage.",
"memchr_files": "Depset[File]: `.a` files associated with the `memchr` module.",
"panic_files": "Depset[File]: `.a` files associated with `panic_unwind` and `panic_abort`.",
"self_contained_files": "List[File]: All `.o` files from the `self-contained` directory.",
Expand Down
2 changes: 1 addition & 1 deletion rust/private/rust.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ def _rust_test_impl(ctx):
data,
{},
)
if toolchain.llvm_cov and ctx.configuration.coverage_enabled:
if toolchain.coverage_supported and ctx.configuration.coverage_enabled:
if not toolchain.llvm_profdata:
fail("toolchain.llvm_profdata is required if toolchain.llvm_cov is set.")

Expand Down
4 changes: 2 additions & 2 deletions rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ def construct_arguments(
rustc_flags.add("--extern")
rustc_flags.add("proc_macro")

if toolchain.llvm_cov and ctx.configuration.coverage_enabled:
if toolchain.coverage_supported and ctx.configuration.coverage_enabled:
# https://doc.rust-lang.org/rustc/instrument-coverage.html
rustc_flags.add("--codegen=instrument-coverage")

Expand Down Expand Up @@ -1651,7 +1651,7 @@ def rustc_compile_action(
outputs = [crate_info.output]

coverage_runfiles = []
if toolchain.llvm_cov and ctx.configuration.coverage_enabled and crate_info.is_test:
if toolchain.coverage_supported and ctx.configuration.coverage_enabled and crate_info.is_test:
coverage_runfiles = [toolchain.llvm_cov, toolchain.llvm_profdata] + toolchain.llvm_lib
collect_cc_coverage = getattr(ctx.executable, "_collect_cc_coverage", None)
if not collect_cc_coverage:
Expand Down
3 changes: 3 additions & 0 deletions rust/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def _rust_stdlib_filegroup_impl(ctx):
panic_files = []

std_rlibs = [f for f in rust_std if f.basename.endswith(".rlib")]
has_profiler_builtins = any(["profiler_builtins" in f.basename for f in std_rlibs])
if std_rlibs:
# test depends on std
# std depends on everything except test
Expand Down Expand Up @@ -116,6 +117,7 @@ def _rust_stdlib_filegroup_impl(ctx):
alloc_files = alloc_files,
self_contained_files = self_contained_files,
panic_files = panic_files,
has_profiler_builtins = has_profiler_builtins,
srcs = ctx.attr.srcs,
),
]
Expand Down Expand Up @@ -585,6 +587,7 @@ def _rust_toolchain_impl(ctx):
linker = sysroot.linker,
linker_preference = linker_preference,
linker_type = ctx.attr.linker_type or None,
coverage_supported = bool(ctx.file.llvm_cov) and ctx.attr.rust_std[rust_common.stdlib_info].has_profiler_builtins,
llvm_cov = ctx.file.llvm_cov,
llvm_profdata = ctx.file.llvm_profdata,
llvm_lib = ctx.files.llvm_lib,
Expand Down
Loading