-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
minimal libc + posix: add strerror and perror functions #46101
Conversation
d656113
to
92d6660
Compare
Coding guideline issues are a false positive |
b769ca2
to
e41a12b
Compare
98eac69
to
dd5ecfa
Compare
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.
Need to update https://github.com/zephyrproject-rtos/zephyr/blob/main/doc/services/portability/posix.rst as well.
Also as per #45776 and the previous discussion on the scope of the minimal libc, I am not convinced this should be a part of the minimal libc because:
- The original intent of the minimal libc was to provide only the minimal amount of functions required to make Zephyr run for testing and validation as per @nashif's comments in the linked discussion.
- These functions are not required by any of the Zephyr internal components.
- We will be moving on to using the picolibc as the default C library instead of the minimal libc in the near future, in which case the latter will be reserved only for internal testing and validation purposes and will not be used by end users/products.
Nevertheless, I am not necessarily opposed to merging this because we have added other "non-essential" features to the minimal libc before, and this feature can be configured such that it does cause any meaningful footprint increase.
Good catch - will do.
Yes, definitely. Another aspect about the minimal libc, was to minimize the amount of maintenance necessary as well. This implementation of I can definitely see the frustration about manually maintaining a separate table of error strings that would rely on a human to remember to update. At least this way it's minimal in that sense.
Note:
That works for me too - I would make this PR to picolibc as well, if it does not already have I wouldn't necessarily say with absolute certainty that users/products will not use the minimal libc though. If it's in-tree (rather than a module) that might be enough for some organizations to stick with it, as the cost of adding / updating another repo is large in comparison.
Thanks. Yeah, I thought that would be a concern for sure, and so wanted to make the default "no code size increase". |
970d7f9
to
e28c4dc
Compare
Yea, GitHub is having (yet another) bad day. https://discord.com/channels/720317445772017664/733037738068148335/991718319310766090 |
@keith-packard - could use your review here as well |
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.
Let's have the strings present by default so that naive apps 'just work'.
@keith-packard - I've flipped and I've flopped already. Am going to go with the maintainer's request here. |
@stephanosio, @keith-packard - please re-ack :-) |
Add simple strerror() and strerror_r() implementations. Fixes zephyrproject-rtos#46099 Signed-off-by: Christopher Friedt <[email protected]>
Add tests for strerror() and strerror_r() Signed-off-by: Christopher Friedt <[email protected]>
Add a trivial implementation of `perror()`. Fixes zephyrproject-rtos#46100 Signed-off-by: Christopher Friedt <[email protected]>
Add myself as collaborator on the C library. Signed-off-by: Christopher Friedt <[email protected]>
@keith-packard can you please re-approve? |
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.
lgtm.
Add basic
strerror()
andperror()
implementations to the minimal C library.Also add myself as collaborator in that area.
With a simple change to
samples/hello_world
, we observe the following size differences on cortex-m3:Before change:
After change (
CONFIG_MINIMAL_LIBC_STRING_ERROR_TABLE=n
):After change (
CONFIG_MINIMAL_LIBC_STRING_ERROR_TABLE=y
):Fixes #46099
Fixes #46100