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 mips64r6 and mips32r6 options to target_arch #632

Closed
1 of 3 tasks
chenx97 opened this issue May 10, 2023 · 3 comments
Closed
1 of 3 tasks

Add mips64r6 and mips32r6 options to target_arch #632

chenx97 opened this issue May 10, 2023 · 3 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

@chenx97
Copy link

chenx97 commented May 10, 2023

Proposal

Tier-3 targets like mipsisa64r6-unknown-linux-gnuabi64 and mipsisa64r6el-unknown-linux-gnuabi64 exist because their binaries are not compatible with those of mips64-unknown-linux-gnuabi64 and mips64el-unknown-linux-gnuabi64. MIPS R6 repurposes many opcodes for new instructions and introduces new instructions occupying reserved opcodes. It even changed its multiplication and division behavior, as it now uses separated instructions for upper and lower parts of the result, stores results in GPRs instead of a special register pair, and lets the microarchitecture optimize divide-and-remainder instruction sequences and low-high multiplication instruction sequences. In short, it doesn't just make sense to treat them as different targets, but as different architectures.

The proposal is written because these targets' target_arch is "mips64", and the target_arch of 32-bit MIPS R6 targets is "mips". I'd like to change them to "mips64r6" and "mips32r6" respectively. Although "mips64" and "mips" work most of the time as both MIPS revisions share the same ABI, ioctl constants, etc., it makes rust programs difficult, if not impossible, to figure out whether they are being compiled for traditional MIPS or MIPS R6. In build.rs, you can check the TARGET or the HOST triples to see if you are targeting MIPS R6. But what if I want to conditionally enable features and dependencies in Cargo.toml?

I also explored the possibility of adding target_features instead because that follows what the backends do. We ultimately decided against it because enabling such "features" inside a mips64 program would be possible and is pure nonsense. It also challenges what a "feature" should mean semantically. Existing architecture matching logic would continue to fail unless you match features after matching the architecture, and these "features" probably wouldn't stabilize when introduced, making them less useful anyway.

Mentors or Reviewers

@bjorn3 @nagisa @workingjubilee @wesleywiser

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.

@chenx97 chenx97 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 May 10, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 10, 2023

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 May 10, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label May 25, 2023
@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 Jun 16, 2023
@chenx97 chenx97 changed the title Add mips64r6 option to target_arch Add mips64r6 and mips32r6 option to target_arch Jun 17, 2023
@chenx97 chenx97 changed the title Add mips64r6 and mips32r6 option to target_arch Add mips64r6 and mips32r6 options to target_arch Jun 17, 2023
Cyanoxygen added a commit to Cyanoxygen/linux-raw-sys that referenced this issue Jun 28, 2023
@apiraino
Copy link
Contributor

apiraino commented Jul 6, 2023

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

@apiraino apiraino closed this as completed Jul 6, 2023
@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 Jul 6, 2023
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Jul 6, 2023
bors added a commit to rust-lang/libc that referenced this issue Jul 10, 2023
add mips32r6 and mips64r6 target_arch detection

This PR introduces `"mips32r6"` and `"mips64r6"` as valid `target_arch` values, and would be the arch values used by Tier-3 targets `mipsisa32r6-unknown-linux-gnu`, `mipsisa32r6el-unknown-linux-gnu`, `mipsisa64r6-unknown-linux-gnuabi64` and `mipsisa64r6el-unknown-linux-gnuabi64`.

This PR is made for rust-lang/rust#112374.

This PR has a corresponding [MCP](rust-lang/compiler-team#632) waiting for review.

mips64r6 has the same ABIs, syscall conventions, and various magic numbers as mips64 does. So this PR just adds mips64r6 to all mips64 detection macros. Similarly, mips32r6 share their ABIs, syscall conventions and various magic with mips, so the PR just adds mips32r6 to where mips is to be detected.
Cyanoxygen added a commit to Cyanoxygen/linux-raw-sys that referenced this issue Jul 18, 2023
- This is a part of the MCP rust-lang/compiler-team#632, that MIPS
  release 6 being migrated as target_arch instead of target features of
  MIPS.
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 18, 2023
add mips64r6 and mips32r6 as target_arch values

This PR introduces `"mips32r6"` and `"mips64r6"` as valid `target_arch` values, and would be the arch value used by Tier-3 targets `mipsisa32r6-unknown-linux-gnu`, `mipsisa32r6el-unknown-linux-gnu`, `mipsisa64r6-unknown-linux-gnuabi64` and `mipsisa64r6el-unknown-linux-gnuabi64`.

This PR was inspired by `rustix` attempting to link traditional mips64el objects with mips64r6el objects when building for mips64r6, even though `rustix` recently removed outline assembly support. This is because currently this target's `target_arch` is `"mips64"` and rustix has its respective assembly implementation as well as a pre-compiled little-endian static library prepared for mips64el, a tier-2 target with the same `target_arch`. After some [discussions on zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20New.20Values.20To.20MIPS_ALLOWED_FEATURES.20compiler-team.23595), I decided to treat mips64r6 as an independent architecture from Rust's POV, since these two architectures are incompatible anyway.

This PR is now waiting for `libc` to release a new version with [support](rust-lang/libc#3268) for these `target_arch` values. It is not expected to introduce changes to any other target, especially Tier-1 and Tier-2 targets.

This PR has its corresponding [MCP](rust-lang/compiler-team#632) approved.
github-actions bot pushed a commit to rust-lang/miri that referenced this issue Jul 20, 2023
add mips64r6 and mips32r6 as target_arch values

This PR introduces `"mips32r6"` and `"mips64r6"` as valid `target_arch` values, and would be the arch value used by Tier-3 targets `mipsisa32r6-unknown-linux-gnu`, `mipsisa32r6el-unknown-linux-gnu`, `mipsisa64r6-unknown-linux-gnuabi64` and `mipsisa64r6el-unknown-linux-gnuabi64`.

This PR was inspired by `rustix` attempting to link traditional mips64el objects with mips64r6el objects when building for mips64r6, even though `rustix` recently removed outline assembly support. This is because currently this target's `target_arch` is `"mips64"` and rustix has its respective assembly implementation as well as a pre-compiled little-endian static library prepared for mips64el, a tier-2 target with the same `target_arch`. After some [discussions on zulip](https://rust-lang.zulipchat.com/#narrow/stream/233931-t-compiler.2Fmajor-changes/topic/Add.20New.20Values.20To.20MIPS_ALLOWED_FEATURES.20compiler-team.23595), I decided to treat mips64r6 as an independent architecture from Rust's POV, since these two architectures are incompatible anyway.

This PR is now waiting for `libc` to release a new version with [support](rust-lang/libc#3268) for these `target_arch` values. It is not expected to introduce changes to any other target, especially Tier-1 and Tier-2 targets.

This PR has its corresponding [MCP](rust-lang/compiler-team#632) approved.
sunfishcode pushed a commit to sunfishcode/linux-raw-sys that referenced this issue Jul 31, 2023
* gen: add 32/64 MIPS Release 6 as separate target arch

- This is a part of the MCP rust-lang/compiler-team#632, that MIPS
  release 6 being migrated as target_arch instead of target features of
  MIPS.

* Introduce generated bindings for mipsr6 targets
sunfishcode pushed a commit to sunfishcode/linux-raw-sys that referenced this issue Jul 31, 2023
* gen: add 32/64 MIPS Release 6 as separate target arch

- This is a part of the MCP rust-lang/compiler-team#632, that MIPS
  release 6 being migrated as target_arch instead of target features of
  MIPS.

* Introduce generated bindings for mipsr6 targets
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

4 participants