Merge "Add code coverage support to cc toolchain" am: ff91435009
Original change: https://android-review.googlesource.com/c/platform/prebuilts/clang/host/linux-x86/+/2103884
Change-Id: I51cd42cfda88285a9dc19c02d7c44224de42b2ca
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/cc_toolchain_config.bzl b/cc_toolchain_config.bzl
index 416c746..b482a92 100644
--- a/cc_toolchain_config.bzl
+++ b/cc_toolchain_config.bzl
@@ -53,7 +53,11 @@
),
tool_path(
name = "gcov",
- path = "/bin/false",
+ path = clang_version_info.directory.basename + "/bin/llvm-profdata",
+ ),
+ tool_path(
+ name = "llvm-cov",
+ path = clang_version_info.directory.basename + "/bin/llvm-cov",
),
tool_path(
name = "nm",
diff --git a/cc_toolchain_features.bzl b/cc_toolchain_features.bzl
index 9ef14df..9316954 100644
--- a/cc_toolchain_features.bzl
+++ b/cc_toolchain_features.bzl
@@ -6,6 +6,7 @@
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
+ "feature_set",
"flag_group",
"flag_set",
"variable_with_value",
@@ -1134,6 +1135,35 @@
],
enabled = False,
),
+ feature(
+ name = "llvm_coverage_map_format",
+ flag_sets = [
+ flag_set(
+ actions = _actions.compile,
+ flag_groups = [
+ flag_group(
+ flags = [
+ "-fprofile-instr-generate=/data/misc/trace/clang-%%p-%%m.profraw",
+ "-fcoverage-mapping",
+ "-Wno-pass-failed",
+ "-D__ANDROID_CLANG_COVERAGE__"
+ ],
+ ),
+ ],
+ ),
+ flag_set(
+ actions = [_actions.c_compile, _actions.cpp_compile],
+ flag_groups = [flag_group(flags = ["-Wno-frame-larger-than="])],
+ ),
+ # TODO(b/233660582): support "-Wl,--wrap,open" and libprofile-clang-extras
+ flag_set(
+ actions = _actions.link,
+ flag_groups = [flag_group(flags = ["-fprofile-instr-generate"])],
+ ),
+ ],
+ requires = [feature_set(features = ["coverage"])],
+ ),
+ feature(name = "coverage"),
]
return features