[commit: ghc] ghc-8.2: Recompile if -fhpc is added or removed (#11798) (81fcfdf)

git at git.haskell.org git at git.haskell.org
Mon Mar 27 03:00:00 UTC 2017


Repository : ssh://git@git.haskell.org/ghc

On branch  : ghc-8.2
Link       : http://ghc.haskell.org/trac/ghc/changeset/81fcfdf1d2534e352de0096545ebe414ad8d8077/ghc

>---------------------------------------------------------------

commit 81fcfdf1d2534e352de0096545ebe414ad8d8077
Author: Reid Barton <rwbarton at gmail.com>
Date:   Sat Mar 25 10:53:29 2017 -0400

    Recompile if -fhpc is added or removed (#11798)
    
    Test Plan: validate
    
    Reviewers: austin, bgamari, dfeuer
    
    Reviewed By: dfeuer
    
    Subscribers: dfeuer, thomie
    
    Differential Revision: https://phabricator.haskell.org/D3368
    
    (cherry picked from commit 14b46a556dde8a2795ff5ede46ba8ee63368ae93)


>---------------------------------------------------------------

81fcfdf1d2534e352de0096545ebe414ad8d8077
 compiler/iface/FlagChecker.hs     | 10 ++++++++--
 testsuite/tests/hpc/Makefile      |  6 ++++++
 testsuite/tests/hpc/T11798.hs     |  3 +++
 testsuite/tests/hpc/T11798.stdout |  2 ++
 testsuite/tests/hpc/all.T         |  2 ++
 5 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/compiler/iface/FlagChecker.hs b/compiler/iface/FlagChecker.hs
index a0654b0..305a21b 100644
--- a/compiler/iface/FlagChecker.hs
+++ b/compiler/iface/FlagChecker.hs
@@ -57,9 +57,15 @@ fingerprintDynFlags dflags at 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]
 
diff --git a/testsuite/tests/hpc/Makefile b/testsuite/tests/hpc/Makefile
index 9a36a1c..6de7cee 100644
--- a/testsuite/tests/hpc/Makefile
+++ b/testsuite/tests/hpc/Makefile
@@ -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
index 0000000..2d42817
--- /dev/null
+++ b/testsuite/tests/hpc/T11798.hs
@@ -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
index 0000000..024b0dc
--- /dev/null
+++ b/testsuite/tests/hpc/T11798.stdout
@@ -0,0 +1,2 @@
+[1 of 1] Compiling T11798           ( T11798.hs, T11798.o )
+[1 of 1] Compiling T11798           ( T11798.hs, T11798.o ) [flags changed]
diff --git a/testsuite/tests/hpc/all.T b/testsuite/tests/hpc/all.T
index f1fc590..274674b 100644
--- a/testsuite/tests/hpc/all.T
+++ b/testsuite/tests/hpc/all.T
@@ -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



More information about the ghc-commits mailing list