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

7903314: Jextract doesn't honor pack pragmas #113

Closed
wants to merge 1 commit into from

Conversation

mcimadamore
Copy link
Contributor

@mcimadamore mcimadamore commented Mar 13, 2023

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.


Progress

  • Change must not contain extraneous whitespace
  • Change must be properly reviewed (no review required)

Issue

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jextract pull/113/head:pull/113
$ git checkout pull/113

Update a local copy of the PR:
$ git checkout pull/113
$ git pull https://git.openjdk.org/jextract pull/113/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 113

View PR using the GUI difftool:
$ git pr show -t 113

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jextract/pull/113.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 13, 2023

👋 Welcome back mcimadamore! A progress list of the required criteria for merging this PR into panama will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Mar 13, 2023

@mcimadamore This change now passes all automated pre-integration checks.

After integration, the commit message for the final commit will be:

7903314: Jextract doesn't honor pack pragmas

Reviewed-by: jvernee

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been no new commits pushed to the panama branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the panama branch, type /integrate in a new comment.

@openjdk openjdk bot added ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 13, 2023
@mlbridge
Copy link

mlbridge bot commented Mar 13, 2023

Webrevs

@mcimadamore
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Mar 13, 2023

Going to push as commit 750c415.

@openjdk openjdk bot added the integrated Pull request has been integrated label Mar 13, 2023
@openjdk openjdk bot closed this Mar 13, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 13, 2023
@openjdk
Copy link

openjdk bot commented Mar 13, 2023

@mcimadamore Pushed as commit 750c415.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
2 participants