This is GHC's Wiki related to LoongArch64.
The main issues here are related to GHC on the LoongArch64 platform, including but not limited to the following(To be kind to my wrist, I'll shorten LoongArch64 to Loong64.):
Latest Status:
- NCG Backend: Finished but need to be optimized.
- RTS Linker: Work In Progress.
Introduction to LoongArch
On the following pages you will get detailed information:
About LoongArch(https://docs.kernel.org/arch/loongarch/introduction.html)
Environment where you can build GHC-Loong64
Currently all my authentication is based on the debian:sid container, which you can get with the following command:
docker pull lcr.loongnix.cn/library/debian:sid
As to cross-compiling, maybe the GHC's official wiki is enough.
The default version of ghc in debian:sid is 9.6.
Since the master branch code is currently generating larger object files, this can cause the R_LARCH_B26 relocation type overflow problem that is specific to the LoongAach64 platform. For convenience, I've ported to version 9.10, which also adds NCG support. This way, it is possible to build ghc-9.10 with the existing binary, and then build ghc-master.
Build steps:
./boot
./configure (for building master, to use GHC=$PATH/ghc-9.10 specify the compiler)
hadrian/build --config="config.timeout=5000" --docs=none binary-dist test -j[NCPUs]
Personal Repo:
loong64-ncg-9.10(https://gitlab.haskell.org/fp/ghc/-/tree/loong64-ncg-9.10)
Via the NCG backend
Added NCG support to LoongArch64 to reduce compilation time having to wait.
So far, I've completed a basic port of the NCG, but there's still a lot of room for improvement in performance.
Subsequently, I will further optimize the code generation to make sure to use less compilation time and smaller code size.
FAQs with GHC-Loong64 builds
Building with LLVM
'int128 ' in GMP is not complatible with --with-intre-gmp
If you build GHC with llvm and include the --with-intree-gmp parameter, odds are you'll run into this problem.
Cause: int128 is not knowned by LLVM, change another kind. __int128.