Skip to content
Merged
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
13 changes: 13 additions & 0 deletions rust/private/repository_utils.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ def BUILD_for_clippy(target_triple):
)

_build_file_for_llvm_tools = """\
filegroup(
name = "llvm_lib",
srcs = glob(
["lib/rustlib/{target_triple}/lib/libLLVM*.so*"],
allow_empty = True,
),
visibility = ["//visibility:public"],
)

filegroup(
name = "llvm_cov_bin",
srcs = ["lib/rustlib/{target_triple}/bin/llvm-cov{binary_ext}"],
Expand Down Expand Up @@ -255,6 +264,7 @@ rust_toolchain(
cargo_clippy = "//:cargo_clippy_bin",
llvm_cov = {llvm_cov_label},
llvm_profdata = {llvm_profdata_label},
llvm_lib = {llvm_lib_label},
rustc_lib = "//:rustc_lib",
allocator_library = {allocator_library},
global_allocator_library = {global_allocator_library},
Expand Down Expand Up @@ -319,9 +329,11 @@ def BUILD_for_rust_toolchain(
rustfmt_label = "\"//:rustfmt_bin\""
llvm_cov_label = "None"
llvm_profdata_label = "None"
llvm_lib_label = "None"
if include_llvm_tools:
llvm_cov_label = "\"//:llvm_cov_bin\""
llvm_profdata_label = "\"//:llvm_profdata_bin\""
llvm_lib_label = "\"//:llvm_lib\""
allocator_library_label = "None"
if allocator_library:
allocator_library_label = "\"{allocator_library}\"".format(allocator_library = allocator_library)
Expand All @@ -343,6 +355,7 @@ def BUILD_for_rust_toolchain(
rustfmt_label = rustfmt_label,
llvm_cov_label = llvm_cov_label,
llvm_profdata_label = llvm_profdata_label,
llvm_lib_label = llvm_lib_label,
extra_rustc_flags = extra_rustc_flags,
extra_exec_rustc_flags = extra_exec_rustc_flags,
opt_level = opt_level,
Expand Down
2 changes: 1 addition & 1 deletion rust/private/rustc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ def rustc_compile_action(

coverage_runfiles = []
if toolchain.llvm_cov and ctx.configuration.coverage_enabled and crate_info.is_test:
coverage_runfiles = [toolchain.llvm_cov, toolchain.llvm_profdata]
coverage_runfiles = [toolchain.llvm_cov, toolchain.llvm_profdata] + toolchain.llvm_lib

experimental_use_coverage_metadata_files = toolchain._experimental_use_coverage_metadata_files

Expand Down
6 changes: 6 additions & 0 deletions rust/toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ def _rust_toolchain_impl(ctx):
make_libstd_and_allocator_ccinfo = make_ccinfo,
llvm_cov = ctx.file.llvm_cov,
llvm_profdata = ctx.file.llvm_profdata,
llvm_lib = ctx.files.llvm_lib,
lto = lto,
make_variables = make_variable_info,
rust_doc = sysroot.rustdoc,
Expand Down Expand Up @@ -873,6 +874,11 @@ rust_toolchain = rule(
allow_single_file = True,
cfg = "exec",
),
"llvm_lib": attr.label(
doc = "The location of the `libLLVM` shared object files. If `llvm_cov` is None, this can be None as well and rust code is not instrumented for coverage.",
allow_files = True,
cfg = "exec",
),
"llvm_tools": attr.label(
doc = "LLVM tools that are shipped with the Rust toolchain.",
allow_files = True,
Expand Down
Loading