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

[RFC]: zephyr: CMakeLists: disable packed-related warnings #8521

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions zephyr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,8 @@ if (NOT CONFIG_COMPILER_INLINE_FUNCTION_OPTION)
target_compile_options(SOF INTERFACE -fno-inline-functions)
endif()

target_compile_options(SOF INTERFACE -Wno-address-of-packed-member)
Copy link
Member

@lgirdwood lgirdwood Nov 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its better we keep this, what errors do you see, there may be other/better ways to resolve ? i.e. a snippet from the CC errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's mostly stuff like:

/zep_workspace/sof/src/include/sof/coherent.h: In function '__coherent_init_thread':
/zep_workspace/sof/src/include/sof/coherent.h:433:19: warning: taking address of packed member of 'struct coherent' may result in an unaligned pointer value [-Waddress-of-packed-member]
  433 |         list_init(&c->list);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. no, no idea why struct coherent has to be packed, I'd say it doesn't. It was that way from day one of the coherent API
  2. we currently have only one used of the coherent API: src/lib/ams.c - is ams used at all, are there plans to use it? Does it really need and benefit from the coherent API? @kfrydryx
  3. removing that warning seems like not the right fix for this. I found this explanation on [1] why this warning is useful:

When a program accesses a misaligned member of a packed struct, the compiler generates whatever code is necessary to read or write the correct value.

If the address of a misaligned member is stored in a pointer object, dereferencing that pointer doesn't give the compiler an opportunity to generate that extra code.

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51628


# SOF needs `typeof`, `__VA_ARGS__` and maybe other GNU C99
# extensions. TODO other flags required ?
target_compile_options(SOF INTERFACE $<$<COMPILE_LANGUAGE:C,ASM>: -std=gnu99>)
Expand Down