From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 64BA6139360 for ; Wed, 11 Aug 2021 16:39:43 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 93C17E0801; Wed, 11 Aug 2021 16:39:38 +0000 (UTC) Received: from mailbox.box.xen0n.name (unknown [115.28.160.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D6518E03EC for ; Wed, 11 Aug 2021 16:39:37 +0000 (UTC) Received: from [192.168.9.172] (unknown [101.86.3.130]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id E183D600FF for ; Thu, 12 Aug 2021 00:39:33 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=xen0n.name; s=mail; t=1628699973; bh=JAAe5ZlLRkh0lTGkpx8K7BK6U3+ba9/xGyY8UQoTEtw=; h=Date:To:From:Subject:From; b=sG34XxQdwPfZzign3jq4e+pt7hKX3lW0qLGEKaMNBQEB44RIf/wKrc4wa7q13Y+Eq gxr0qoERN8quNuy/gruCQRQp52ixCR9+Dra3XkC7J+XyotCUnSlSTXnuKVrbYjOeNF guPsYpJM1bF+lK2AQIbVkDGVZqupdIiwnrZYkrcY= Message-ID: Date: Thu, 12 Aug 2021 00:39:33 +0800 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Thunderbird/93.0a1 Content-Language: en-US To: gentoo-dev@lists.gentoo.org From: WANG Xuerui Subject: [gentoo-dev] [RFC] Plans for a Gentoo/LoongArch port Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Archives-Salt: 7ce41733-9902-4b45-a751-bb7a3718cd30 X-Archives-Hash: ef0b1812e9b66cdf5978ecc2ad4eda4e Hi everyone, I'm your average Gentoo user who obviously thought his sleeping time is more than enough, and just decided to start porting Gentoo to LoongArch. As this is such a niche architecture with no upstreamed support so far, I'm posting this to announce my intent and gather advice on how to best push this. I'll first give some background material to help people gain context, then describe my porting plan. This is going to be a bit long; apologizes for that. Note: I'm not affiliated with Loongson in any way; I'm just doing this in my spare time (once meant for some quality sleep). ## A bit of introduction on the LoongArch LoongArch, as its name implies, is the brand-new ISA developed by the Loongson Corporation, incompatible with MIPS which was implemented by all previous Loongson processors. Currently only the base ISA specification is publicly available; it has fixed-length 32-bit instructions, vastly more instruction formats (39 distinct formats in the base ISA alone!), and its instruction semantics mostly resemble RISC-V, with a bit of MIPS R6 here and there. It is capable of 64-bit operations, obviously. ISA documentation: https://github.com/loongson/LoongArch-Documentation ELF psABI draft: https://github.com/loongson/LoongArch-Documentation/pull/3 The draft ABI is undergoing fierce review, and is subject to change, especially the relocation types. Other parts like the register convention and data layout is unlikely to change much, though. There is little code upstreamed for basic software (GNU toolchain, QEMU, Linux and the like), but many are open-sourced already. Nevertheless, the code quality is still very much inferior, and much of it is obviously based on respective MIPS support. There is continuous debate inside and outside Loongson on this matter, too. Kernel ABI and glibc code seems to be inspired by RISC-V, but still some parts show MIPS heritage. The kernel bits are being reviewed on the linux-arch mailing list. All of the projects above can be accessed at https://github.com/loongson. Loongson 3A5000 is the first LoongArch CPU; the Lemote A2101 board with this CPU can be bought in China for ~4000 CNY already. ## Gentoo porting plans I'm planning to take ARCH=loongarch for the port; and support the LP64 ABI first. I'd like to support both LP64 and ILP32 ABIs, but that's not a priority. The ABI flag might be named "ABI_LOONGARCH" but that's IMO a bit long (pun semi-intended); ARCH=loong and ABI_LOONG might be better, I'm open to suggestions. Because much of the ABI and even some toolchain internals are going through VERY fierce debate and rework, obviously the port will remain experimental for a long time. Some minimal support should get in tree though; doing so would ease a lot of pain for experimentation. I already hacked my way to generate working crossdev toolchains, and is halfway towards a rootfs with working Python (and Portage). I've already independently ported strace, and plan to do the same to libffi in the coming days which would give me Python. I'll do all work in my own loongson-overlay first, and upstream these when appropriate. Eventually I hope to have working crossdev, qemu-user emulation and proper catalyst support. And that's about all; the message is getting long! Your opinions are welcome, and thanks again for following along. Regards, WANG "xen0n" Xuerui