[GHC] #13269: Changes in includes of `addCStub` do not cause recompilation of downstream modules.

GHC ghc-devs at haskell.org
Sat Feb 11 14:39:27 UTC 2017


#13269: Changes in includes of `addCStub` do not cause recompilation of downstream
modules.
-------------------------------------+-------------------------------------
           Reporter:                 |             Owner:
  facundo.dominguez                  |
               Type:  bug            |            Status:  new
           Priority:  normal         |         Milestone:
          Component:  Template       |           Version:  8.0.1
  Haskell                            |
           Keywords:  inline-c       |  Operating System:  Unknown/Multiple
  addCStub                           |
       Architecture:                 |   Type of failure:  None/Unknown
  Unknown/Multiple                   |
          Test Case:                 |        Blocked By:
           Blocking:                 |   Related Tickets:  13237
Differential Rev(s):                 |         Wiki Page:
-------------------------------------+-------------------------------------
 Failing example:
 {{{
 // header.h
 #include <stdio.h>

 int f(int  x) {
     printf("calling f(%d)\n",x);
     return x + 1;
 }
 }}}

 {{{
 -- A.hs
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE TemplateHaskell #-}

 module A where

 import Language.Haskell.TH.Syntax

 foreign import ccall f :: Int -> IO Int

 do addCStub "#include \"header.h\""
    addDependentFile "header.h"
    return []
 }}}
 {{{
 -- B.hs
 {-# LANGUAGE ForeignFunctionInterface #-}
 {-# LANGUAGE TemplateHaskell #-}

 module Main where

 import Language.Haskell.TH.Syntax
 import A

 do i <- runIO $ f 0
    [d| fh = i |]

 main :: IO ()
 main = print fh
 }}}
 {{{
 $ ghc --make B.hs
 [1 of 2] Compiling A                ( A.hs, A.o )
 [2 of 2] Compiling Main             ( B.hs, B.o )
 calling f(0)
 Linking B ...
 $ ./B
 1
 }}}
 Edit `header.h`:
 {{{
  // header.h
  #include <stdio.h>

  int f(int  x) {
      printf("calling f(%d)\n",x);
 -    return x + 1;
 +    return x + 2;
  }
 }}}
 Recompiling we can see that `B.hs` is not rebuilt. And executing the
 program still shows the old result.
 {{{
 $ ghc --make B.hs
 [1 of 2] Compiling A                ( A.hs, A.o ) [header.h changed]
 Linking B ...
 $ ./B
 1
 }}}

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/13269>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list