pub static ABI_UNSUPPORTED_VECTOR_TYPES: &'static Lint
Expand description
The abi_unsupported_vector_types
lint detects function definitions and calls
whose ABI depends on enabling certain target features, but those features are not enabled.
§Example
ⓘ
extern "C" fn missing_target_feature(_: std::arch::x86_64::__m256) {
todo!()
}
#[target_feature(enable = "avx")]
unsafe extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
todo!()
}
fn main() {
let v = unsafe { std::mem::zeroed() };
unsafe { with_target_feature(v); }
}
warning: ABI error: this function call uses a avx vector type, which is not enabled in the caller
--> lint_example.rs:18:12
|
| unsafe { with_target_feature(v); }
| ^^^^^^^^^^^^^^^^^^^^^^ function called here
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
= help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
= note: `#[warn(abi_unsupported_vector_types)]` on by default
warning: ABI error: this function definition uses a avx vector type, which is not enabled
--> lint_example.rs:3:1
|
| pub extern "C" fn with_target_feature(_: std::arch::x86_64::__m256) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function defined here
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116558 <https://github.com/rust-lang/rust/issues/116558>
= help: consider enabling it globally (-C target-feature=+avx) or locally (#[target_feature(enable="avx")])
§Explanation
The C ABI for __m256
requires the value to be passed in an AVX register,
which is only possible when the avx
target feature is enabled.
Therefore, missing_target_feature
cannot be compiled without that target feature.
A similar (but complementary) message is triggered when with_target_feature
is called
by a function that does not enable the avx
target feature.
Note that this lint is very similar to the -Wpsabi
warning in gcc
/clang
.