Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cross-compilation with GHC

Tags:

Is it possible to do cross-compilation with the Glasgow Haskell Compiler for common architectures?

If not, is this feature planned to be developed in the near future?

like image 898
orftz Avatar asked May 30 '11 00:05

orftz


People also ask

Does GCC support cross-compilation?

GCC, a free software collection of compilers, can be set up to cross compile. It supports many platforms and languages. Cross-compiling GCC requires that a portion of the target platform's C standard library be available on the host platform.

How do you cross-compile arms with GCC?

Save this answer. Install gcc-arm-linux-gnueabi and binutils-arm-linux-gnueabi packages, and then just use arm-linux-gnueabi-gcc instead of gcc for compilation. This brings in the complete cross-compile environment, including binutils. On Ubuntu 13.10 you get gcc-4.7 for 'gnueabi' and gcc-4.8 for 'gnueabihf'.

What is the cross-compilation process?

Cross-compilation is the act of compiling code for one computer system (often known as the target) on a different system, called the host. It's a very useful technique, for instance when the target system is too small to host the compiler and all relevant files.

Why is cross-compiling so hard?

"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.


1 Answers

As of this moment (GHC 7.0) GHC does not support cross-compilation.

As of 2013, "support for cross-compilation works reasonably well in GHC 7.8.1".

See the status on the CrossCompilation wiki page.


Discussion

GHC has always supported self-cross-compilation (i.e. you can port GHC to a new architecture). However, GHC as a cross-compiler, that runs on a host, but produces binaries that target another, has not been supported.

As of GHC 7 though, with the new LLVM backend, work is being undertaken to add cross-compilation support. Status appears to be, from Mark Lentczner, "At this point I can build and link and run a stage1 cross-compiler." So stay tuned for GHC 7.2

like image 95
Don Stewart Avatar answered Oct 01 '22 08:10

Don Stewart