Haskell: How to only generate .hi file with ghc?

后端 未结 2 1266
执笔经年
执笔经年 2021-01-06 08:49

I would like to generate an .hi interface file and only that (no object file, no code generation at all).

I tried

ghc -         


        
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-06 08:59

    Use -c option, or else ghc wants to link, not just to compile:

    ghc -fno-code -ohi out.hi -c myfile.hs
    

    UPDATE: but it doesn't really help, because -fno-code prevents .hi creation.

    ghc -o /dev/null -ohi out.hi -c myfile.hs
    

    This one throws away the result of compilation. However, it will also avoid unnecessary compilation if out.hi is up to date.

提交回复
热议问题