Recompilation avoidance on ABI hash changes

Domínguez, Facundo facundo.dominguez at tweag.io
Thu Aug 11 12:50:30 UTC 2022


Thanks Matthew. I've now found my example, which I share bellow for the
record.

Cheers!
Facundo

> module A where
>
> a :: Bool
> a = False
>
> a2 :: Bool
> a2 = True

> module B where
>
> import A
>
> b :: Bool
> b = not a

Building I get

> $ ghc A.hs B.hs
> [1 of 2] Compiling A                ( A.hs, A.o )
> [2 of 2] Compiling B                ( B.hs, B.o ) [A changed]
>
> $ ghc --show-iface A.hi | grep "ABI hash"
>   ABI hash: 811ba0740c0157da5cd2ea747468b19f

Changing A.a2 to have a different type causes the ABI hash to change yet
GHC doesn't recompile module B:

> - a2 :: Bool
> - a2 = True
> + a2 :: Int
> + a2 = 0

> $ ghc A.hs B.hs
> [1 of 2] Compiling A                ( A.hs, A.o )
>
> $ ghc --show-iface A.hi | grep "ABI hash"
>   ABI hash: 6d7a56ce0b9f5fbca71f48bf08c2db84

I was previously trying to change the value of a2 rather than the type,
which doesn't change the ABI hash if one isn't compiling with optimizations
:)

I also tried doing modifications to the export list of A, but this seems to
trigger recompilation of module B in all cases.


On Thu, Aug 11, 2022 at 9:20 AM Matthew Pickering <
matthewtpickering at gmail.com> wrote:

> Facundo,
>
> If the interface in question is from a home package module, then it's
> required that the ABI of the specifically used function is modified
> rather than the ABI hash of the whole module. If the interface is from
> an external package then if the ABI of the entire module changes then
> that is sufficient to trigger recompilation.
>
> Matt
>
> On Thu, Aug 11, 2022 at 12:11 PM Domínguez, Facundo
> <facundo.dominguez at tweag.io> wrote:
> >
> > Dear devs,
> >
> > rules_haskell [1] recently earned the ability to skip recompiling
> modules when the ABI hashes of dependencies don't change in interface files.
> >
> > We have noticed since then that sometimes ghc --make does avoid
> rebuilding even when ABI hashes change. However, so far I've been unable to
> reproduce this in the small. The wiki page on recompilation avoidance does
> remark that a changing ABI hash is a necessary but not sufficient condition
> for recompilation [2].
> >
> > Does anyone have a small example showing how ghc avoids rebuilding even
> when the ABI hash of a dependency changes?
> >
> > Thanks in advance!
> > Facundo
> >
> > [1]
> https://github.com/tweag/rules_haskell/issues/1760#issuecomment-1179102232
> > [2]
> https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/compiler/recompilation-avoidance#interface-file-invariants
> > _______________________________________________
> > ghc-devs mailing list
> > ghc-devs at haskell.org
> > http://mail.haskell.org/cgi-bin/mailman/listinfo/ghc-devs
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-devs/attachments/20220811/5fd4c0f3/attachment.html>


More information about the ghc-devs mailing list