Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to only compile Haskell source to interface file, not further? [duplicate]

Tags:

haskell

ghc

Usually, when ghc is compiling a source code, it will produce at least an .o (object) and a .hi (interface) file.

In the interest of diminishing compilation time, if I only need an interface file, can I somehow order ghc to abandon everything else and just give me said interface file? Or, otherwise, obtain that interface by any kind of lowly guile?

I found this ghc user guide part and it says nothing of such. This one doesn't even mention "interface" anywhere in its text. (In particular, -fno-code doesn't generate it.) It must mean there's no easy way. In this question from five years ago, nothing floated up, but by chance things are different now?

Most likely, I expect it to take a hack to ghc. If so, I'd like directions:

  • Is it reasonable to submit a feature request to trac, or (likely) I should rather go for it myself?
  • How is .hi file distinct from something like -ddump-types, just binary?
  • Is there certainty that composing a .hi file takes strictly less compilation stages than a complete .o file? (For example, if there are hashes of machine code fragments within .hi, the corresponding code will probably have to be generated, which means nothing is to be gained here.)

Otherwise, perhaps I can just extract related parts from ghc code so that I can then compile a .hi file from the output of -ddump-types or the like?

like image 795
Ignat Insarov Avatar asked Feb 08 '18 09:02

Ignat Insarov


1 Answers

Actually, there is a flag -fno-code -fwrite-interface that does this. It actually cuts compilation time for even a simplistic example by about a quarter.

like image 167
Ignat Insarov Avatar answered Nov 11 '22 17:11

Ignat Insarov