Recompile if -fhpc is added or removed (#11798)
authorReid Barton <rwbarton@gmail.com>
Sat, 25 Mar 2017 14:53:29 +0000 (10:53 -0400)
committerBen Gamari <ben@smart-cactus.org>
Sun, 26 Mar 2017 23:28:29 +0000 (19:28 -0400)
Test Plan: validate

Reviewers: austin, bgamari, dfeuer

Reviewed By: dfeuer

Subscribers: dfeuer, thomie

Differential Revision: https://phabricator.haskell.org/D3368

compiler/iface/FlagChecker.hs
testsuite/tests/hpc/Makefile
testsuite/tests/hpc/T11798.hs [new file with mode: 0644]
testsuite/tests/hpc/T11798.stdout [new file with mode: 0644]
testsuite/tests/hpc/all.T

index b21c2ce..2c0b6c4 100644 (file)
@@ -57,9 +57,15 @@ fingerprintDynFlags dflags@DynFlags{..} this_mod nameio =
                  then 0
                  else optLevel
 
-    in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths, prof, opt)) $
-       computeFingerprint nameio (mainis, safeHs, lang, cpp, paths, prof, opt)
+        -- -fhpc, see https://ghc.haskell.org/trac/ghc/ticket/11798
+        -- hpcDir is output-only, so we should recompile if it changes
+        hpc = if gopt Opt_Hpc dflags then Just hpcDir else Nothing
 
+        -- Nesting just to avoid ever more Binary tuple instances
+        flags = (mainis, safeHs, lang, cpp, paths, (prof, opt, hpc))
+
+    in -- pprTrace "flags" (ppr flags) $
+       computeFingerprint nameio flags
 
 {- Note [path flags and recompilation]
 
index 9a36a1c..6de7cee 100644 (file)
@@ -1,3 +1,9 @@
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
 include $(TOP)/mk/test.mk
+
+# Test that adding -fhpc triggers recompilation
+T11798:
+       "$(TEST_HC)" $(TEST_HC_ARGS) T11798
+       "$(TEST_HC)" $(TEST_HC_ARGS) T11798 -fhpc
+       test -e .hpc/T11798.mix
diff --git a/testsuite/tests/hpc/T11798.hs b/testsuite/tests/hpc/T11798.hs
new file mode 100644 (file)
index 0000000..2d42817
--- /dev/null
@@ -0,0 +1,3 @@
+module T11798 where
+
+f x = [x,x,x]
diff --git a/testsuite/tests/hpc/T11798.stdout b/testsuite/tests/hpc/T11798.stdout
new file mode 100644 (file)
index 0000000..024b0dc
--- /dev/null
@@ -0,0 +1,2 @@
+[1 of 1] Compiling T11798           ( T11798.hs, T11798.o )
+[1 of 1] Compiling T11798           ( T11798.hs, T11798.o ) [flags changed]
index f1fc590..274674b 100644 (file)
@@ -3,6 +3,8 @@ test('T10138', [extra_files(['.keepme.hpc.T10138/']),
      # Using --hpcdir with an absolute path should work (exit code 0).
      ['{hpc} report T10138.keepme.tix --hpcdir="`pwd`/.keepme.hpc.T10138"'])
 
+test('T11798', normal, run_command, ['$MAKE -s --no-print-directory T11798'])
+
 # Run tests below only for the hpc way.
 #
 # Do not explicitly specify '-fhpc' in extra_hc_opts, unless also setting