diff options
| author | Nico Weber <nicolasweber@gmx.de> | 2019-05-29 20:00:36 +0000 |
|---|---|---|
| committer | Nico Weber <nicolasweber@gmx.de> | 2019-05-29 20:00:36 +0000 |
| commit | 4955eb7ceb98bc2be9641a99e87556c5918abf02 (patch) | |
| tree | d96555756d3111a8e2f8ddd8fa27fa80206155ca | |
| parent | 107f8d98730c9f38f28b462f0e11901274f93cdd (diff) | |
| download | bcm5719-llvm-4955eb7ceb98bc2be9641a99e87556c5918abf02.tar.gz bcm5719-llvm-4955eb7ceb98bc2be9641a99e87556c5918abf02.zip | |
gn build: Make it possible to build with coverage information
Differential Revision: https://reviews.llvm.org/D62508
llvm-svn: 362018
| -rw-r--r-- | llvm/utils/gn/build/BUILD.gn | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/utils/gn/build/BUILD.gn b/llvm/utils/gn/build/BUILD.gn index 1af1c220a6f..a20cdb1f5af 100644 --- a/llvm/utils/gn/build/BUILD.gn +++ b/llvm/utils/gn/build/BUILD.gn @@ -3,6 +3,19 @@ import("//llvm/utils/gn/build/mac_sdk.gni") 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") { |

