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

scripts: build: gen_handles: use Z_DECL_ALIGN #51162

Merged

Conversation

gmarull
Copy link
Member

@gmarull gmarull commented Oct 11, 2022

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]

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]>
Copy link
Collaborator

@JordanYates JordanYates left a 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");
Copy link
Member

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?

Copy link
Member

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)

Copy link
Member Author

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.

@carlescufi carlescufi merged commit 8821623 into zephyrproject-rtos:main Oct 11, 2022
@gmarull gmarull deleted the gen-handles-z-decl-align branch October 11, 2022 16:47
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.

6 participants