1 |
HI Xuerui: |
2 |
|
3 |
This must be a *HUGE* project and gonna put lots of effort in to it! |
4 |
So, first, good luck to you with all my best wishes!~ |
5 |
|
6 |
On 00:39 Thu 12 Aug , WANG Xuerui wrote: |
7 |
> Hi everyone, |
8 |
> |
9 |
> I'm your average Gentoo user who obviously thought his sleeping time is more |
10 |
> than enough, and just decided to start porting Gentoo to LoongArch. As this |
11 |
> is such a niche architecture with no upstreamed support so far, I'm posting |
12 |
> this to announce my intent and gather advice on how to best push this. |
13 |
> |
14 |
> I'll first give some background material to help people gain context, then |
15 |
> describe my porting plan. This is going to be a bit long; apologizes for |
16 |
> that. |
17 |
> |
18 |
> |
19 |
> Note: I'm not affiliated with Loongson in any way; I'm just doing this in my |
20 |
> spare time (once meant for some quality sleep). |
21 |
> |
22 |
> |
23 |
> ## A bit of introduction on the LoongArch |
24 |
> |
25 |
> LoongArch, as its name implies, is the brand-new ISA developed by the |
26 |
> Loongson Corporation, incompatible with MIPS which was implemented by |
27 |
> all previous Loongson processors. Currently only the base ISA specification |
28 |
> is publicly available; it has fixed-length 32-bit instructions, vastly more |
29 |
> instruction formats (39 distinct formats in the base ISA alone!), and its |
30 |
> instruction semantics mostly resemble RISC-V, with a bit of MIPS R6 here and |
31 |
> there. It is capable of 64-bit operations, obviously. |
32 |
> |
33 |
> ISA documentation: https://github.com/loongson/LoongArch-Documentation |
34 |
> ELF psABI draft: https://github.com/loongson/LoongArch-Documentation/pull/3 |
35 |
> |
36 |
> The draft ABI is undergoing fierce review, and is subject to change, |
37 |
> especially the relocation types. Other parts like the register |
38 |
> convention and |
39 |
> data layout is unlikely to change much, though. |
40 |
> |
41 |
> There is little code upstreamed for basic software (GNU toolchain, QEMU, |
42 |
> Linux and the like), but many are open-sourced already. Nevertheless, the |
43 |
> code quality is still very much inferior, and much of it is obviously based |
44 |
> on respective MIPS support. There is continuous debate inside and outside |
45 |
> Loongson on this matter, too. |
46 |
> |
47 |
Didn't do any investigation, but if I read correctly, also see here [1] |
48 |
|
49 |
The fundamental pieces of softwares are open-sourced but *NOT* yet upstreamed |
50 |
So, I'd say, let's wait till it's actually accepted by upstream, |
51 |
before pushing to downsteam (Gentoo here). Sure, you're free to send |
52 |
a pull-request for review/comment, but collect peices under your own overlay |
53 |
would be a good idea ( in my humble opition ). |
54 |
|
55 |
|
56 |
> Kernel ABI and glibc code seems to be inspired by RISC-V, but still some |
57 |
> parts show MIPS heritage. The kernel bits are being reviewed on the |
58 |
> linux-arch |
59 |
> mailing list. |
60 |
> |
61 |
> All of the projects above can be accessed at https://github.com/loongson. |
62 |
> |
63 |
> Loongson 3A5000 is the first LoongArch CPU; the Lemote A2101 board with this |
64 |
> CPU can be bought in China for ~4000 CNY already. |
65 |
> |
66 |
> |
67 |
> ## Gentoo porting plans |
68 |
> |
69 |
> I'm planning to take ARCH=loongarch for the port; and support the LP64 ABI |
70 |
> first. I'd like to support both LP64 and ILP32 ABIs, but that's not a |
71 |
> priority. |
72 |
> |
73 |
start with LP64 would be good idea, so same as RISC-V here. |
74 |
|
75 |
> The ABI flag might be named "ABI_LOONGARCH" but that's IMO a bit long (pun |
76 |
> semi-intended); ARCH=loong and ABI_LOONG might be better, I'm open to |
77 |
> suggestions. |
78 |
> |
79 |
> Because much of the ABI and even some toolchain internals are going through |
80 |
> VERY fierce debate and rework, obviously the port will remain experimental |
81 |
> for a long time. Some minimal support should get in tree though; doing so |
82 |
> would ease a lot of pain for experimentation. I already hacked my way to |
83 |
> generate working crossdev toolchains, and is halfway towards a rootfs with |
84 |
> working Python (and Portage). I've already independently ported strace, and |
85 |
> plan to do the same to libffi in the coming days which would give me Python. |
86 |
> |
87 |
> I'll do all work in my own loongson-overlay first, and upstream these when |
88 |
> appropriate. Eventually I hope to have working crossdev, qemu-user emulation |
89 |
> and proper catalyst support. |
90 |
> |
91 |
> |
92 |
sounds a good plan, first start with making cross compiling work, then try to |
93 |
populate a mini rootfs (kernel, glibc, base system), then python, portage |
94 |
|
95 |
|
96 |
> And that's about all; the message is getting long! Your opinions are |
97 |
> welcome, |
98 |
> and thanks again for following along. |
99 |
> |
100 |
> |
101 |
|
102 |
[1] https://github.com/gentoo/portage/pull/740#issuecomment-895021854 |
103 |
|
104 |
-- |
105 |
Yixun Lan (dlan) |
106 |
Gentoo Linux Developer |
107 |
GPG Key ID AABEFD55 |