Skip to content
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

Fix System V ABI for packed structs with misaligned fields #14324

Merged

Conversation

HertzDevil
Copy link
Contributor

@HertzDevil HertzDevil commented Feb 26, 2024

Fixes #9873. Section 3.2.3 of the System V ABI reference says: (emphasis own)

The classification of aggregate (structures and arrays) and union types works as follows:

  1. If the size of an object is larger than eight eightbytes, or it contains unaligned fields, it has class MEMORY.

The same behavior is verified with C on Clang. Actually calling Procs that take or return those misaligned structs will most likely require #14323 as well, as byval and sret are now mandatory.

On an unrelated note: while the reference says "eight eightbytes", an earlier revision said "four" instead, which is what Crystal currently uses for classification. This probably won't matter unless Crystal supports 512-bit vectors natively.

@straight-shoota straight-shoota added this to the 1.12.0 milestone Feb 26, 2024
@straight-shoota straight-shoota merged commit 81fa3a9 into crystal-lang:master Feb 27, 2024
57 checks passed
@HertzDevil HertzDevil deleted the bug/x86-64-misaligned-struct branch February 29, 2024 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Internal compiler error when lib fun takes or returns packed struct by value
2 participants