rust-lang / rust-lang/rust

Figure out the PowerPC64 ABI for the ibm-aix target (vec-default vs vec-extabi)

Open
#153,876 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs-triage O-aix
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Disclaimer: I know little about PowerPC and even less about AIX. So maybe I'm wrong about all this. Someone please confirm whether any of this makes sense. :)

AIX on Power64 has two possible ABIs: vec-default and vec-extabi. In LLVM, the EnableAIXExtendedAltivecABI field controls which ABI is actually used. In Rust, we also have the abi field on each target which controls cfg(target_abi), but usually (and in particular in this case) doesn't itself have any effect on the ABI -- it merely informs the programmer which ABI the target spec claims to implement, but as target spec author one still has to manually arrange for that ABI to actually be used (in a usually architecture-specific manner, because ABIs are a mess so nothing is consistent).

The powerpc64-ibm-aix target got added in https://github.com/rust-lang/rust/pull/102293, with cfg(target_abi) indicating "vec-extabi", but without setting EnableAIXExtendedAltivecABI, leaving it at its default value of false. In other words, the target claims via cfg(target_abi) to use vec-extabi, but actually it used vec-default. That seems inconsistent and we should fix it.

In https://github.com/rust-lang/rust/pull/153784, the proposal was to fix this by actually setting EnableAIXExtendedAltivecABI in LLVM. However, @daltenty raised the concern that this might not actually be what the target maintainers want. So in https://github.com/rust-lang/rust/pull/153830 I proposed to instead fix the problem by changing cfg(target_abi) to "vec-default", matching the (implied default) value of EnableAIXExtendedAltivecABI. But that clashes with logic in our inline assembly handling which rejects using the registers v20-v31 (vs52-vs63) when cfg(target_abi) is "vec-default" (https://github.com/rust-lang/rust/pull/131341, #146949).

I don't know what the correct fix here is, so I figured I'd just open an issue, dump everything I know, ping all the right people, and let you all figure it out. :) In particular, it is confusing to me that the inline assembly logic looks at the ABI -- whether the registers are available and whether they get used by the ABI are usually orthogonal questions, and it would seem to me that inline asm should care about the former, not the latter. But I also don't know how availability of these registers is modeled on AIX/PowerPC; on other architectures, this is typically done via target features.

Cc @Gelbpunkt @daltenty @gilamn5tr @amy-kwan @ecnelises @pmur @taiki-e @Amanieu @workingjubilee

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the target ABI discussion in PRs #102293, #153784, and #153830, including the linked maintainer comment. Then trace how EnableAIXExtendedAltivecABI, cfg(target_abi), and the inline-assembly v20-v31 register checks are connected. Done means documenting the intended AIX ABI and agreeing on a consistent fix with the target maintainers.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers, operating-systems
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.