-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
segfault with target-feature=+soft-float #63466
Comments
Compiler team pre-triage: Seems problematic! @roblabla do you know if this used to work in older versions? Or has it always been buggy? |
When using |
The use of soft-float disables use of xmm registers, but parts of std are compiled without soft-float and expect parameters to be passed in xmm registers. This can be seen by looking at the assembly build without soft-float, searching for Note that adding target features to individual functions with the However, we don't have a similar safeguard when mixing crates compiled with different "global" target-features. I don't know if reasonably can (and want) do that. Maybe we could put the target-features into metadata and error if they don't match during crate loading, but that's going to break some popular workflows that work fine today. In particular, |
I think that we want a solution that either errors when incompatible features are used, or works (e.g. generates shims). How we store the target-feature information is an implementation-detail (and the crate metadata sounds like a reasonable place to put this information for the features a crate was compiled with), but since functions can also have target features that deviate from the crate, we probably need to perform a validation at each call-site, comparing the target features of the caller with that of the callee. The interaction is also ABI dependent, e.g., target-features that are incompatible with the C ABI (e.g. avx2 vs sse) might be compatible with the Rust ABI (e.g. because types are passed by memory and not in registers). So I think that more precisely, the target features are part of the call ABI of a function (cc @eddyb ), and when calling a function we should check whether the function can be called as is, or whether shims are required and we can generate them, or error instead. The problem here is exacerbated because we pass the
|
My point is that you'll always be linking in at least libcore, which was compiled with a different and most likely incompatible list of features (unless you're using Xargo or an equivalent Cargo capability which doesn't exist yet). |
If it were true that #[repr(simd)] f64x4(f64, f64, f64, f64);
#[target_feature(enable = "avx")] fn foo(x: f64x4) { ... }
#[target_feature(enable = "sse")] fn bar(x: f64x4} { foo(x) } We currently incorrectly assume that Compiling whole crates with different features is only one of the many ways to generate functions that have different sets of target features. It is not the only one, and it is not the bug itself. In some cases, calling one function from another might be truly incompatible in an unfixable way. We should just error when that happens, and the error should say what went wrong. On top of the fix, we could also maybe have a warning that warns when rustc needs to shim these functions to make the call ABI work. |
Please take a step back to consider context. In the month old comment you quoted, I was talking about the possibility of erroring when crates are linked together which are compiled with different "global" target_features. That would also have prevented the issue @roblabla experienced, and it's vastly simpler to implement than everything you propose here (none of which is original, IIRC, the two of us and several others have discussed it extensively in the past). I am very well aware of what we could do to make calls between functions with different sets of target_features work fine. It is indeed conceivable for us to paper over all the ABI mismatches currently caused both by |
if this issue is closed, then maybe you should stop referring to it on this page? |
The following program currently segfaults on x86_64-unknown-linux-gnu when compiling with stable rust 1.36.0 with soft-float, and running with TARGET unset.
Here's the output:
A backtrace:
Binary attached.
hello_world.zip
The text was updated successfully, but these errors were encountered: