Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 2d26681

Browse files
committedOct 25, 2024
ABI compatibility: remove section on target features
1 parent 2da7b7f commit 2d26681

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed
 

‎core/src/primitive_docs.rs

+6-26
Original file line numberDiff line numberDiff line change
@@ -1743,20 +1743,18 @@ mod prim_ref {}
17431743
/// alignment, they might be passed in different registers and hence not be ABI-compatible.
17441744
///
17451745
/// ABI compatibility as a concern only arises in code that alters the type of function pointers,
1746-
/// code that imports functions via `extern` blocks, and in code that combines `#[target_feature]`
1747-
/// with `extern fn`. Altering the type of function pointers is wildly unsafe (as in, a lot more
1748-
/// unsafe than even [`transmute_copy`][mem::transmute_copy]), and should only occur in the most
1749-
/// exceptional circumstances. Most Rust code just imports functions via `use`. `#[target_feature]`
1750-
/// is also used rarely. So, most likely you do not have to worry about ABI compatibility.
1746+
/// and code that imports functions via `extern` blocks. Altering the type of function pointers is
1747+
/// wildly unsafe (as in, a lot more unsafe than even [`transmute_copy`][mem::transmute_copy]), and
1748+
/// should only occur in the most exceptional circumstances. Most Rust code just imports functions
1749+
/// via `use`. So, most likely you do not have to worry about ABI compatibility.
17511750
///
17521751
/// But assuming such circumstances, what are the rules? For this section, we are only considering
17531752
/// the ABI of direct Rust-to-Rust calls, not linking in general -- once functions are imported via
17541753
/// `extern` blocks, there are more things to consider that we do not go into here.
17551754
///
17561755
/// For two signatures to be considered *ABI-compatible*, they must use a compatible ABI string,
1757-
/// must take the same number of arguments, the individual argument types and the return types must
1758-
/// be ABI-compatible, and the target feature requirements must be met (see the subsection below for
1759-
/// the last point). The ABI string is declared via `extern "ABI" fn(...) -> ...`; note that
1756+
/// must take the same number of arguments, and the individual argument types and the return types
1757+
/// must be ABI-compatible. The ABI string is declared via `extern "ABI" fn(...) -> ...`; note that
17601758
/// `fn name(...) -> ...` implicitly uses the `"Rust"` ABI string and `extern fn name(...) -> ...`
17611759
/// implicitly uses the `"C"` ABI string.
17621760
///
@@ -1826,24 +1824,6 @@ mod prim_ref {}
18261824
/// Behavior since transmuting `None::<NonZero<i32>>` to `NonZero<i32>` violates the non-zero
18271825
/// requirement.
18281826
///
1829-
/// #### Requirements concerning target features
1830-
///
1831-
/// Under some conditions, the signature used by the caller and the callee can be ABI-incompatible
1832-
/// even if the exact same ABI string and types are being used. As an example, the
1833-
/// `std::arch::x86_64::__m256` type has a different `extern "C"` ABI when the `avx` feature is
1834-
/// enabled vs when it is not enabled.
1835-
///
1836-
/// Therefore, to ensure ABI compatibility when code using different target features is combined
1837-
/// (such as via `#[target_feature]`), we further require that one of the following conditions is
1838-
/// met:
1839-
///
1840-
/// - The function uses the `"Rust"` ABI string (which is the default without `extern`).
1841-
/// - Caller and callee are using the exact same set of target features. For the callee we consider
1842-
/// the features enabled (via `#[target_feature]` and `-C target-feature`/`-C target-cpu`) at the
1843-
/// declaration site; for the caller we consider the features enabled at the call site.
1844-
/// - Neither any argument nor the return value involves a SIMD type (`#[repr(simd)]`) that is not
1845-
/// behind a pointer indirection (i.e., `*mut __m256` is fine, but `(i32, __m256)` is not).
1846-
///
18471827
/// ### Trait implementations
18481828
///
18491829
/// In this documentation the shorthand `fn(T₁, T₂, …, Tₙ)` is used to represent non-variadic

0 commit comments

Comments
 (0)
Failed to load comments.