[llvm] r362018 - gn build: Make it possible to build with coverage information
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 13:00:36 PDT 2019
Author: nico
Date: Wed May 29 13:00:36 2019
New Revision: 362018
URL: http://llvm.org/viewvc/llvm-project?rev=362018&view=rev
Log:
gn build: Make it possible to build with coverage information
Differential Revision: https://reviews.llvm.org/D62508
Modified:
llvm/trunk/utils/gn/build/BUILD.gn
Modified: llvm/trunk/utils/gn/build/BUILD.gn
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/gn/build/BUILD.gn?rev=362018&r1=362017&r2=362018&view=diff
==============================================================================
--- llvm/trunk/utils/gn/build/BUILD.gn (original)
+++ llvm/trunk/utils/gn/build/BUILD.gn Wed May 29 13:00:36 2019
@@ -3,6 +3,19 @@ import("//llvm/utils/gn/build/mac_sdk.gn
import("//llvm/utils/gn/build/toolchain/compiler.gni")
import("//llvm/utils/gn/build/toolchain/target_flags.gni")
+declare_args() {
+ # Whether to build everything with coverage information.
+ # After building with this, run tests and then run
+ # llvm/utils/prepare-code-coverage-artifact.py \
+ # .../llvm-profdata .../llvm-cov out/gn/profiles/ report/ \
+ # out/gn/bin/llvm-undname ...`
+ # to generate a HTML report for the binaries passed in the last line.
+ llvm_build_instrumented_coverage = false
+}
+
+assert(!llvm_build_instrumented_coverage || is_clang,
+ "llvm_build_instrumented_coverage requires clang as host compiler")
+
config("compiler_defaults") {
defines = []
@@ -136,6 +149,21 @@ config("compiler_defaults") {
if (use_lld && host_os != "win") {
ldflags += [ "-fuse-ld=lld" ]
}
+
+ if (llvm_build_instrumented_coverage) {
+ cflags += [
+ "-fcoverage-mapping",
+
+ # Using an absolute path here is lame, but it's used at test execution
+ # time to generate the profiles, and lit doesn't specify a fixed folder
+ # for test execution -- so this is the only way to get all profiles into
+ # a single folder like llvm/utils/prepare-code-coverage-artifact.py
+ # expects.
+ "-fprofile-instr-generate=" +
+ rebase_path("$root_build_dir/profiles/%4m.profraw"),
+ ]
+ ldflags += [ "-fprofile-instr-generate" ]
+ }
}
config("no_exceptions") {
More information about the llvm-commits
mailing list