How do I install dependencies when cross compiling haskell code?

こ雲淡風輕ζ 提交于 2019-12-05 00:51:36

To understand this error, you need to know how cabal install works internally. In essence, it will perform the following steps:

  1. Download and unpack the source code
  2. Compile Setup.hs (this file is used for customization of the build system, for example, you can implement some hooks to run additional haskell code in the configure phase).
  3. Run setup configure <configure flags> && setup build && setup install

The problem is now that cabal install uses the GHC given by --with-ghc also for step 2, but the executable produced by that step must run on the host system!

A workaround is to do the steps manually, which means you have full control. First, get the source:

$ cabal get random
Downloading random-1.0.1.3...
Unpacking to random-1.0.1.3/
$ cd random-1.0.1.3

Then, compile Setup.hs, using the host ghc:

$ ghc ./Setup.hs -o setup

And finally, configure, build and install. As suggested by @Yuras in a comment, we also add the -x option for running hsc2hs:

$ ./setup configure ----with-ghc=arm-unknown-linux-gnueabi-ghc --with-ghc-pkg=arm-unknown-linux-gnueabi-ghc-pkg --with-ld=arm-unknown-linux-gnueabi-ld --hsc2hs-options=-x
$ ./setup build && ./setup install

There is already a cabal issue about this: https://github.com/haskell/cabal/issues/2085

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!