-
Notifications
You must be signed in to change notification settings - Fork 279
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
Improper usage of #[inline(always)] and #[target_feature] results in LLVM instruction selection error #404
Comments
Thanks! I'll poke around at this soon |
The RFC2045 #[target_feature(enable = "avx")] unsafe fn foo();
#[target_feature(enable = "avx")] #[inline] unsafe fn baz(); // OK
#[target_feature(enable = "avx")] #[inline(always)] unsafe fn bar(); // OK
#[target_feature(enable = "sse3")]
unsafe fn moo() {
// This function supports SSE3 but not AVX
if cfg_feature_enabled!("avx") {
foo(); // OK: foo is not inlined into moo
baz(); // OK: baz is not inlined into moo
bar();
// ^ ERROR: bar cannot be inlined across mismatching features
// did you meant to make bar #[inline] instead of #[inline(always)]?
// Note: the logic to detect this is the same as for the call
// to baz, but in this case rustc must emit an error because an
// #[inline(always)] function cannot be inlined in this call site.
}
} We should probably suggest doing both things:
|
I've applied a hammer for this rust-lang/rust#49425 which is different than RFC 2045 (but easier to implement) |
@alexcrichton I've skimmed through the RFC comments, and it looks like the RFC wasn't properly updated. In the comments you argued for the fix that you proposed in this PR, and it was agreed upon that it is the right step to take. Allowing |
Once a target feature is enabled for a function that means that it in general can't be inlined into other functions which don't have that target feature enabled. This can cause both safety and LLVM issues if we were to actually inline it, so `#[inline(always)]` both can't be respected and would be an error if we did so! Today LLVM doesn't inline functions with different `#[target_feature]` annotations, but it turns out that if one is tagged with `#[inline(always)]` it'll override this and cause scary LLVM error to arise! This commit fixes this issue by forbidding these two attributes to be used in conjunction with one another. cc rust-lang/stdarch#404
|
@Amanieu which |
I'm also getting a bunch of errors when trying to compile
|
The answer is probably to migrate to @AdamNiederer 's coresimd fork here: https://github.com/AdamNiederer/stdsimd/tree/fix-bft-build for the time being till we do a new 0.0.5 release, or to migrate to |
1.26.0-nightly (2018-03-25 482a913fb337855072a53c0d602cd19947f45285)
The text was updated successfully, but these errors were encountered: