Skip to content

Commit d19aa69

Browse files
authored
Rollup merge of rust-lang#132136 - RalfJung:target-feature-abi-compat, r=Mark-Simulacrum
ABI compatibility: remove section on target features Once rust-lang#127731 lands, we will properly diagnose ABI issues caused by target feature mismatch (at least on tier 1 targets). So I'd say we can remove the corresponding part of the docs here -- this is now something the compiler can take care of, so programmers don't need to be concerned. For now this is just a lint, but that's just a transition period, like in prior cases where we fix I-unsound bugs by adding a new check that goes through the "future incompatibility" stages. We have decided that it's actually a bug that we have ABI risks around target features, and we shouldn't document that bug as-if it was intended behavior. Cc `@rust-lang/opsem` `@chorman0773` `@veluca93`
2 parents 978a553 + 2d26681 commit d19aa69

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

core/src/primitive_docs.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,11 +1746,10 @@ mod prim_ref {}
17461746
/// alignment, they might be passed in different registers and hence not be ABI-compatible.
17471747
///
17481748
/// ABI compatibility as a concern only arises in code that alters the type of function pointers,
1749-
/// code that imports functions via `extern` blocks, and in code that combines `#[target_feature]`
1750-
/// with `extern fn`. Altering the type of function pointers is wildly unsafe (as in, a lot more
1751-
/// unsafe than even [`transmute_copy`][mem::transmute_copy]), and should only occur in the most
1752-
/// exceptional circumstances. Most Rust code just imports functions via `use`. `#[target_feature]`
1753-
/// is also used rarely. So, most likely you do not have to worry about ABI compatibility.
1749+
/// and code that imports functions via `extern` blocks. Altering the type of function pointers is
1750+
/// wildly unsafe (as in, a lot more unsafe than even [`transmute_copy`][mem::transmute_copy]), and
1751+
/// should only occur in the most exceptional circumstances. Most Rust code just imports functions
1752+
/// via `use`. So, most likely you do not have to worry about ABI compatibility.
17541753
///
17551754
/// But assuming such circumstances, what are the rules? For this section, we are only considering
17561755
/// the ABI of direct Rust-to-Rust calls (with both definition and callsite visible to the
@@ -1762,9 +1761,8 @@ mod prim_ref {}
17621761
/// types from `core::ffi` or `libc`**.
17631762
///
17641763
/// For two signatures to be considered *ABI-compatible*, they must use a compatible ABI string,
1765-
/// must take the same number of arguments, the individual argument types and the return types must
1766-
/// be ABI-compatible, and the target feature requirements must be met (see the subsection below for
1767-
/// the last point). The ABI string is declared via `extern "ABI" fn(...) -> ...`; note that
1764+
/// must take the same number of arguments, and the individual argument types and the return types
1765+
/// must be ABI-compatible. The ABI string is declared via `extern "ABI" fn(...) -> ...`; note that
17681766
/// `fn name(...) -> ...` implicitly uses the `"Rust"` ABI string and `extern fn name(...) -> ...`
17691767
/// implicitly uses the `"C"` ABI string.
17701768
///
@@ -1834,24 +1832,6 @@ mod prim_ref {}
18341832
/// Behavior since transmuting `None::<NonZero<i32>>` to `NonZero<i32>` violates the non-zero
18351833
/// requirement.
18361834
///
1837-
/// #### Requirements concerning target features
1838-
///
1839-
/// Under some conditions, the signature used by the caller and the callee can be ABI-incompatible
1840-
/// even if the exact same ABI string and types are being used. As an example, the
1841-
/// `std::arch::x86_64::__m256` type has a different `extern "C"` ABI when the `avx` feature is
1842-
/// enabled vs when it is not enabled.
1843-
///
1844-
/// Therefore, to ensure ABI compatibility when code using different target features is combined
1845-
/// (such as via `#[target_feature]`), we further require that one of the following conditions is
1846-
/// met:
1847-
///
1848-
/// - The function uses the `"Rust"` ABI string (which is the default without `extern`).
1849-
/// - Caller and callee are using the exact same set of target features. For the callee we consider
1850-
/// the features enabled (via `#[target_feature]` and `-C target-feature`/`-C target-cpu`) at the
1851-
/// declaration site; for the caller we consider the features enabled at the call site.
1852-
/// - Neither any argument nor the return value involves a SIMD type (`#[repr(simd)]`) that is not
1853-
/// behind a pointer indirection (i.e., `*mut __m256` is fine, but `(i32, __m256)` is not).
1854-
///
18551835
/// ### Trait implementations
18561836
///
18571837
/// In this documentation the shorthand `fn(T₁, T₂, …, Tₙ)` is used to represent non-variadic

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy