-
Notifications
You must be signed in to change notification settings - Fork 37
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
Handle return type promotion in the high layer #69
Conversation
Are these changes backwards compatible, or should they be accompanied by a major version bump? |
223f054
to
2810a1f
Compare
These changes should be backwards compatible. There should be no change in the public API, and the only changes in generated code actually fix the underlying bug (missing type promotion). I noticed that tests were failing on Rust 1.48.0, because I was using the After re-running the tests I still see two failures that do not appear to be obviously related to my changes, not sure what's going on there. |
As described in tov#66, the libffi library implicitly extends small integer types used as return types, both in calls and closure callbacks. This is not currently addressed by the existing code base. For the low and middle layers, the user can manually address this issue by using appropriate return types. However, for the high layer, the types are automatically determined, and are currently incorrect. This leads to problems (primarily) on big-endian platforms. This PR addresses the return type extension in the high layer by storing the extended type used by libffi as an associated type `RetType` in the `CType` trait, and using that type when performing calls or constructing closure callbacks. This implementation does not change the libffi-rs API, and should not add any significant run-time overhead.
Ping? Any other questions or issues with this patch? |
Thank you! With those PRs merged, the test suite now fully passes on s390x. In order to refer to the updated libffi-rs from other rust packages, it would be good to have a new version on cargo. Do you have an outlook when you're planning to publish the next version? |
@uweigand All recent changes have just been pushed as new versions of libffi-sys and libffi 😃 |
Perfect! Thank you very much for your support :-) |
Unfortunately trying to pull the new release into upstream rust/miri failed:
This looks like it has been fixed upstream in libffi here: libffi/libffi#764 What would be the best way forward here? Just backport that fix? |
@uweigand A new release of libffi would have to be published. Maintaining a set of patches isn't something we're interested in. |
As described in #66, the libffi library implicitly extends small integer types used as return types, both in calls and closure callbacks. This is not currently addressed by the existing code base.
For the low and middle layers, the user can manually address this issue by using appropriate return types. However, for the high layer, the types are automatically determined, and are currently incorrect. This leads to problems (primarily) on big-endian platforms.
This PR addresses the return type extension in the high layer by storing the extended type used by libffi as an associated type
RetType
in theCType
trait, and using that type when performing calls or constructing closure callbacks.This implementation does not change the libffi-rs API, and should not add any significant run-time overhead.