[commit: ghc] master: Fix #10923 by fingerprinting optimization level. (818760d)

git at git.haskell.org git at git.haskell.org
Fri Sep 2 08:42:34 UTC 2016


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

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/818760d68c0e5e4479a4f64fc863303ff5f23a3a/ghc

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

commit 818760d68c0e5e4479a4f64fc863303ff5f23a3a
Author: Edward Z. Yang <ezyang at cs.stanford.edu>
Date:   Thu Sep 1 15:28:07 2016 -0700

    Fix #10923 by fingerprinting optimization level.
    
    Signed-off-by: Edward Z. Yang <ezyang at cs.stanford.edu>
    
    Test Plan: validate
    
    Reviewers: simonmar, austin, bgamari, thomie, rwbarton
    
    Differential Revision: https://phabricator.haskell.org/D2509
    
    GHC Trac Issues: #10923


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

818760d68c0e5e4479a4f64fc863303ff5f23a3a
 compiler/iface/FlagChecker.hs    | 10 ++++++++--
 compiler/utils/Binary.hs         | 11 +++++++++++
 testsuite/tests/driver/Makefile  |  7 +++++++
 testsuite/tests/driver/T10923.hs |  1 +
 testsuite/tests/driver/all.T     |  5 +++++
 5 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/compiler/iface/FlagChecker.hs b/compiler/iface/FlagChecker.hs
index ca8cf28..b3f3758 100644
--- a/compiler/iface/FlagChecker.hs
+++ b/compiler/iface/FlagChecker.hs
@@ -45,8 +45,14 @@ fingerprintDynFlags dflags at DynFlags{..} this_mod nameio =
         -- -fprof-auto etc.
         prof = if gopt Opt_SccProfilingOn dflags then fromEnum profAuto else 0
 
-    in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths)) $
-       computeFingerprint nameio (mainis, safeHs, lang, cpp, paths, prof)
+        -- -O, see https://ghc.haskell.org/trac/ghc/ticket/10923
+        opt = if hscTarget == HscInterpreted ||
+                 hscTarget == HscNothing
+                 then 0
+                 else optLevel
+
+    in -- pprTrace "flags" (ppr (mainis, safeHs, lang, cpp, paths, prof, opt)) $
+       computeFingerprint nameio (mainis, safeHs, lang, cpp, paths, prof, opt)
 
 
 {- Note [path flags and recompilation]
diff --git a/compiler/utils/Binary.hs b/compiler/utils/Binary.hs
index 9f7c03d..c3814cd 100644
--- a/compiler/utils/Binary.hs
+++ b/compiler/utils/Binary.hs
@@ -420,6 +420,17 @@ instance (Binary a, Binary b, Binary c, Binary d, Binary e, Binary f) => Binary
                                  f <- get bh
                                  return (a,b,c,d,e,f)
 
+instance (Binary a, Binary b, Binary c, Binary d, Binary e, Binary f, Binary g) => Binary (a,b,c,d,e,f,g) where
+    put_ bh (a,b,c,d,e,f,g) = do put_ bh a; put_ bh b; put_ bh c; put_ bh d; put_ bh e; put_ bh f; put_ bh g
+    get bh                  = do a <- get bh
+                                 b <- get bh
+                                 c <- get bh
+                                 d <- get bh
+                                 e <- get bh
+                                 f <- get bh
+                                 g <- get bh
+                                 return (a,b,c,d,e,f,g)
+
 instance Binary a => Binary (Maybe a) where
     put_ bh Nothing  = putByte bh 0
     put_ bh (Just a) = do putByte bh 1; put_ bh a
diff --git a/testsuite/tests/driver/Makefile b/testsuite/tests/driver/Makefile
index 8069331..4e9ef20 100644
--- a/testsuite/tests/driver/Makefile
+++ b/testsuite/tests/driver/Makefile
@@ -629,3 +629,10 @@ T12135:
 	cp T12135b.h T12135b/T12135.h
 	"$(TEST_HC)" $(TEST_HC_OPTS) -IT12135b -IT12135a --make T12135.hs
 	./T12135
+
+.PHONY: T10923
+T10923:
+	$(RM) -rf T10923.o T10923.hi
+	"$(TEST_HC)" $(TEST_HC_OPTS) -v1 -O0 -c T10923.hs
+	# should NOT output "compilation is NOT required"
+	"$(TEST_HC)" $(TEST_HC_OPTS) -v1 -O -c T10923.hs
diff --git a/testsuite/tests/driver/T10923.hs b/testsuite/tests/driver/T10923.hs
new file mode 100644
index 0000000..8e2ddcd
--- /dev/null
+++ b/testsuite/tests/driver/T10923.hs
@@ -0,0 +1 @@
+module T10923 where
diff --git a/testsuite/tests/driver/all.T b/testsuite/tests/driver/all.T
index ebd1b5a..c6283df 100644
--- a/testsuite/tests/driver/all.T
+++ b/testsuite/tests/driver/all.T
@@ -492,3 +492,8 @@ test('T12135',
      ['$MAKE -s --no-print-directory T12135'])
 
 test('T12192', normal, run_command, ['mkdir foo && (cd foo && {compiler} -v0 ../T12192)']) 
+
+test('T10923',
+     extra_clean(['T10923.o', 'T10923.hi']),
+     run_command,
+     ['$MAKE -s --no-print-directory T10923'])



More information about the ghc-commits mailing list