-
Notifications
You must be signed in to change notification settings - Fork 14k
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.
|
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 |
|
If this is specific to the Any thoughts from people who need extra alignment on things? Are they needed at high-ish numbers across platforms? |
|
Note that it's not just statics, it's also promoteds and consts that can give rise to global allocations that end up in the binary. So checking specifically only statics is insufficient. #[repr(align(16384))]
enum E5 { A, B }
let x = &E5::A; // this gets promoted to a global, so this must also error |
|
Seems like a reasonable restriction to add. FCPing for lang: @rfcbot merge |
|
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! cc @rust-lang/lang-advisors: FCP proposed for lang, please feel free to register concerns. |
|
@rfcbot reviewed |
|
In the lang call today, we talked about this again. In discussion, @scottmcm raised again his question:
It'd be good to answer this in the Reference PR, as it may be observable. I'm going to wait to see the Reference PR before checking a box here. |
|
I'm hopeful that 8k is high enough that checking the declaration is good; worst come to worst I think we could change if people show up really needing something else. (I don't think people do @rfcbot reviewed |
|
🔔 This is now entering its final comment period, as per the review above. 🔔 |
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.