-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
scripts: build: gen_handles: use Z_DECL_ALIGN #51162
scripts: build: gen_handles: use Z_DECL_ALIGN #51162
Conversation
Instead of hardcoding alignment size for pass 2 device handles, use Z_DECL_ALIGN. This makes sure gen_handles.py is always in sync with the type defined in device.h. The build assert in device.h can be removed as a result, since we do not hardcode handles size anywhere else. Signed-off-by: Gerard Marull-Paretas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion is a holdover from the time when the handles array was not allowed to change sizes after the first linker pass, and python scripts were assuming 2 byte handles.
* means the alignment directives in the linker scripts and in | ||
* `gen_handles.py` must be updated. | ||
*/ | ||
BUILD_ASSERT(sizeof(device_handle_t) == 2, "fix the linker scripts"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove this? This is about the size of uint16_t
and not the alignment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, saw this comment now #51162 (review)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because we relied on size being 2 (hardcoded), like in the gen_handles.py script.
Instead of hardcoding alignment size for pass 2 device handles, use Z_DECL_ALIGN. This makes sure gen_handles.py is always in sync with the type defined in device.h. The build assert in device.h can be removed as a result, since we do not hardcode handles size anywhere else.
Note: this assertion was introduced in #32127, as far as I can see, we do not hardcode the size in any linker script even though the message says, "fix the linker scripts".
Signed-off-by: Gerard Marull-Paretas [email protected]