Skip to content

Unknown register rts/StgCRun.c building cross compiler for AArch64

Summary

Trying to build a cross compiler for AArch64 results in compile errors in rts/StgCRun.c

Steps to reproduce

Using a docker container with

FROM ubuntu:20.04

ARG DEBIAN_FRONTEND=noninteractive

# Enable for aarch64 (and arm64 which is the same)
RUN dpkg --add-architecture aarch64

# Enable source code in apt
RUN (cp /etc/apt/sources.list /etc/apt/sources.list~ && sed -Ei 's/^# deb-src /deb-src /' /etc/apt/sources.list)

RUN apt-get update && apt-get -y -q install libgmp-dev git apt-file make wget xz-utils gcc patchelf python3 python3-pip python3-venv libnuma-dev binutils texlive-xetex texlive-fonts-extra texlive-lang-cyrillic latexmk libncurses-dev libtinfo5 zlib1g-dev curl npm cmake time xindy lua5.3 liblua5.3-dev luarocks markdown perl

RUN ( ln -s /usr/bin/make /usr/bin/gmake )

# GHC build environment
RUN apt-get -y -q build-dep ghc

# AArch64 cross tools and libraries
RUN apt-get -y -q install binutils-aarch64-linux-gnu cpp-10-aarch64-linux-gnu gcc-10-aarch64-linux-gnu

RUN apt-get -y -q install linux-libc-dev-arm64-cross libc6-arm64-cross libc6-dev-arm64-cross

RUN apt-get -y -q install llvm-9

RUN ( cd /tmp && wget -q https://downloads.haskell.org/~ghc/8.10.2/ghc-8.10.2-src.tar.xz )

RUN ( cd /tmp && xzcat ghc-8.10.2-src.tar.xz | tar xf - )

RUN ( cd /tmp/ghc-8.10.2 && sed 's/#.* = quick-cross$/BuildFlavour = quick-cross/' mk/build.mk.sample > mk/build.mk && perl boot && ./configure --target=aarch64-linux-gnu --prefix=$HOME/GHC/Cross/ && make -j4 && make install )

Results in compilation errors as follows:

rts/StgCRun.c:939:5: error:
     error: unknown register name '%x30' in 'asm'
      939 |     __asm__ volatile (
          |     ^~~~~~~
    |
939 |     __asm__ volatile (
    |     ^

rts/StgCRun.c:939:5: error:
     error: unknown register name '%x17' in 'asm'
    |
939 |     __asm__ volatile (
    |     ^

rts/StgCRun.c:939:5: error:
     error: unknown register name '%x16' in 'asm'

...

Add the description above to a Dockerfile and build a container with a command like:

% docker build -t aarch64-cross-build <<docker-directory>>

Expected behavior

It had hoped it would compile without errors.

Environment

  • GHC version used: Trying to build ghc-8.10.2

Optional:

  • Operating System: I run this on an Arch Linux host.
  • System Architecture: amd64
Edited by Håkan Thörngren
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information