RFR: 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer [v5]
Jorn Vernee
jvernee at openjdk.org
Thu Dec 18 12:56:46 UTC 2025
On Thu, 18 Dec 2025 11:36:52 GMT, Varada M <varadam at openjdk.org> wrote:
>> Total of 10 test failures observed on AIX:
>> jtreg/generator/nestedTypes/TestNestedTypesUnsupported.java
>> jtreg/generator/test8246400/LibTest8246400Test.java
>> jtreg/generator/test8258605/LibTest8258605Test.java
>> jtreg/generator/test8261511/Test8261511.java
>> jtreg/generator/testStruct/LibStructTest.java
>> testng/org/openjdk/jextract/test/toolprovider/ConstantsTest.java
>> testng/org/openjdk/jextract/test/toolprovider/IncompleteArrayTest.java
>> testng/org/openjdk/jextract/test/toolprovider/Test8240811.java
>> testng/org/openjdk/jextract/test/toolprovider/TestClassGeneration.java
>> testng/org/openjdk/jextract/test/toolprovider/nestedAnonOffset/TestNestedAnonOffset.java
>>
>> This PR fixes AIX specific layout generation issues related to incorrect alignment double and pointer types.
>> 1. Structs containing double fields fail with:
>> i. Unsupported layout: 4%D8
>> ii. Invalid alignment constraint for member layout
>> double in AIX structs has size 8 but alignment 4 (except as first field). AIX specific handling for C_DOUBLE computes the correct alignment.
>>
>> 2. Clang was detected as 32-bit due to missing -m64 during macro extraction, causing inconsistent macros. This caused jextract to interpret pointer constants incorrectly, leading to failures like:
>> expected [-1] but found [4294967295]
>>
>> 3. TestNestedAnonOffset.java test failed on AIX because it also expects more padding similar to platforms like windows and linux
>>
>>
>> After the patch jtreg tests passes successfully.
>>
>> JBS: [CODETOOLS-7904115](https://bugs.openjdk.org/browse/CODETOOLS-7904115)
>
> Varada M has updated the pull request incrementally with two additional commits since the last revision:
>
> - 7904115: Fix for AIX test case failures due to incorrect alignment for double and pointer
> - restoring the changes
src/main/java/org/openjdk/jextract/impl/ClassSourceBuilder.java line 262:
> 260: case LongLong -> alignIfNeeded(runtimeHelperName() + ".C_LONG_LONG", 8, align);
> 261: case Float -> alignIfNeeded(runtimeHelperName() + ".C_FLOAT", 4, align);
> 262: case Double -> alignIfNeeded(runtimeHelperName() + ".C_DOUBLE", TypeImpl.IS_AIX ? 4 : 8, align);
With natural alignment, `double` is aligned to `8` bytes, so this change shouldn't be needed?
src/main/java/org/openjdk/jextract/impl/StructBuilder.java line 488:
> 486: long fieldTypeAlign = ClangAlignOf.getOrThrow(var) / 8;
> 487: long expectedAlign = Math.min(scopedTypeAlign, fieldTypeAlign);
> 488: memberLayout = layoutString(var.type(), expectedAlign);
Changes in this file are not needed either.
test/jtreg/generator/testStruct/LibStructTest.java line 103:
> 101: checkField(g, "ull",C_LONG_LONG);
> 102: checkField(g, "f", C_FLOAT);
> 103: checkField(g, "d", C_DOUBLE);
Suggestion:
checkField(g, "d", C_DOUBLE);
-------------
PR Review Comment: https://git.openjdk.org/jextract/pull/296#discussion_r2630919957
PR Review Comment: https://git.openjdk.org/jextract/pull/296#discussion_r2630961466
PR Review Comment: https://git.openjdk.org/jextract/pull/296#discussion_r2630922070
More information about the jextract-dev
mailing list