rust-lang / rust-lang/rust

Missing target feature ABI checks for nvptx

Open
#157,532 14 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

The Target::abi_required_features and Target::check_consistency ABI-checking logic currently has no handling for NVPTX.

For context: on other targets this logic ensures things like

  • valid values for llvm_abiname/llvm_floatabi
  • consistent values for cfg_abi relative to llvm_abiname
  • preventing target features from being enabled/disabled in a way that would alter the ABI

This is needed to prevent issues like https://github.com/rust-lang/rust/issues/116344.

To resolve this, we need to figure out if there are target features that would alter the ABI, and pin those down in abi_required_features to avoid ABI issues. This target is a bit special since one has to pick a consistent -Ctarget-cpu value across all compilation units that are linked with each other. There is work on the way to enforce this. However, even with that in place, we need to worry about people using -Ctarget-feature in a way that would produce incorrect code.

From prior discussion in https://github.com/rust-lang/rust/issues/131799 and https://github.com/rust-lang/rust/issues/141468, it seems like the general constraint is that

A binary will end up with one exact ptx and sm version.

That would seem to indicate that we have to mark all of these target features as "forbidden"? Then only -Ctarget-cpu would remain usable and will be locked down across the crate graph. However I don't actually know the target so this may make no sense.
Cc @kulst @ZuseZ4

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 examining Target::abi_required_features and Target::check_consistency for how other targets validate ABI names, cfg values, and target features. Use the NVPTX constraints and the discussions in issues 131799 and 141468 to determine which features can alter the PTX or SM ABI; done means encoding those constraints so unsafe -Ctarget-feature combinations are rejected.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.