有没有办法只编译Haskell源接口文件,而不是进一步? [英] Is there a way to only compile Haskell source to interface file, not further?

查看:87
本文介绍了有没有办法只编译Haskell源接口文件,而不是进一步?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通常,当 ghc 编译源代码时,它至少会产生一个 .o (object)和 .hi (接口)文件。

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

为了减少编译时间,如果我只需要接口文件,我可以以某种方式命令 ghc 放弃一切,只给我说的接口文件?或者,否则,通过任何一种卑微的诡计获取该接口?

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?

我发现这个 ghc 用户指南部分,它没有提到这些。 这一个甚至没有在文本的任何地方提及 interface 。 (特别是, -fno-code 不会生成它。)它意味着没有简单的方法。在五年前的这个问题中,没有任何东西出现,但偶然的情况现在有所不同了?

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?

大多数情况下,我预计它会对 ghc 进行破解。如果是这样,我想要指示:

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


  • trac ,或者(可能)我宁愿自己去找它?

  • .hi 文件与 -ddump-types ,只是二进制文件?

  • 是否可以确定编写 .hi 文件的编译阶段比完整的 .o 文件? (例如,如果 .hi 中存在机器代码片段的哈希值,则可能必须生成相应的代码,这意味着这里没有任何内容。)

  • 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.)

否则,也许我可以从 ghc 代码中提取相关的部分,这样我然后可以从 -ddump-types 之类的输出中编译 .hi 文件?

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?

推荐答案

实际上,有一个标记 -fno-code -fwrite-interface 。它实际上缩短了编译时间,甚至是一个简单的例子大约四分之一。

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.

这篇关于有没有办法只编译Haskell源接口文件,而不是进一步?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