|
8 | 8 | #![warn(unreachable_pub)]
|
9 | 9 | // tidy-alphabetical-end
|
10 | 10 |
|
| 11 | +/*! ABI handling for rustc |
| 12 | +
|
| 13 | +## What is an "ABI"? |
| 14 | +
|
| 15 | +Literally, "application binary interface", which means it is everything about how code interacts, |
| 16 | +at the machine level, with other code. This means it technically covers all of the following: |
| 17 | +- object binary format for e.g. relocations or offset tables |
| 18 | +- in-memory layout of types |
| 19 | +- procedure calling conventions |
| 20 | +
|
| 21 | +When we discuss "ABI" in the context of rustc, we are probably discussing calling conventions. |
| 22 | +To describe those `rustc_abi` also covers type layout, as it must for values passed on the stack. |
| 23 | +Despite `rustc_abi` being about calling conventions, it is good to remember these usages exist. |
| 24 | +You will encounter all of them and more if you study target-specific codegen enough! |
| 25 | +Even in general conversation, when someone says "the Rust ABI is unstable", it may allude to |
| 26 | +either or both of |
| 27 | +- `repr(Rust)` types have a mostly-unspecified layout |
| 28 | +- `extern "Rust" fn(A) -> R` has an unspecified calling convention |
| 29 | +
|
| 30 | +## Crate Goal |
| 31 | +
|
| 32 | +ABI is a foundational concept, so the `rustc_abi` crate serves as an equally foundational crate. |
| 33 | +It cannot carry all details relevant to an ABI: those permeate code generation and linkage. |
| 34 | +Instead, `rustc_abi` is intended to provide the interface for reasoning about the binary interface. |
| 35 | +It should contain traits and types that other crates then use in their implementation. |
| 36 | +For example, a platform's `extern "C" fn` calling convention will be implemented in `rustc_target` |
| 37 | +but `rustc_abi` contains the types for calculating layout and describing register-passing. |
| 38 | +This makes it easier to describe things in the same way across targets, codegen backends, and |
| 39 | +even other Rust compilers, such as rust-analyzer! |
| 40 | +
|
| 41 | +*/ |
| 42 | + |
11 | 43 | use std::fmt;
|
12 | 44 | #[cfg(feature = "nightly")]
|
13 | 45 | use std::iter::Step;
|
|
0 commit comments