-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
ZRESTRICT conflict between toolchain/common.h and toolchain/gcc.h #62464
Comments
This is introduced by commit fbf851c where
Normally, |
@dcpleung is the fix to move the |
Maybe? I haven't tried it. IMHO, hierarchy wise, |
Having two .h files that include each other directly does not make any sense to me; I think this commit should never have been merged.
Two .h files including each other means the code in these two .h files can intentionally end-up in one order in some .c files but in another order in other .c file. I imagine it's technically possible for both orders to compile depending on which macros are in use but does anyone seriously want that? Structuring .h files and debugging I don't fully understand what the #56006 problem was and I bet it wasn't an easy one but I'm pretty sure the one-line commit fbf851c was not the fix. I guess the proper fix is as usual to split/combine/shuffle the content of .h files into a proper DAG. cc: |
Oh I see what you mean now, sorry took me a bit to realize that the problem was the headers including each other
Yeah I agree the cross-include makes no sense and is asking for troubles, obviously no one caught that in code review. @yperess is that something you could look into? Moving the definition between headers and removing the cross include seems to be the right thing. |
I make no guarantee on timeline but I'll be happy to add it to my list |
Thanks! May I ask what order of magnitude is your current list? I mean days-long or months-long? According to @dcpleung this is what has just turned (in an unfortunate sequence of events) our CI red. |
Ok I'll take a stab at this myself since it's messing with CI. |
Commit 9c5dafe ("util: add type checking to CONTAINER_OF") made `util.h` #include `toolchain/common.h` in order to get `BUILD_ASSERT()` used by CONTAINER_OF_VALIDATE() when compiling C code. However `toolchain/common.h` is not supposed to be included directly but indirectly through `toolchain/<your_toolchain>.h` and in a very specific order. The direct inclusion caused the following warning when compiling C++: ``` toolchain/gcc.h:87: error: "ZRESTRICT" redefined [-Werror] 87 | #define ZRESTRICT __restrict | In file included from include/zephyr/sys/util.h:18: note: this is the location of the previous definition: include/zephyr/toolchain/common.h:33: 33 | #define ZRESTRICT ``` Fix this issue zephyrproject-rtos#62464 by including `zephyr/toolchain.h` instead, as done by 350 other files. Fixes commit 9c5dafe ("util: add type checking to CONTAINER_OF") Signed-off-by: Marc Herbert <marc.herbert@intel.com>
Thanks a lot @fabiobaltieri . I tested your #62580 and while it looks like it does fix the circular #include issue, I found it makes no difference for the ZRESTRICT redefinition bug I reported here. So I spent a bit more more time and I found a much simpler, one-line fix for the ZRESTRICT redefinition bug: Your fix and mine do not conflict with each other, I believe they're unrelated after all. Sorry for the confusion. |
Ok thanks for checking that @marc-hb, I guess let's go ahead with both, fixing the cross include can't be a bad thing anyway. |
Commit 9c5dafe ("util: add type checking to CONTAINER_OF") made `util.h` #include `toolchain/common.h` in order to get `BUILD_ASSERT()` used by CONTAINER_OF_VALIDATE() when compiling C code. However `toolchain/common.h` is not supposed to be included directly but indirectly through `toolchain/<your_toolchain>.h` and in a very specific order. The direct inclusion caused the following warning when compiling C++: ``` toolchain/gcc.h:87: error: "ZRESTRICT" redefined [-Werror] 87 | #define ZRESTRICT __restrict | In file included from include/zephyr/sys/util.h:18: note: this is the location of the previous definition: include/zephyr/toolchain/common.h:33: 33 | #define ZRESTRICT ``` Fix this issue #62464 by including `zephyr/toolchain.h` instead, as done by 350 other files. Fixes commit 9c5dafe ("util: add type checking to CONTAINER_OF") Signed-off-by: Marc Herbert <marc.herbert@intel.com>
#62620 is merged. So this should have been fixed. |
You mean like this? https://github.com/orgs/community/discussions/17308 I'll close this when daily compilation works again: https://github.com/thesofproject/sof/actions/workflows/daily-tests.yml Should happen tomorrow. |
Daily build is passing again: https://github.com/thesofproject/sof/actions/runs/6192376904 |
Commit 9c5dafe ("util: add type checking to CONTAINER_OF") made `util.h` #include `toolchain/common.h` in order to get `BUILD_ASSERT()` used by CONTAINER_OF_VALIDATE() when compiling C code. However `toolchain/common.h` is not supposed to be included directly but indirectly through `toolchain/<your_toolchain>.h` and in a very specific order. The direct inclusion caused the following warning when compiling C++: ``` toolchain/gcc.h:87: error: "ZRESTRICT" redefined [-Werror] 87 | #define ZRESTRICT __restrict | In file included from include/zephyr/sys/util.h:18: note: this is the location of the previous definition: include/zephyr/toolchain/common.h:33: 33 | #define ZRESTRICT ``` Fix this issue zephyrproject-rtos#62464 by including `zephyr/toolchain.h` instead, as done by 350 other files. Fixes commit 9c5dafe ("util: add type checking to CONTAINER_OF") Signed-off-by: Marc Herbert <marc.herbert@intel.com>
The addition of the
#include toolchain/common.h
in #61962 just revealed a funny ZRESTRICT conflict betweeninclude/zephyr/toolchain/common.h
andinclude/zephyr/toolchain/gcc.h
when compiling C++As a datapoint/evidence, replacing the
common.h
include with#include <zephyr/toolchain/gcc.h>
in #61962 avoids the warning.https://github.com/thesofproject/sof/actions/runs/6127039819/job/16632163797?pr=8175
Originally posted by @marc-hb in #61962 (comment)
The text was updated successfully, but these errors were encountered: