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

[stable] Prepare TargetC for ARM bit-fields special case #16742

Merged
merged 2 commits into from
Jul 31, 2024

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Jul 21, 2024

Required for 32-bit ARM, and non-Apple 64-bit ARM targets.

The only difference to Gcc_Clang is that anonymous and 0-length bit-fields do contribute to the aggregate alignment.

Caught by existing proper C interop tests in runnable_cxx/testbitfields.d on such targets. The hardcoded bad tests in runnable/{bitfieldsposix64.c,dbitfieldsposix64.d} however now fail after the fix, on such targets again.

See ldc-developers/ldc#4707 (comment) and following.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#16742"

@kinke kinke marked this pull request as ready for review July 21, 2024 16:09
@kinke kinke requested a review from ibuclaw as a code owner July 21, 2024 16:09
@ibuclaw
Copy link
Member

ibuclaw commented Jul 21, 2024

My preference would be to add a target hook for this. Looks like the behaviour you want is controlled by this macro in GCC (which doesn't explicitly match for a specific target/compiler combo)

https://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html#index-EMPTY_005fFIELD_005fBOUNDARY

or...

https://gcc.gnu.org/onlinedocs/gccint/Storage-Layout.html#index-TARGET_005fALIGN_005fANON_005fBITFIELD

@kinke
Copy link
Contributor Author

kinke commented Jul 22, 2024

I hope this is the last bit-field special case in a while. If so, we'd only have these 3 BitFieldStyles, no other config options or Target hooks to account for bit-field implementation details. If there'd be more to come, then yeah, the enum won't cut it anymore.

@ibuclaw
Copy link
Member

ibuclaw commented Jul 22, 2024

I hope this is the last bit-field special case in a while. If so, we'd only have these 3 BitFieldStyles, no other config options or Target hooks to account for bit-field implementation details. If there'd be more to come, then yeah, the enum won't cut it anymore.

The docs suggest there are more permutations than just this gcc/clang/arm special case.

kinke and others added 2 commits July 22, 2024 17:21
Required for 32-bit ARM, and non-Apple 64-bit ARM targets.

The only difference to `Gcc_Clang` is that anonymous and 0-length
bit-fields do contribute to the aggregate alignment.

Caught by existing proper C interop tests in
runnable_cxx/testbitfields.d on such targets. The hardcoded bad tests
in runnable/{bitfieldsposix64.c,dbitfieldsposix64.d} however now fail
after the fix, on such targets again.
@kinke
Copy link
Contributor Author

kinke commented Jul 22, 2024

I hope we won't need much more in the near future. I guess the generic gcc options there also account for the 'Microsoft style' behavior; proper support for all gcc-supported targets would likely entail a rewrite of this frontend code, adding more complexity.

I've refactored it to a TargetC.contributesToAggregateAlignment(BitFieldDeclararation) hook for now.

@kinke kinke changed the title [stable] Add BitFieldStyle.Gcc_Clang_ARM [stable] Prepare TargetC for ARM bit-fields special case Jul 22, 2024
@ibuclaw
Copy link
Member

ibuclaw commented Jul 23, 2024

I hope we won't need much more in the near future. I guess the generic gcc options there also account for the 'Microsoft style' behavior;

Yes, I think it's PCC vs non-PCC bit field layouts.

proper support for all gcc-supported targets would likely entail a rewrite of this frontend code, adding more complexity.

We're probably not far off how GCC code is, much like the clean room implementation of unwind exceptions follows the same logic flow.

@kinke
Copy link
Contributor Author

kinke commented Jul 26, 2024

Alright, you sound optimistic, good. :) - Anything else to do here?

@thewilsonator thewilsonator merged commit 5ca4593 into dlang:stable Jul 31, 2024
73 checks passed
@kinke kinke deleted the bitfields_arm branch July 31, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants