Commit 78d6b995 authored by Sajjad Mirza's avatar Sajjad Mirza Committed by Commit Bot

Use the wrapper script in all coverage builds.

Previously the wrapper script would only be used for coverage builds
that required selective instrumentation of specific files. Now it
will also be used for any coverage builds.

Since the script's job is to remove flags from files that shouldn't
have them the default_coverage config now adds to cflags even in a
CQ build.

Bug: 918215
Change-Id: I012c5732d46bf5cff9eaf8f50615739bb781cc29
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1496002
Commit-Queue: Sajjad Mirza <sajjadm@google.com>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Reviewed-by: default avatarMax Moroz <mmoroz@chromium.org>
Reviewed-by: default avatarYuke Liao <liaoyuke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#638321}
parent 599457eb
...@@ -25,10 +25,6 @@ config("default_coverage") { ...@@ -25,10 +25,6 @@ config("default_coverage") {
} }
} }
# Coverage flags are only on by default when instrument all source files.
# Otherwise, coverage flags are dynamically passed to the compile command
# via the //build/toolchain/clang_code_coverage_wrapper.py script.
if (coverage_instrumentation_input_file == "") {
cflags = [ cflags = [
"-fprofile-instr-generate", "-fprofile-instr-generate",
"-fcoverage-mapping", "-fcoverage-mapping",
...@@ -45,5 +41,4 @@ config("default_coverage") { ...@@ -45,5 +41,4 @@ config("default_coverage") {
cflags += [ "-fno-use-cxa-atexit" ] cflags += [ "-fno-use-cxa-atexit" ]
} }
} }
}
} }
...@@ -194,6 +194,23 @@ template("gcc_toolchain") { ...@@ -194,6 +194,23 @@ template("gcc_toolchain") {
compiler_prefix = "${analyzer_wrapper} " + compiler_prefix compiler_prefix = "${analyzer_wrapper} " + compiler_prefix
} }
# A specific toolchain may wish to avoid coverage instrumentation, so we
# allow the global "use_clang_coverage" arg to be overridden.
if (defined(toolchain_args.use_clang_coverage)) {
toolchain_use_clang_coverage = toolchain_args.use_clang_coverage
} else {
toolchain_use_clang_coverage = use_clang_coverage
}
# For a coverage build, we use the wrapper script globally so that it can
# remove coverage cflags from files that should not have them.
if (toolchain_use_clang_coverage) {
assert(!use_clang_static_analyzer,
"Clang static analyzer wrapper and Clang code coverage wrapper " +
"cannot be used together.")
# "coverage_instrumentation_input_file" is set in args.gn, but it can be
# overridden by a toolchain config.
if (defined(toolchain_args.coverage_instrumentation_input_file)) { if (defined(toolchain_args.coverage_instrumentation_input_file)) {
toolchain_coverage_instrumentation_input_file = toolchain_coverage_instrumentation_input_file =
toolchain_args.coverage_instrumentation_input_file toolchain_args.coverage_instrumentation_input_file
...@@ -201,18 +218,24 @@ template("gcc_toolchain") { ...@@ -201,18 +218,24 @@ template("gcc_toolchain") {
toolchain_coverage_instrumentation_input_file = toolchain_coverage_instrumentation_input_file =
coverage_instrumentation_input_file coverage_instrumentation_input_file
} }
_use_clang_coverage_wrapper =
toolchain_coverage_instrumentation_input_file != ""
if (_use_clang_coverage_wrapper) {
assert(!use_clang_static_analyzer,
"Clang static analyzer wrapper and Clang code coverage wrapper " +
"cannot be used together.")
_coverage_wrapper = _coverage_wrapper =
rebase_path("//build/toolchain/clang_code_coverage_wrapper.py", rebase_path("//build/toolchain/clang_code_coverage_wrapper.py",
root_build_dir) + " --files-to-instrument=" + root_build_dir)
# The wrapper needs to know what OS we target because it uses that to
# select a list of files that should not be instrumented.
_coverage_wrapper = _coverage_wrapper + "--target-os=" + target_os
# We want to instrument everything if there is no input file set.
# If there is a file we need to give it to the wrapper script so it can
# instrument only those files.
if (toolchain_coverage_instrumentation_input_file != "") {
_coverage_wrapper =
_coverage_wrapper + " --files-to-instrument=" +
rebase_path(toolchain_coverage_instrumentation_input_file, rebase_path(toolchain_coverage_instrumentation_input_file,
root_build_dir) root_build_dir)
}
compiler_prefix = "${_coverage_wrapper} " + compiler_prefix compiler_prefix = "${_coverage_wrapper} " + compiler_prefix
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment