Fix #10923 by fingerprinting optimization level.
authorEdward Z. Yang <ezyang@cs.stanford.edu>
Thu, 1 Sep 2016 22:28:07 +0000 (15:28 -0700)
committerEdward Z. Yang <ezyang@cs.stanford.edu>
Fri, 2 Sep 2016 08:42:21 +0000 (01:42 -0700)
Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
Test Plan: validate

Reviewers: simonmar, austin, bgamari, thomie, rwbarton

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

GHC Trac Issues: #10923

compiler/iface/FlagChecker.hs
compiler/utils/Binary.hs
testsuite/tests/driver/Makefile
testsuite/tests/driver/T10923.hs [new file with mode: 0644]
testsuite/tests/driver/all.T

index ca8cf28..b3f3758 100644 (file)
@@ -45,8 +45,14 @@ fingerprintDynFlags dflags@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]
index 9f7c03d..c3814cd 100644 (file)
@@ -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
index 8069331..4e9ef20 100644 (file)
@@ -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 (file)
index 0000000..8e2ddcd
--- /dev/null
@@ -0,0 +1 @@
+module T10923 where
index ebd1b5a..c6283df 100644 (file)
@@ -491,4 +491,9 @@ test('T12135',
      run_command,
      ['$MAKE -s --no-print-directory T12135'])
 
-test('T12192', normal, run_command, ['mkdir foo && (cd foo && {compiler} -v0 ../T12192)']) 
\ No newline at end of file
+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'])