Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
GHC
GHC
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 4,265
    • Issues 4,265
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge Requests 419
    • Merge Requests 419
  • Requirements
    • Requirements
    • List
  • CI / CD
    • CI / CD
    • Pipelines
    • Jobs
    • Schedules
  • Security & Compliance
    • Security & Compliance
    • Dependency List
    • License Compliance
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI / CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Glasgow Haskell Compiler
  • GHCGHC
  • Wiki
    • Building
  • cross compiling on debian

Last edited by Tobias Dammers Mar 29, 2019
Page history New page

cross compiling on debian

Setting up a Debian system to build a GHC cross-compiler

This is a (possibly incomplete) guide to setting up a Debian system to allow building a cross compiler. This is known to work for building x86_64 to armhf and x86_64 to arm64 cross compilers. Others architectures may also work. For the purposes of this documentation we will assume that we want to cross-compiler for both 32 bit armhf and 64 bit arm63/aarch64.

A good first step is to make sure that your machine is set up the build a native GHC. The easiest way to do this is to run:

sudo apt-get build-dep ghc

This installs all the packages need to build a the native GHC Debian package.

Now its time to set up Debain multi-arch which allows you to install Debian packages for more than one architecture on a single machine. The Debian documention for this is at https://wiki.debian.org/Multiarch/HOWTO .

Once that is set up you should be able to query the available architectures using:

dpkg --print-foreign-architectures

That command should list the new foreign architectures.

Then make sure that the machine's local apt database gets updated using:

sudo apt-get update

The next step is to install the required C compilers, binutils and libraries required to build the GHC cross compilers. First for arm64/aarch64:

sudo apt-get install binutils-aarch64-linux-gnu cpp-5-aarch64-linux-gnu gcc-5-aarch64-linux-gnu
sudo apt-get install linux-libc-dev-arm64-cross libc6-arm64-cross libc6-dev:arm64
sudo apt-get install libtinfo-dev:arm64 libncurses5:arm64 libncurses5-dev:arm64 

and then for armhf:

sudo apt-get install binutils-arm-linux-gnueabihf cpp-5-arm-linux-gnueabihf gcc-5-arm-linux-gnueabihf
sudo apt-get install linux-libc-dev-armhf-cross libc6-armhf-cross libc6-dev:arm64
sudo apt-get install libtinfo-dev:armhf libncurses5:armhf libncurses5-dev:armhf

Finally, to build for both arm64 and armhf, you need to install the LLVM tools. To build GHC 7.10 you will need llvm-3.5 while to build GHC 8.0 you will need llvm-3.7. Its ok to install both using:

sudo apt-get install llvm-3.5 llvm-3.7

And thats it! Assuming you already have the GHC source distribution of Git checkout, build a cross compiler is as simple as changing into the top level directory of the sources and doing (arm-linux-gnueabihf can be replaced with aarch64-linux-gnu) :

sed 's/#.* = quick-cross/BuildFlavour = quick-cross/' mk/build.mk.sample > mk/build.mk
perl boot
./configure --target=arm-linux-gnueabihf --prefix=$HOME/GHC/Cross/
make -j4
make install

Assuming everything succeeded, you will now have your cross compiler in $HOME/GHC/Cross/.

Clone repository

GHC Home
GHC User's Guide

Joining In

Newcomers info
Mailing Lists & IRC
The GHC Team

Documentation

GHC Status Info
Working conventions
Building Guide
Debugging
Commentary

Wiki

Title Index
Recent Changes