ty: Use underlying layout of typedefs if available. - #3453
Merged
Conversation
Contributor
Author
|
cc @ojeda |
This fixes struct layout issues with over-aligned typedefs, which rust can't represent, see #3449 for context and some other discussion. This is kinda ugly tho, but as far as I can tell there's no good way of getting the right ABI and struct layout at the same time...
emilio
force-pushed
the
over-aligned-typedef
branch
from
September 6, 2026 19:38
5e6308c to
447f5f4
Compare
Contributor
|
A few more cases for your tests/future considerations: struct Inner { long long a, b; };
typedef struct Inner AlignedInner __attribute__((aligned(16)));
struct Outer {
long long before;
AlignedInner inner[1];
};(and the same with struct Inner { long long a, b; };
typedef struct Inner AlignedInner __attribute__((aligned(16)));
struct Outer {
long long before;
AlignedInner inner[0];
char tail;
};enum __attribute__((aligned(16))) AlignedEnum { Value = 1 };
struct Outer {
long long before;
enum AlignedEnum inner;
};typedef unsigned int U __attribute__((aligned(2)));
struct Outer {
char before;
U bits : 31;
char mid;
U inner;
char tail;
};All these changed w.r.t. 0.72.1. I hope that helps & thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes struct layout issues with over-aligned typedefs, which rust can't represent, see #3449 for context and some other discussion.
This is kinda ugly tho, but as far as I can tell there's no good way of getting the right ABI and struct layout at the same time...