Skip to content

ghc -odir is incompatible with .hs-boot files for hierarchical modules

Steps to reproduce

  1. Adapt the example of how to compile mutually recursive modules so that the modules involved have hierarchical names:

File S/A.hs:

module S.A where
    import S.B( TB(..) )
    
    newtype TA = MkTA Int
    
    f :: TB -> TA
    f (MkTB x) = MkTA x

File S/A.hs-boot:

module S.A where
    newtype TA = MkTA Int

File S/B.hs:

module S.B where
    import {-# SOURCE #-} S.A( TA(..) )
    
    data TB = MkTB !Int
    
    g :: TA -> TB
    g (MkTA x) = MkTB x
  1. Compile as the example suggests, but with -odir:
mkdir out
ghc -odir out -c S/A.hs-boot

Expected behaviour

GHC silently creates the directory out/S and then emits the file A.o-boot in that directory.

Observed behaviour

GHC produces the error message:

touch: cannot touch `out/S/A.o-boot': No such file or directory

Note: this happens with ghc --make as well.

Workaround

Create the directory out/S beforehand.

Trac metadata
Trac field Value
Version 7.0.4
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information