summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Loehning <robert.loehning@qt.io>2018-08-29 22:18:42 +0200
committerRobert Loehning <robert.loehning@qt.io>2018-10-31 15:08:59 +0000
commitcc9645f11b46aaad36658d62d38a5e44a5ba5ae5 (patch)
treea6e7b3b9278403624768e2cb55f89f73825446b3
parent0330b967f20bc265b9799418ce8e0b6faf929a62 (diff)
configure: Add switch for adding coverage info
Change-Id: If6f3d4f29233206ef911f48e63872d28bf7b8e71 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
-rw-r--r--config_help.txt3
-rw-r--r--configure.json22
-rw-r--r--configure.pri15
-rw-r--r--mkspecs/common/clang.conf4
-rw-r--r--mkspecs/features/coverage.prf7
5 files changed, 51 insertions, 0 deletions
diff --git a/config_help.txt b/config_help.txt
index 5b32eb183f..f8da33d4ec 100644
--- a/config_help.txt
+++ b/config_help.txt
@@ -135,6 +135,9 @@ Build options:
for example, -sanitize address cannot be combined with
-sanitize thread.
+ -coverage {trace-pc-guard}
+ Add code coverage instrumentation (Clang only)
+
-c++std <edition> .... Select C++ standard <edition> [c++1z/c++14/c++11]
(Not supported with MSVC)
diff --git a/configure.json b/configure.json
index 522bd34e9b..d6568b9a7f 100644
--- a/configure.json
+++ b/configure.json
@@ -67,6 +67,7 @@
"commercial": "void",
"compile-examples": { "type": "boolean", "name": "compile_examples" },
"confirm-license": "void",
+ "coverage": "coverage",
"dbus": { "type": "optionalString", "values": [ "no", "yes", "linked", "runtime" ] },
"dbus-linked": { "type": "void", "name": "dbus", "value": "linked" },
"dbus-runtime": { "type": "void", "name": "dbus", "value": "runtime" },
@@ -791,6 +792,16 @@
"condition": "features.sanitize_address || features.sanitize_thread || features.sanitize_memory || features.sanitize_undefined",
"output": [ "sanitizer", "publicConfig" ]
},
+ "coverage_trace_pc_guard": {
+ "label": "trace-pc-guard",
+ "autoDetect": false,
+ "output": [ "publicConfig" ]
+ },
+ "coverage": {
+ "label": "Code Coverage Instrumentation",
+ "condition": "features.coverage_trace_pc_guard",
+ "output": [ "publicConfig" ]
+ },
"GNUmake": {
"label": "GNU make",
"autoDetect": false,
@@ -1268,6 +1279,11 @@ Qt can be built in release mode with separate debug information, so
"type": "error",
"condition": "(features.rpath || features.rpath_dir) && var.QMAKE_LFLAGS_RPATH == ''",
"message": "This platform does not support RPATH"
+ },
+ {
+ "type": "error",
+ "condition": "features.coverage && !config.clang",
+ "message": "Command line option -coverage is only supported with clang compilers."
}
],
@@ -1402,6 +1418,12 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5
"entries": [ "sanitize_address", "sanitize_thread", "sanitize_memory", "sanitize_undefined" ]
},
{
+ "message": "Code Coverage Instrumentation",
+ "type": "firstAvailableFeature",
+ "args": "coverage_trace_pc_guard",
+ "condition": "features.coverage"
+ },
+ {
"message": "Build parts",
"type": "buildParts"
},
diff --git a/configure.pri b/configure.pri
index 64ed6b9ed8..3f3d2da571 100644
--- a/configure.pri
+++ b/configure.pri
@@ -58,6 +58,21 @@ defineTest(qtConfCommandline_sanitize) {
}
}
+defineTest(qtConfCommandline_coverage) {
+ arg = $${1}
+ val = $${2}
+ isEmpty(val): val = $$qtConfGetNextCommandlineArg()
+ !contains(val, "^-.*"):!isEmpty(val) {
+ equals(val, "trace-pc-guard") {
+ qtConfCommandlineSetInput("coverage_trace_pc_guard", "yes")
+ } else {
+ qtConfAddError("Invalid argument $$val to command line parameter $$arg")
+ }
+ } else {
+ qtConfAddError("Missing argument to command line parameter $$arg")
+ }
+}
+
# callbacks
defineReplace(qtConfFunc_crossCompile) {
diff --git a/mkspecs/common/clang.conf b/mkspecs/common/clang.conf
index 5800aaa5b4..dacd1539cf 100644
--- a/mkspecs/common/clang.conf
+++ b/mkspecs/common/clang.conf
@@ -44,3 +44,7 @@ QMAKE_LFLAGS_LTCG = $$QMAKE_CFLAGS_LTCG
QMAKE_AR_LTCG = llvm-ar cqs
QMAKE_NM_LTCG = llvm-nm -P
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
diff --git a/mkspecs/features/coverage.prf b/mkspecs/features/coverage.prf
new file mode 100644
index 0000000000..b8b37e1b80
--- /dev/null
+++ b/mkspecs/features/coverage.prf
@@ -0,0 +1,7 @@
+# Coverage flags
+
+coverage_trace_pc_guard {
+ QMAKE_CFLAGS += $$QMAKE_CFLAGS_COVERAGE_TRACE_PC_GUARD
+ QMAKE_CXXFLAGS += $$QMAKE_CXXFLAGS_COVERAGE_TRACE_PC_GUARD
+ QMAKE_LFLAGS += $$QMAKE_LFLAGS_COVERAGE_TRACE_PC_GUARD
+}