Integrated: 7903314: Jextract doesn't honor pack pragmas

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Mar 13 19:20:30 UTC 2023


On Mon, 13 Mar 2023 18:08:45 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> This patch fixes a long standing issue where jextract ignores alignment directives (e.g. `pragma pack`). Because of this issue, jextract can sometiems generate layouts whose alignment is incorrect (e.g. jextract might attempt to add a `i32` to a struct at an offset that is not 32-bit aligned).
> 
> The fix is in `RecordLayoutComputer` - when we need to emit the layout of a given struct field, we need to additionally pass in the offset at which the field is added. Then we check that the offset conforms to the field alignment. If not, we force-align the layout to the available alignment. This should only affect instances of `ValueLayout`.
> 
> During code generation, when we lookup a value layout, we first drop both name and custom alignment (so that the lookup will find what it's looking for). Additional name and/or alignment is added back when the layout is turned back into a string.

This pull request has now been integrated.

Changeset: 750c4153
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/jextract/commit/750c4153994ae1c37681f53f0ec81915bd0b40e6
Stats:     167 lines in 10 files changed: 143 ins; 11 del; 13 mod

7903314: Jextract doesn't honor pack pragmas

Reviewed-by: jvernee

-------------

PR: https://git.openjdk.org/jextract/pull/113


More information about the jextract-dev mailing list