about summary refs log tree commit diff
path: root/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh')
-rw-r--r--pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh14
1 files changed, 14 insertions, 0 deletions
diff --git a/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
new file mode 100644
index 000000000000..08ef490e2447
--- /dev/null
+++ b/pkgs/build-support/setup-hooks/enable-coverage-instrumentation.sh
@@ -0,0 +1,14 @@
+# Force GCC to build with coverage instrumentation.  Also disable
+# optimisation, since it may confuse things.
+export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -O0 --coverage"
+
+# FIXME: Handle the case where postUnpack is already set.
+postUnpack() {
+    # This is an uberhack to prevent libtool from remoaving gcno
+    # files.  This has been fixed in libtool, but there are packages
+    # out there with old ltmain.sh scripts.  See
+    # http://www.mail-archive.com/libtool@gnu.org/msg10725.html
+    for i in $(find -name ltmain.sh); do
+        substituteInPlace $i --replace '*.$objext)' '*.$objext | *.gcno)'
+    done
+}