Project:LoongArch

Article description::The LoongArch Development Project is an effort to bring first-class support for the LoongArch CPU architecture to Gentoo. Because this is such a new platform with many fundamental pieces of software still under development, we also strive to make Gentoo/LoongArch the ideal testing ground for the wider community, so as to minimize the risk of overlooked mistakes going upstream.

Basic facts

 * We are . We don't use stable keywords for the moment.
 * Target triple is loongarch64-unknown-linux-gnu. (Official spec says the LP64D ABI is loongarch64-unknown-linux-gnuf64, at least for Debian, unsure if we should follow suit.)
 * All LoongArch systems are little-endian.
 * LoongArch is not binary compatible with either MIPS or RISC-V, although the ISA and ABI show heavy influence of the two.
 * There are six ABIs defined for LoongArch, much like those of RISC-V. But for Gentoo, we intend to focus on LP64D only first. Multilib support will come later if truly necessary.

Binary compatibility with other distros
Gentoo/LoongArch belongs to the new world, just like any other properly open-sourced community distribution for LoongArch.

This does mean that all commercial/closed-source offerings for LoongArch are unusable on Gentoo, such as Kingsoft Office (WPS Office) or LATX (Loongson Architecture Translator for X86; the Loongson binary translation solution allegedly based on QEMU and Wine but not open-source, supporting a subset of Windows applications and games), which are all compiled on, and for commercial distributions like Loongnix (pseudo-open-source), Kylin and UOS.

Status
Everything mostly works except the GUI (no upstream LLVM support = no AMDGPU support = no discrete graphics; support for the LS7A integrated graphics is not upstream), LiveCD used to work but is reported to have initrd problems.

Stage tarballs are currently built on a semi-regular basis by xen0n, and available on several Chinese mirrors:


 * hosted by Aliyun (Alibaba Cloud)
 * hosted by Tencent Cloud
 * hosted by Tsinghua University

The development work used to happen at loongson-overlay for things not currently upstreamable; we're going to focus on nailing down and upstreaming the profile bits first.

State of important packages
Because the architecture is still in its infancy, LoongArch support for many essential packages is still missing from upstream, aggravated by the fact that Loongson has not much experience in developing and upstreaming a brand-new architecture like this (and limited English communication abilities). Hence, the loongson-overlay (::loongson) must be configured for every installation for now.

Trying out the stages
It's of course best to have actual LoongArch hardware to play with; any model will do, as currently there is only one hardware implementation of LoongArch that is the 3A5000. There are many form factors available, from smaller MATX boards to 2U servers, but it can be hard to purchase outside of China.

Fortunately, there is working QEMU support for linux-user emulation, provided by the app-emulation/qemu package in ::loongson. Just enable the loongarch64 target:

binfmt_misc configuration for both OpenRC and systemd should be automatically generated and installed. Afterwards just chroot like with any other Gentoo installation.

System emulation support for LoongArch is present in this forked qemu version, but is too buggy to be usable. The package will be updated in ::loongson once the situation improves.

Cross-compiling for LoongArch
can be used to conveniently make LoongArch cross toolchains, once you have set up the ::loongson overlay.

You may optionally pin the versions for the various components to your liking, or if you see failures.

External resources

 * The unofficial yet comprehensive FAQ for LoongArch by xen0n
 * Unofficial collection of various Loongson docs by the community (not all of them are LoongArch-related)
 * The official LoongArch documentation by Loongson