Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the LoongArch architecture #518

Closed
3 tasks done
xen0n opened this issue Jun 8, 2022 · 4 comments
Closed
3 tasks done

Add support for the LoongArch architecture #518

xen0n opened this issue Jun 8, 2022 · 4 comments
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team

Comments

@xen0n
Copy link

xen0n commented Jun 8, 2022

Proposal

tl;dr: Make LoongArch a new supported architecture, initially supporting the following 2 tuples:

Target Notes Eventual tier
loongarch64-unknown-linux-gnuf64 LoongArch LA64, Linux, LP64D ABI (kernel 5.19, glibc TBD, expected 2.36) Tier 2 with host tools
loongarch64-unknown-linux-muslf64 LoongArch LA64, Linux, LP64D ABI (kernel 5.19, musl TBD) Tier 2

after the LoongArch ports of LLVM, glibc and musl fully land.

LoongArch is a new RISC architecture developed by the Loongson Technology Corporation, with pretty complete upstream support (binutils 2.38, gcc 12.1.0, linux v5.19-rc1, qemu 7.1). Ports for LLVM, glibc and musl are already under review, I'm one of the reviewers so I'll update this whenever new progress happens.

This architecture already has a small but growing user base in China, that mainly consists of software porters and hobbyist end-users for now (June 2022). Growth is expected to continue in the coming years, expanding to the general consumer market. The architecture is capable of full-fledged desktop and server workload alike, in addition to SoC models intended for embedded.

Latest version of the LoongArch ELF psABI specification can be found here, while current toolchain convention document is available here. The ISA manual (currently revision v1.00) is here; new ISA revisions are expected to keep backwards compatibility so we don't need to encode the revision in the target tuple (ideally just configure target-cpu just like any other arch).

The LoongArch ABI is modeled after that of RISC-V, so there are 6 ABIs in total (LP64/ILP32; soft-float, SP/DP hard-float). The only fully developed ABI is LP64D, others are mostly unusable right now. According to the toolchain convention doc, the Debian multiarch tuples for LP64D are loongarch64-linux-gnuf64 (glibc) and loongarch64-linux-muslf64 (musl) respectively, so we should pick loongarch64-unknown-linux-gnuf64 and loongarch64-unknown-linux-muslf64 for the Rust tuples.

Eventually, the loongarch64-unknown-linux-gnuf64 target should reach Tier 2 with host tools status, because this platform can, and is used, for serious development work, but is not expected to gain enough adoption to be considered Tier 1. The musl target should eventually get to Tier 2 as well; but for the initial bring-up, starting at Tier 3 is expected, for the code to gradually appear and settle.

I'm posting this before all the necessary ports (esp. LLVM) are ready, for convenience and early comments. Some of the ports were rushed (as is the architecture itself), and we really don't want to rush another project.

