-
Notifications
You must be signed in to change notification settings - Fork 13.8k
error out when repr(align)
exceeds COFF limit
#142638
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
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @WaffleLapkin. Use |
Some changes occurred in diagnostic error codes Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It only needs to error if we generate a |
Could you include testing alignment on functions here in this PR (if relevant, but I suspect it is). I think you can just add it to the test files you already modify. #![feature(fn_align)]
// ...
// and then you can annotate a function with `#[repr(align(N))]`
#[repr(align(16))]
fn foo() {} |
@nthery This simple version that rejects |
...wait, we can't crater for Windows. |
fbbth. |
☔ The latest upstream changes (presumably #138165) made this pull request unmergeable. Please resolve the merge conflicts. |
It is relevant indeed. I reproduced the original bug with a function alignment exceeding 0x2000 bytes. Thanks for spotting this. I will add some test points. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
The PE-COFF binary format limits section alignment to 8192 bytes. Emit error when alignment exceeds this limit to avoid crash in llvm.
I reckon I've addressed all points in the latest force-push. |
☔ The latest upstream changes (presumably #142906) made this pull request unmergeable. Please resolve the merge conflicts. |
As noted by @wesleywiser on Aug 28:
So, in the spirit of executing that: Thanks for this PR, @nthery, and sorry about the holdup. We probably want to have a vibe check from T-lang on whether they have a strong feeling on whether this error should occur eagerly or lazily or what. @rustbot label: +I-lang-nominated +T-lang |
(My first instinct, not speaking for the team) Given that this same place is doing other If the limit was gratuitously low, like |
For function alignment on wasm we'll need to impose a maximum alignment of 1: the function address is kind of meaningless for wasm, so an alignment of 1 is all we can reasonably guarantee. The solution that is chosen here still seems like the correct one to me, but there are, or may be, platforms where the limits are substantially lower in some cases. |
Even if we reject the maximally permissive “only error if it’s codegened” option, that still leaves a choice between “error at the type declaration site” (most restrictive) and “error at the |
The PE-COFF binary format limits section alignment to 8192 bytes. Emit error when alignment exceeds this limit to avoid crash in llvm.
Closes #142386.