diff --git a/rust/private/repository_utils.bzl b/rust/private/repository_utils.bzl index 5f9f48bf5a..f45f0e288f 100644 --- a/rust/private/repository_utils.bzl +++ b/rust/private/repository_utils.bzl @@ -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}"], @@ -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}, @@ -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) @@ -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, diff --git a/rust/private/rustc.bzl b/rust/private/rustc.bzl index 3293cd9f12..f8be6bad7b 100644 --- a/rust/private/rustc.bzl +++ b/rust/private/rustc.bzl @@ -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 diff --git a/rust/toolchain.bzl b/rust/toolchain.bzl index 055836f2f9..c31ce15351 100644 --- a/rust/toolchain.bzl +++ b/rust/toolchain.bzl @@ -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, @@ -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,