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

Explain what the fn is an "ABI" and what equivalencies we guarantee #1623

Open
12 tasks
workingjubilee opened this issue Sep 20, 2024 · 3 comments
Open
12 tasks

Comments

@workingjubilee
Copy link
Member

Documentation for this is sort of awkwardly scattered around std docs, the Reference, the Rustonomicon, and the UCG (some of which is more aspirational than actual, for note!), we should sit down and actually document it all somewhere. Probably a new or massively-expanded section of the Reference.

Some notes on major things to make sure we've gotten down into roughly the same place:

  • Explain the difference between repr(Rust) and extern "Rust" or repr(C) and extern "C"
  • Explain how Rust ABI strings relate to commonly-described ABI (e.g. "C" vs. "C-unwind")
  • Explain that memory layout is important to, but not sufficient for, matching function-call ABI
  • Explain that extern "C" has a target-specific meaning based on a psABI and how it is interpreted by the compilers, not specified by "Standard C"
  • Document the special-case guarantees for some types:
    • Option<T>
    • Result<T, Zst>
    • Result<Zst, T>
    • bool
  • Explain the ABI-mismatch UB cases
    • Document any major "unguarantees" (reservations?)
  • Do we have to mention #[target_feature]?
  • Explain that there are not-immediately-arg/ret-related esoterica about ABI
    • mention stack alignment
    • mention MXCSR or FPCSR state
    • mention unwinding / destructors
@workingjubilee
Copy link
Member Author

@chorman0773 you'll fill in the list of things I missed, I trust

@chorman0773
Copy link
Contributor

#1545 contains the ABI equivalence rules.

@workingjubilee
Copy link
Member Author

Cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants