Commit 494df319 authored by Sajjad Mirza's avatar Sajjad Mirza Committed by Commit Bot

Use the wrapper script in all coverage builds (fixed).

This is a fix for crrev.com/c/1496002, which was reverted because of a
1-character mistake. The rest of the CL message is copied from the
original:

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: Ifdb13657c0c7a80d79960b411050e4f8918fa172
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1508560Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Commit-Queue: Sajjad Mirza <sajjadm@google.com>
Cr-Commit-Position: refs/heads/master@{#638762}
parent 3a49c6c4
...@@ -25,25 +25,20 @@ config("default_coverage") { ...@@ -25,25 +25,20 @@ config("default_coverage") {
} }
} }
# Coverage flags are only on by default when instrument all source files. cflags = [
# Otherwise, coverage flags are dynamically passed to the compile command "-fprofile-instr-generate",
# via the //build/toolchain/clang_code_coverage_wrapper.py script. "-fcoverage-mapping",
if (coverage_instrumentation_input_file == "") {
cflags = [
"-fprofile-instr-generate",
"-fcoverage-mapping",
# Following experimental flags removes unused header functions from the # Following experimental flags removes unused header functions from the
# coverage mapping data embedded in the test binaries, and the reduction # coverage mapping data embedded in the test binaries, and the reduction
# of binary size enables building Chrome's large unit test targets on # of binary size enables building Chrome's large unit test targets on
# MacOS. Please refer to crbug.com/796290 for more details. # MacOS. Please refer to crbug.com/796290 for more details.
"-mllvm", "-mllvm",
"-limited-coverage-experimental=true", "-limited-coverage-experimental=true",
] ]
if (!is_win) { if (!is_win) {
cflags += [ "-fno-use-cxa-atexit" ] cflags += [ "-fno-use-cxa-atexit" ]
}
} }
} }
} }
...@@ -194,25 +194,48 @@ template("gcc_toolchain") { ...@@ -194,25 +194,48 @@ template("gcc_toolchain") {
compiler_prefix = "${analyzer_wrapper} " + compiler_prefix compiler_prefix = "${analyzer_wrapper} " + compiler_prefix
} }
if (defined(toolchain_args.coverage_instrumentation_input_file)) { # A specific toolchain may wish to avoid coverage instrumentation, so we
toolchain_coverage_instrumentation_input_file = # allow the global "use_clang_coverage" arg to be overridden.
toolchain_args.coverage_instrumentation_input_file if (defined(toolchain_args.use_clang_coverage)) {
toolchain_use_clang_coverage = toolchain_args.use_clang_coverage
} else { } else {
toolchain_coverage_instrumentation_input_file = toolchain_use_clang_coverage = use_clang_coverage
coverage_instrumentation_input_file
} }
_use_clang_coverage_wrapper =
toolchain_coverage_instrumentation_input_file != "" # For a coverage build, we use the wrapper script globally so that it can
if (_use_clang_coverage_wrapper) { # remove coverage cflags from files that should not have them.
if (toolchain_use_clang_coverage) {
assert(!use_clang_static_analyzer, assert(!use_clang_static_analyzer,
"Clang static analyzer wrapper and Clang code coverage wrapper " + "Clang static analyzer wrapper and Clang code coverage wrapper " +
"cannot be used together.") "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)) {
toolchain_coverage_instrumentation_input_file =
toolchain_args.coverage_instrumentation_input_file
} else {
toolchain_coverage_instrumentation_input_file =
coverage_instrumentation_input_file
}
_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=" +
rebase_path(toolchain_coverage_instrumentation_input_file,
root_build_dir) 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,
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