Cross compile GHC project using aarch64-linux-gnu-ghc

Hi,

I have generated the GHC cross compiler aarch64-linux-gnu-ghc and trying to cross compile simplexmq (GitHub - simplex-chat/simplexmq: ⚙️ SimpleXMQ - A reference implementation of the SimpleX Messaging Protocol for simplex queues over public networks.) for ARM64 bit architecture.

But i am getting the error:

: error
could not find a target code interpreter. Try with -fexternal-interpreter.

Looking for the help.

Thanks
Ashish

GHC cross-compilers do not support TH (nor annotations) out-of-the-box. You need to build an external interpreter program (called iserv) for the target, to run it into qemu or on a real aarch64 playform, to setup an iserv-proxy for ghc to communicate with it… haskell.nix does this automatically afaik, so it may be easier to use it.

1 Like

i am new to ghc. can you provide steps to install/compile iserv?

  1. Build remote-iserv program for aarch64 using your cross-compiler. Sources are in the ghc tree (utils/remote-iserv)
  2. Build iserv-proxy program using a non cross-compiling GHC. Sources have been moved here: Making sure you're not a bot! after Making sure you're not a bot!
  3. Run remote-iserv on some aarch64 host (virtual or not)
  4. Use GHC cross-compiler with the following flags: -fexternal-interpreter -pgmi path/to/iserv-proxy -opti10.0.1.21 -opti500 (adapt the arguments to the ip/port of the remote-iserv host).

I’ve never done it but @angerman has. See his old blog posts: Android and Template Haskell. With the Haskell Cross Compiler for… | by zw3rk | Medium

Thanks for your guidence. Given 4 points look good. Let me try and get back to you.

when building utils/remote-iserv

cabal install -flibrary -fproxy -w aarch64-linux-gnu-ghc. But got the below error:

src/Cli.hs:3:1: error:
Could not find module ‘Remote.Slave’
Use -v (or :set -v in ghci) to see a list of the files searched for.
|
3 | import Remote.Slave (startSlave’)
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: cabal: Failed to build exe:remote-iserv from remote-iserv-9.6.3. See

It seems the code has been removed in iserv: Remove network dependent parts of libiserv (6b2947d2) · Commits · Glasgow Haskell Compiler / GHC · GitLab You can restore it directly in remote-iserv I think.

You may want to open a GHC ticket about this… What a mess