-
Notifications
You must be signed in to change notification settings - Fork 11
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
pico-sdk: Avoid using 'typeof()' operator #9
base: zephyr
Are you sure you want to change the base?
Conversation
C99 doesn't support the `typeof()` operator used in Pico-SDK. So we need to rewrite using `hw_xor_alias` code with `hw_xor_alias_untyped()`. Signed-off-by: TOKITA Hiroshi <tokita.hiroshi@gmail.com>
This feels like going in the wrong direction. https://github.com/pdgendt @pdgendt might be able to offer some guidance. There seems to be support for enabling GNU extensions as a per-module, and that would be a good fit for this, I think. |
Not sure what you need here, modules can require a minimum C standard version with |
I think this is simpler than I thought. I want to avoid changing the source code, and change how Zephyr builds
|
We use BSP to reduce development costs, so I think it needs to be reasonable from that perspective. In the scope of this case, the change is only to avoid compilation errors for code that does not actually run, so I think there is not enough benefit to introducing new constraints for retain the original code. I don't necessarily think that we should adhere to C99, but raising the level of the C standard would still strengthen the constraints. To put it directly, I believe maintaining compatibility with C99 is more valuable than preserving code commonality with the Pico-SDK. |
I'm sorry, I don't really understand this sentence. The Zephyr Project builds its own build toolchain, and ships it as part of Zephyr-SDK. The version of
It supports
That wasn't what I was suggesting in the example I gave. Please re-read the snippet in #9 (comment) . There are several examples
Changing the Pico SDK in a piecemeal way like this is going to be a way to introduce maintenance burden: unless someone changes everything, it's going to result in multiple pairs of PRs (one updating the HAL, then another that changes the |
Simply put, we need to follow Zephyr's customs. Since very few things in Zephyr specify anything other than STD_C99, you will need to clearly explain why exceptional correspondence is needed.
Rather than whether it can be done, I think it is necessary to justify specifying STD_C when other things do not.
The need to do so has already arisen, and as you can see from the maintenance of other HALs, such actions are commonplace. Also, it is within the realm of realistic costs at this point. Zephyr is not Linux kernel, and also Zephyr is not Pico-SDK. I have one question. I think we should maintain C99 compatibility as much as possible, but do you have any policy on this point? |
Ah, I remember now. |
Zephyr does not only care about it's own SDK, you can use a different toolchain, see zephyrproject-rtos/zephyr#84119 where support for GCC 4.1.2 is kept possible. |
@soburi any toolchain building Zephyr must support C99 as of today, but C11 or later cannot be required in general, because as @pdgendt states, the codebase is being built by older toolchains. However, the doc clearly states that, for some modules or functionality, it is allowed to require C11. So, in this particular case, since this only applies to Raspberry Pi Pico, I would tend to agree that requiring C11 is not an issue. Copying @kartben and @nashif in case they have other opinions. |
@ajf58 as @soburi pointed out, Zephyr supports multiple toolchains, not only the ones bundled in the SDK. Here's a good example of this: |
would it make sense to also contribute the patch upstream too? I am sure this |
Right, but I don't think that answer my question. If Zephyr doesn't want to support I share @andyross 's bemusement about this. Is someone picking up a part released in 2021, trying to build software written in 2022, with a compiler that doesn't support a standard from 2011? Isn't it reasonable for a vendor to stipulate "If you want to run Zephyr on our products, you need a toolchain that was release in the past... 14... years."? Edit: corrected my typos |
@stephanosio would be better placed to answer this, but I believe this is because it makes little sense to disable features in GCC regardless of what the RTOS can use by default. Also, as stated above and in the doc, some modules and features do require C11 today, so the toolchain must support that as well.
I agree, but things are more complicated than that. Some vendors (Xtensa cough cough) or old architectures (see my link above to the Nvidia PR) simply do not have modern compilers available, but the silicon or IP is still being used widely. |
Thank you for your explanation. But pico-sdk requires C23 or GNU extensions... |
Oh wow I see. @stephanosio any preferences here? |
I don't think this is a dramatic thing. What I really want to avoid is fettling with Pico-SDK beyond the bare minimum. I think it's wasted effort: Raspberry Pi built the SDK using |
No objections from me to require |
I have to agree with @carlescufi and @ajf58: Avoid Zephyr-specific changes to the Pico SDK, and require the newer language standard when building for the Pico boards. This seems to me to be the most consistent with the C Language Support :
|
From the perspective of a "developer" of rpi_pico, I think it makes sense to make an exception for rpi_pico's hal and specify the specific "--std=gnu11", Does this seem like an issue from this perspective? Or do you know of any experts who would be good to consult? |
@soburi HALs are very much out of scope of the safety certification efforts as far as I know :) |
Thank you for explaining. |
C99 doesn't support the
typeof()
operator used in Pico-SDK. So we need to rewrite usinghw_xor_alias
code withhw_xor_alias_untyped()
.