summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2019-12-19 17:51:21 +0100
committerRobert Loehning <robert.loehning@qt.io>2020-01-28 20:26:15 +0000
commit94bc57213f9a8a74e9e7520de68d7bba7f42ea4c (patch)
tree129ab902c9e3dc54183b583d6159dd9642882a72
parenta611c632bb906cf77dd3af29ddd7b166f79ad1b0 (diff)
configure: Add switch for clang's "source-based" code coverage feature
This adds instrumentation to the binaries. At the end of their execution, these will then write a file containing information which code was executed. This can be used for code coverage analysis. [ChangeLog][QtCore][configure] Add switch "-coverage source-based" to enable clang's "source-based" code coverage feature. This can be used for code coverage analysis. Change-Id: If31c6849aa797ff8820e041e85a492a14e2f1a6b Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
-rw-r--r--config_help.txt6
-rw-r--r--configure.json9
-rw-r--r--configure.pri4
-rw-r--r--mkspecs/common/clang.conf4
-rw-r--r--mkspecs/features/coverage.prf6
5 files changed, 24 insertions, 5 deletions
diff --git a/config_help.txt b/config_help.txt
index 5cba7316b1..ee176c0451 100644
--- a/config_help.txt
+++ b/config_help.txt
@@ -137,8 +137,10 @@ Build options:
for example, -sanitize address cannot be combined with
-sanitize thread.
- -coverage {trace-pc-guard}
- Add code coverage instrumentation (Clang only)
+ -coverage {trace-pc-guard|source-based}
+ Specify the 'trace-pc-guard' coverage instrumentation for
+ sanitizers or generate instrumented code to collect execution
+ counts and enable code coverage analysis, respectively. (Clang only)
-c++std <edition> .... Select C++ standard <edition> [c++2a/c++17/c++14/c++11]
(Not supported with MSVC 2015)
diff --git a/configure.json b/configure.json
index 4218144357..96cca22b31 100644
--- a/configure.json
+++ b/configure.json
@@ -916,9 +916,14 @@
"autoDetect": false,
"output": [ "publicConfig" ]
},
+ "coverage_source_based": {
+ "label": "source-based",
+ "autoDetect": false,
+ "output": [ "publicConfig" ]
+ },
"coverage": {
"label": "Code Coverage Instrumentation",
- "condition": "features.coverage_trace_pc_guard",
+ "condition": "features.coverage_trace_pc_guard || features.coverage_source_based",
"output": [ "publicConfig" ]
},
"GNUmake": {
@@ -1612,7 +1617,7 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
{
"message": "Code Coverage Instrumentation",
"type": "firstAvailableFeature",
- "args": "coverage_trace_pc_guard",
+ "args": "coverage_trace_pc_guard coverage_source_based",
"condition": "features.coverage"
},
{
diff --git a/configure.pri b/configure.pri
index 57a813023e..e775bf046e 100644
--- a/configure.pri
+++ b/configure.pri
@@ -72,7 +72,9 @@ defineTest(qtConfCommandline_coverage) {
!contains(val, "^-.*"):!isEmpty(val) {
equals(val, "trace-pc-guard") {
qtConfCommandlineSetInput("coverage_trace_pc_guard", "yes")
- } else {
+ } else: equals(val, "source-based") {
+ qtConfCommandlineSetInput("coverage_source_based", "yes")
+ } else: {
qtConfAddError("Invalid argument $$val to command line parameter $$arg")
}
} else {
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index aead581478..2499c8b6d8 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -54,3 +54,7 @@ QMAKE_RANLIB_LTCG = true # No need to run, since llvm-ar has "s"
QMAKE_CFLAGS_COVERAGE_TRACE_PC_GUARD = -fsanitize-coverage=trace-pc-guard
QMAKE_CXXFLAGS_COVERAGE_TRACE_PC_GUARD = -fsanitize-coverage=trace-pc-guard
QMAKE_LFLAGS_COVERAGE_TRACE_PC_GUARD = -fsanitize-coverage=trace-pc-guard
+
+QMAKE_CFLAGS_COVERAGE_SOURCE_BASED = -fprofile-instr-generate -fcoverage-mapping
+QMAKE_CXXFLAGS_COVERAGE_SOURCE_BASED = -fprofile-instr-generate -fcoverage-mapping
+QMAKE_LFLAGS_COVERAGE_SOURCE_BASED = -fprofile-instr-generate -fcoverage-mapping
diff --git a/mkspecs/features/coverage.prf b/mkspecs/features/coverage.prf
index b8b37e1b80..5ae746f0b7 100644
--- a/mkspecs/features/coverage.prf
+++ b/mkspecs/features/coverage.prf
@@ -5,3 +5,9 @@ coverage_trace_pc_guard {
QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_COVERAGE_TRACE_PC_GUARD
QMAKE_LFLAGS += $$QMAKE_LFLAGS_COVERAGE_TRACE_PC_GUARD
}
+
+coverage_source_based {
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_COVERAGE_SOURCE_BASED
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_COVERAGE_SOURCE_BASED
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_COVERAGE_SOURCE_BASED
+}