RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v2]
Jorn Vernee
jvernee at openjdk.org
Fri Nov 21 13:10:23 UTC 2025
On Fri, 21 Nov 2025 13:01:07 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> yes right.
>> These are my findings!
>>
>> `case Double -> alignIfNeeded(runtimeHelperName() + ".C_DOUBLE", (TypeImpl.IS_AIX ? 4 : 8), align);`
>> The above fix solves most of the failures except two of them. This solves the failure like "Unsupported layout: 4%D8"
>>
>> The remaining two test failures are due to 'IllegalArgumentException: Invalid alignment constraint for member layout: D8(d)'
>> I observed that the expected alignment is 8 for them and the ABI expects the alignment constraint for d to be 4, not 8
>> For one of the test failure : jtreg/generator/testStruct/LibStructTest.java
>> For the [struct AllTypes](https://github.com/varada1110/jextract/blob/91ff2392ac8c3ee7d0906486e8f523fccdf34c44/test/jtreg/generator/testStruct/struct.h#L41), the double d field is not the first field, so according to AIX power mode rules, subsequent doubles are aligned on 4-byte boundaries, not 8
>
> Yes, that's expected, but I think the test should be modified to handle that instead. The issue with the code in this patch is that it adjusts the alignment down to `4` in some cases when the requested alignment is `8`. The requested alignment (i.e. the `align` argument) is always correct here, since that is what we get straight from clang based on alignment specifiers or pack pragmas.
>
> For instance, for a struct like this:
>
>
> struct foo {
> alignas(8) double d;
> };
>
>
> `align` would be `8` here for the field `d`, but you overwrite it to `4`, which doesn't seem right.
Okay, I had another look at the test, and it looks like it can not really be adjusted, so there might be an issue elsewhere.
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/296#discussion_r2549708230
More information about the jextract-dev
mailing list