input-output-hk/haskell.nix

Any interface file for a module that uses CPP induces a dependency on GHC

michaelpj opened this issue · 3 comments

Here's the output of ghc --show-iface on Brick/Util.hi:

Magic: Wanted 33214052,
       got    33214052
Version: Wanted 9063,
         got    9063
Way: Wanted ,
     got    
interface Brick.Util 9063
  interface hash: 0ff1b61fca498d843838dec452093a58
  ABI hash: ce4201dd994e1c94a5f0157e840a79a0
  export-list hash: dd981e4281abfb416759596e5a09349a
  orphan hash: 693e9af84d3dfcc71e640e005bdc5e2e
  flag hash: cf0da1d81a8379711168e2f3dc4743c2
  opt_hash: f625fe15f01972ba5f99414a443bad7a
  hpc_hash: 93b885adfe0da089cdf634904fd59f71
  plugin_hash: ad164012d6b1e14942349d58b1132007
  src_hash: 7d3bc2c0091465432e14eed2519849fb
  sig of: Nothing
  used TH splices: False
  where
exports:
  bg
  clOffset
  clamp
  fg
  on
  style
direct module dependencies: brick-2.1.1:Brick.Types.Internal
boot module dependencies:
direct package dependencies: base-4.18.1.0 microlens-0.4.13.1
                             vty-6.0
plugin package dependencies:
orphans: GHC.Base GHC.Float Data.Binary.Generic
         Data.ByteString.Builder GHC.Prim.Ext Control.Monad.STM Data.Text
         Data.Text.Lazy Data.Text.Show Data.Time.Calendar.Gregorian
         Data.Time.Format.Format.Instances Data.Time.Format.Parse
         Data.Time.Format.Parse.Instances
         Data.Time.LocalTime.Internal.LocalTime
         Data.Time.LocalTime.Internal.ZonedTime Data.Vector.Fusion.Bundle
family instance modules: Control.Applicative Control.Arrow
                         Data.Array.Byte Data.Complex Data.Functor.Compose
                         Data.Functor.Const Data.Functor.Identity Data.Functor.Product
                         Data.Functor.Sum Data.Monoid Data.Semigroup Data.Semigroup.Internal
                         Data.Type.Ord Data.Version GHC.Generics GHC.IO.Exception GHC.IsList
                         GHC.RTS.Flags Brick.AttrMap Brick.BorderMap Brick.Types.Common
                         Brick.Types.Internal Brick.Widgets.Border.Style Data.IMap
                         Data.ByteString.Internal.Type Data.ByteString.Lazy.Internal
                         Data.ByteString.Short.Internal Data.IntMap.Internal
                         Data.IntSet.Internal Data.Map.Internal Data.Sequence.Internal
                         Data.Set.Internal Data.Tree Control.DeepSeq
                         System.OsString.Internal.Types GHC.ForeignSrcLang.Type
                         GHC.LanguageExtensions.Type Lens.Micro.Internal
                         Lens.Micro.Mtl.Internal Text.PrettyPrint.Annotated.HughesPJ
                         Text.PrettyPrint.HughesPJ Control.Monad.Primitive
                         Data.Primitive.Array Language.Haskell.TH.Syntax Data.Text
                         Data.Text.Lazy Language.Haskell.TH.Datatype
                         Control.Monad.Trans.Accum Control.Monad.Trans.Cont
                         Control.Monad.Trans.Except Control.Monad.Trans.Identity
                         Control.Monad.Trans.Maybe Control.Monad.Trans.RWS.CPS
                         Control.Monad.Trans.RWS.Lazy Control.Monad.Trans.RWS.Strict
                         Control.Monad.Trans.Reader Control.Monad.Trans.Select
                         Control.Monad.Trans.State.Lazy Control.Monad.Trans.State.Strict
                         Control.Monad.Trans.Writer.CPS Control.Monad.Trans.Writer.Lazy
                         Control.Monad.Trans.Writer.Strict Data.Vector
                         Graphics.Vty.Attributes Graphics.Vty.Attributes.Color
                         Graphics.Vty.Image.Internal Graphics.Vty.Input.Events