(Disclaimer: I'm not affiliated with Loongson or any of the Loongson ecosystem companies.)

Mentors or Reviewers

I haven't done serious Rust work recently (my last serious change predated the MCP process, actually) so I don't know who to put here; but I can mentor or do the whole port myself (I polished the Rust MIPS support back in 2015/16, and the basic flow hasn't changed since).

Process

The main points of the Major Change Process are as follows:

  • File an issue describing the proposal.
  • A compiler team member or contributor who is knowledgeable in the area can second by writing @rustbot second.
    • Finding a "second" suffices for internal changes. If however, you are proposing a new public-facing feature, such as a -C flag, then full team check-off is required.
    • Compiler team members can initiate a check-off via @rfcbot fcp merge on either the MCP or the PR.
  • Once an MCP is seconded, the Final Comment Period begins. If no objections are raised after 10 days, the MCP is considered approved.

You can read more about Major Change Proposals on forge.

Comments

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

@xen0n xen0n added major-change A proposal to make a major change to rustc T-compiler Add this label so rfcbot knows to poll the compiler team labels Jun 8, 2022
@rustbot
Copy link
Collaborator

rustbot commented Jun 8, 2022

This issue is not meant to be used for technical discussion. There is a Zulip stream for that. Use this issue to leave procedural comments, such as volunteering to review, indicating that you second the proposal (or third, etc), or raising a concern that you would like to be addressed.

cc @rust-lang/compiler @rust-lang/compiler-contributors

@rustbot rustbot added the to-announce Announce this issue on triage meeting label Jun 8, 2022
@xry111
Copy link

xry111 commented Jun 8, 2022

I have a "working" rustc fork for LoongArch: https://github.com/xry111/rust/tree/xry111/loongarch-1.61.0. At least it can compile Spidermonkey and librsvg so I can make GNOME running on my LoongArch board.

The rustc fork currently depends on a LLVM fork with patches authored by Loongson people and rebased & adjusted by me: https://github.com/xry111/llvm-project/tree/xry111/loongarch-14

I don't expect a very soon ending of LLVM upstreaming process (the code generation for integer arithmetics was just submitted for review yesterday), so I'll try libgccjit codegen next. If libgccjit works hopefully we won't be blocked by LLVM.

Another blocker is glibc. As long as glibc port is not merged, we cannot submit rust binding for libc code for review. The libc crate is needed by std crate. But thanks to your effort I think glibc LoongArch port may be merged before Aug :).

All deleted as all my work shall be superseded now.

@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jun 16, 2022
@wesleywiser
Copy link
Member

@rustbot second

@rustbot rustbot added the final-comment-period The FCP has started, most (if not all) team members are in agreement label Aug 25, 2022
@apiraino
Copy link
Contributor

apiraino commented Sep 8, 2022

@rustbot label -final-comment-period +major-change-accepted

@apiraino apiraino closed this as completed Sep 8, 2022
@rustbot rustbot added major-change-accepted A major change proposal that was accepted to-announce Announce this issue on triage meeting and removed final-comment-period The FCP has started, most (if not all) team members are in agreement labels Sep 8, 2022
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Sep 8, 2022
bors added a commit to rust-lang-ci/rust that referenced this issue May 23, 2023
ci: Add support for dist-loongarch64-linux

We are preparing to promote loongarch64-unknown-linux-gnu to Tier 2, and one of the tasks is to add CI support. We are currently in the process of upgrading the dependencies for the build tools, and before this is completed, we would like to request comments. Thanks

#### Progress

- [x] Update linux-raw-sys to 0.3.2 (rust-lang/cargo#11998)
- [x] Update openssl-src to 111.25.3+1.1.1t (rust-lang/cargo#12005)
- [x] bootstrap: Update linux-raw-sys to 0.3.2 (rust-lang#110516)
- [x] Update linux-raw-sys to 0.3.4 (rust-lang#110518)
- [x] Update cargo (rust-lang#110834)
- [x] linux_like: Add missing constants for loongarch64 (rust-lang/libc#3237)
- [x] Release 0.2.143 (rust-lang/libc#3236)
- [x] Update libc to 0.2.144 (rust-lang/cargo#12098)
- [x] Update cargo (rust-lang#111456)

Tier 2 with host tools MCP: rust-lang/compiler-team#518
bors added a commit to rust-lang-ci/rust that referenced this issue May 24, 2023
…imulacrum

Promote loongarch64-unknown-linux-gnu to Tier 2 with host tools

This PR promotes `loongarch64-unknown-linux-gnu` to Tier 2 (with host tools).

MCP: rust-lang/compiler-team#518
saethlin pushed a commit to saethlin/miri that referenced this issue May 26, 2023
ci: Add support for dist-loongarch64-linux

We are preparing to promote loongarch64-unknown-linux-gnu to Tier 2, and one of the tasks is to add CI support. We are currently in the process of upgrading the dependencies for the build tools, and before this is completed, we would like to request comments. Thanks

#### Progress

- [x] Update linux-raw-sys to 0.3.2 (rust-lang/cargo#11998)
- [x] Update openssl-src to 111.25.3+1.1.1t (rust-lang/cargo#12005)
- [x] bootstrap: Update linux-raw-sys to 0.3.2 (rust-lang/rust#110516)
- [x] Update linux-raw-sys to 0.3.4 (rust-lang/rust#110518)
- [x] Update cargo (rust-lang/rust#110834)
- [x] linux_like: Add missing constants for loongarch64 (rust-lang/libc#3237)
- [x] Release 0.2.143 (rust-lang/libc#3236)
- [x] Update libc to 0.2.144 (rust-lang/cargo#12098)
- [x] Update cargo (rust-lang/rust#111456)

Tier 2 with host tools MCP: rust-lang/compiler-team#518
saethlin pushed a commit to saethlin/miri that referenced this issue May 26, 2023
Promote loongarch64-unknown-linux-gnu to Tier 2 with host tools

This PR promotes `loongarch64-unknown-linux-gnu` to Tier 2 (with host tools).

MCP: rust-lang/compiler-team#518
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…iser

Add new Tier-3 target: `loongarch64-unknown-linux-musl`

MCP: rust-lang/compiler-team#518
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…iser

Add new Tier-3 target: `loongarch64-unknown-linux-musl`

MCP: rust-lang/compiler-team#518
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 5, 2024
…iser

Add new Tier-3 target: `loongarch64-unknown-linux-musl`

MCP: rust-lang/compiler-team#518
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 8, 2024
…iser

Add new Tier-3 target: `loongarch64-unknown-linux-musl`

MCP: rust-lang/compiler-team#518
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 8, 2024
Rollup merge of rust-lang#121832 - heiher:loongarch64-musl, r=wesleywiser

Add new Tier-3 target: `loongarch64-unknown-linux-musl`

MCP: rust-lang/compiler-team#518
heiher added a commit to heiher/rust that referenced this issue Aug 29, 2024
heiher added a commit to heiher/rust that referenced this issue Sep 23, 2024
heiher added a commit to heiher/rust that referenced this issue Sep 23, 2024
heiher added a commit to heiher/rust that referenced this issue Sep 23, 2024
heiher added a commit to heiher/rust that referenced this issue Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change A proposal to make a major change to rustc major-change-accepted A major change proposal that was accepted T-compiler Add this label so rfcbot knows to poll the compiler team
Projects
None yet
Development

No branches or pull requests

5 participants