import  -/  Data.Function 54e76835bda995f732dbcb929be42398
import  -/  GHC.Base 5a01ca574e3fc3196c3612cbcf5879b9
import  -/  Prelude a1ae76d73d35cc0683dc06ee0b1f4dc2
import  -/  brick-2.1.1-JKc4spU0lEiEu24TFAgt5W:Brick.Types.Common 629ac528ce0b634f19cbac7e7a07e1ff
  Location e3aaa688553bcce220b3c64b45da7933
import  -/  brick-2.1.1-JKc4spU0lEiEu24TFAgt5W:Brick.Types.Internal 4651ef2939f4c1e40046c05947f82844
  exports: 6853d0ff5fbc75a67eee00d8425989ce
  CursorLocation 6e2e32a1f66dd518a4e4cef306f00825
  cursorLocationL 1ab02a4faf6ea8e9921234a15c3a8355
import  -/  GHC.Classes 448b501d99f99154cdcc210e9f32fa08
import  -/  Lens.Micro 902222928c82f28f1c7232105235fd9d
import  -/  Graphics.Vty d8f5a8c27c2a521eb3fb49cabb75998d
import  -/  Graphics.Vty.Attributes a09aacf5bb8952faf13ae39f6d9337d8
import  -/  Graphics.Vty.Attributes.Color d59df840606c093e21fa356708632087
addDependentFile "/nix/store/wrkb3pn69pcw119qkh3w2244ch8iik0p-ghc-9.6.3/lib/ghc-9.6.3/lib/x86_64-osx-ghc-9.6.3/rts-1.0.2/include/ghcversion.h" e7af57aa93f9d398aa1e0e3b7cffda5c
addDependentFile "dist/build/autogen/cabal_macros.h" 71f026dacc318a609435ec7d26b74d98
273f1289aa54c34cdb4d643180c679cf
  $trModule :: GHC.Types.Module
  [HasNoCafRefs, TagSig: <TagProper>,
   LambdaFormInfo: LFCon[GHC.Types.Module],
   Unfolding: Core: <vanilla> GHC.Types.Module $trModule3 $trModule1]
82442c36c10305ee87fcc7a2fdf41d91
  $trModule1 :: GHC.Types.TrName
  [HasNoCafRefs, TagSig: <TagProper>,
   LambdaFormInfo: LFCon[GHC.Types.TrNameS],
   Unfolding: Core: <vanilla> GHC.Types.TrNameS $trModule2]
06084dcbeac783382f72276518fb52fb
  $trModule2 :: GHC.Prim.Addr#
  [HasNoCafRefs, LambdaFormInfo: LFUnlifted,
   Unfolding: Core: <vanilla> "Brick.Util"#]
25821623dcaa0de3602048d0241b0272
  $trModule3 :: GHC.Types.TrName
  [HasNoCafRefs, TagSig: <TagProper>,
   LambdaFormInfo: LFCon[GHC.Types.TrNameS],
   Unfolding: Core: <vanilla> GHC.Types.TrNameS $trModule4]
b12dc367ea9d89d1d1636c9c3bf4b00e
  $trModule4 :: GHC.Prim.Addr#
  [HasNoCafRefs, LambdaFormInfo: LFUnlifted,
   Unfolding: Core: <vanilla> "brick-2.1.1-JKc4spU0lEiEu24TFAgt5W"#]
4e1c3492a0c2a7a9bfb2ed5cd606f644
  bg ::
    Graphics.Vty.Attributes.Color.Color -> Graphics.Vty.Attributes.Attr
  [HasNoCafRefs, TagSig: <TagProper>, LambdaFormInfo: LFReEntrant 1,
   Arity: 1, Strictness: <1L>, CPR: 1(1, 1, 3, 1),
   Unfolding: Core: StableSystem <1,TrueFalse>
              \ (v['GHC.Types.Many] :: Graphics.Vty.Attributes.Color.Color) ->
              case v of conrep { DEFAULT ->
              Graphics.Vty.Attributes.Attr
                (Graphics.Vty.Attributes.Default @Graphics.Vty.Attributes.Style)
                (Graphics.Vty.Attributes.Default
                   @Graphics.Vty.Attributes.Color.Color)
                (Graphics.Vty.Attributes.SetTo
                   @Graphics.Vty.Attributes.Color.Color
                   conrep)
                (Graphics.Vty.Attributes.Default @Data.Text.Internal.Text) }]
7bb1aa21bbe4320433066a606d601713
  clOffset ::
    Brick.Types.Internal.CursorLocation n
    -> Brick.Types.Common.Location
    -> Brick.Types.Internal.CursorLocation n
  [HasNoCafRefs, TagSig: <TagProper>, LambdaFormInfo: LFReEntrant 2,
   Arity: 2, Strictness: <1!P(1!P(ML,ML),L,L)><1!P(1!P(ML,ML))>,
   CPR: 1(1, ,),
   Unfolding: Core: <vanilla>
              clOffset1
                `cast`
              (forall (n :: <*>_N).
               <Brick.Types.Internal.CursorLocation n>_R
               %<'GHC.Types.Many>_N ->_R <Brick.Types.Common.Location>_R
               %<'GHC.Types.Many>_N ->_R Data.Functor.Identity.N:Identity[0]
                                             <Brick.Types.Internal.CursorLocation n>_R)]
17d74ed89395f5939471005c4bec84c1
  clOffset1 ::
    Brick.Types.Internal.CursorLocation n
    -> Brick.Types.Common.Location
    -> Data.Functor.Identity.Identity
         (Brick.Types.Internal.CursorLocation n)
  [HasNoCafRefs, TagSig: <TagProper>, LambdaFormInfo: LFReEntrant 2,
   Arity: 2, Strictness: <1!P(1!P(ML,ML),L,L)><1!P(1!P(ML,ML))>,
   CPR: 1(1, ,),
   Unfolding: Core: StableSystem <2,TrueFalse>
              \ @n
                (cl['GHC.Types.Many] :: Brick.Types.Internal.CursorLocation n)
                (off['GHC.Types.Many] :: Brick.Types.Common.Location) ->
              case cl of wild { Brick.Types.Internal.CursorLocation bx x2 x3 ->
              case bx of wild1 { (,) w1 h1 ->
              case off of wild2 { Brick.Types.Common.Location ds5 ->
              case ds5 of wild3 { (,) w2 h2 ->
              (Brick.Types.Internal.CursorLocation
                 @n
                 (GHC.Num.$fNumInt_$c+ w1 w2, GHC.Num.$fNumInt_$c+ h1 h2)
                 x2
                 x3)
                `cast`
              (Sym (Data.Functor.Identity.N:Identity[0]
                        <Brick.Types.Internal.CursorLocation n>_R)) } } } }]
b8043934dc53a0d927a5fd6cc618cf85
  clamp :: GHC.Classes.Ord a => a -> a -> a -> a
  [HasNoCafRefs, LambdaFormInfo: LFReEntrant 4, Arity: 4,
   Strictness: <SP(A,A,A,A,A,A,1C(1,C(1,L)),MC(1,C(1,L)))><L><L><L>,
   Unfolding: Core: <vanilla>
              \ @a
                ($dOrd['GHC.Types.Many] :: GHC.Classes.Ord a)
                (mn['GHC.Types.Many] :: a)
                (mx['GHC.Types.Many] :: a)
                (val['GHC.Types.Many] :: a) ->
              GHC.Classes.max @a $dOrd mn (GHC.Classes.min @a $dOrd val mx)]
550ca6ea003213685acbdae41b184a42
  fg ::
    Graphics.Vty.Attributes.Color.Color -> Graphics.Vty.Attributes.Attr
  [HasNoCafRefs, TagSig: <TagProper>, LambdaFormInfo: LFReEntrant 1,
   Arity: 1, Strictness: <1L>, CPR: 1(1, 3, 1, 1),
   Unfolding: Core: StableSystem <1,TrueFalse>
              \ (v['GHC.Types.Many] :: Graphics.Vty.Attributes.Color.Color) ->
              case v of conrep { DEFAULT ->
              Graphics.Vty.Attributes.Attr
                (Graphics.Vty.Attributes.Default @Graphics.Vty.Attributes.Style)
                (Graphics.Vty.Attributes.SetTo
                   @Graphics.Vty.Attributes.Color.Color
                   conrep)
                (Graphics.Vty.Attributes.Default
                   @Graphics.Vty.Attributes.Color.Color)
                (Graphics.Vty.Attributes.Default @Data.Text.Internal.Text) }]
8ee2efe4b50c3a44bde0998274276ff1
  on ::
    Graphics.Vty.Attributes.Color.Color
    -> Graphics.Vty.Attributes.Color.Color
    -> Graphics.Vty.Attributes.Attr
  [HasNoCafRefs, TagSig: <TagProper>, LambdaFormInfo: LFReEntrant 2,
   Arity: 2, Strictness: <1L><1L>, CPR: 1(1, 3, 3, 1),
   Unfolding: Core: StableSystem <2,TrueFalse>
              \ (f['GHC.Types.Many] :: Graphics.Vty.Attributes.Color.Color)
                (b['GHC.Types.Many] :: Graphics.Vty.Attributes.Color.Color) ->
              case f of conrep { DEFAULT ->
              case b of conrep1 { DEFAULT ->
              Graphics.Vty.Attributes.Attr
                (Graphics.Vty.Attributes.Default @Graphics.Vty.Attributes.Style)
                (Graphics.Vty.Attributes.SetTo
                   @Graphics.Vty.Attributes.Color.Color
                   conrep)
                (Graphics.Vty.Attributes.SetTo
                   @Graphics.Vty.Attributes.Color.Color
                   conrep1)
                (Graphics.Vty.Attributes.Default @Data.Text.Internal.Text) } }]
5c4b3dca4c4cb8dfdf4776b933d0cfb0
  style ::
    Graphics.Vty.Attributes.Style -> Graphics.Vty.Attributes.Attr
  [HasNoCafRefs, LambdaFormInfo: LFReEntrant 1, Arity: 1,
   Strictness: <1!P(L)>, CPR: 1(, 1, 1, 1),
   Unfolding: Core: StableSystem <1,TrueFalse>
              \ (v['GHC.Types.Many] :: Graphics.Vty.Attributes.Style) ->
              case v of wild { GHC.Word.W8# ww ->
              case GHC.Prim.word8ToWord# ww of wild1 {
                DEFAULT
                -> Graphics.Vty.Attributes.Attr
                     (Graphics.Vty.Attributes.SetTo
                        @Graphics.Vty.Attributes.Style
                        (GHC.Word.W8# ww))
                     (Graphics.Vty.Attributes.Default
                        @Graphics.Vty.Attributes.Color.Color)
                     (Graphics.Vty.Attributes.Default
                        @Graphics.Vty.Attributes.Color.Color)
                     (Graphics.Vty.Attributes.Default @Data.Text.Internal.Text)
                0## -> Graphics.Vty.Attributes.defAttr } }]
trusted: none
require own pkg trusted: False
docs:
  Nothing
extensible fields:

Note in particular

addDependentFile "/nix/store/wrkb3pn69pcw119qkh3w2244ch8iik0p-ghc-9.6.3/lib/ghc-9.6.3/lib/x86_64-osx-ghc-9.6.3/rts-1.0.2/include/ghcversion.h" e7af57aa93f9d398aa1e0e3b7cffda5c
addDependentFile "dist/build/autogen/cabal_macros.h" 71f026dacc318a609435ec7d26b74d98

brick sets default-extensions: CPP, so my hypothesis is that for any file that turns on CPP, GHC adds a dependency on its macro files. That's pretty reasonable, and it's likely that most projects have some genuine use of GHC's macros somewhere in their dependency closure, so the issue is just that doing so retains a reference to the full GHC.

Two possible ideas:

  • addDependentFile only matters for recompilation avoidance, I think, and we're relying on Nix for that anyway. So it might just be fine to hack these out?
  • Can we put the RTS in a separate output? Then packages would only depend on the (hopefully much smaller) RTS.
shlevy commented

What happens with nixpkgs haskell packages?

Same problem!

However, now that I think about it, I'm unsure that this is really a problem:

  • A stripped binary won't have this (it certainly won't have interface files)
  • If you have interface files around, it's usually because you're making an environment to compile in... in which case surely you have a compiler anyway!

Closing since I think this is a non-issue. I can't think of a situation where you would want the interface files built by GHC X and not also want GHC X too.