-
Notifications
You must be signed in to change notification settings - Fork 3k
[RFC] Use minimal printf by default inside the OS #12168
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
Conversation
@bulislaw, thank you for your changes. |
Test run: FAILEDSummary: 2 of 4 test jobs failed Failed test jobs:
|
Test run: FAILEDSummary: 2 of 4 test jobs failed Failed test jobs:
|
It is a good idea to move mbed-os and examples to use minimal printf.
Why expand to stdlib? This is extra complexity and does not bring anything, unless we are using format specifiers not supported by minimal printf. |
In an unlikely scenario when you are using std printf in your app you could save 1-1.5k by switching off minimal-printf, considering you are already pulling printf and its dependencies. But you're probably right, no point complicating things any more. I'm more worried about the 10 different ways of printing in Mbed and the most obvious one ( |
@@ -74,7 +74,7 @@ namespace mbed { | |||
* i2c.read( addr8bit, cmd, 2); | |||
* | |||
* float tmp = (float((cmd[0]<<8)|cmd[1]) / 256.0); | |||
* printf("Temp = %.2f\n", tmp); | |||
* mbed_printf("Temp = %.2f\n", tmp); |
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.
Floating point support for minimal-printf is disabled by default.
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.
Then the minimal-printf README is wrong:
* %f: floating point (enabled by default).
* %F: floating point (enabled by default, treated as %f).
* %g: floating point (enabled by default, treated as %f).
* %G: floating point (enabled by default, treated as %f).
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.
I'll add it to things to consider in this PR.
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.
Yes it is wrong: https://github.com/ARMmbed/mbed-os/blob/master/platform/mbed_lib.json#L146
There is a PR to fix it.
@geky I changed all the printf family calls in littlefs to mbed_printf (that is minimal-printf). But considering that we only host a copy maybe it's not the best way and adding some abstraction over it would be better. Thoughts? |
Test run: FAILEDSummary: 1 of 4 test jobs failed Failed test jobs:
|
43ccdf8
to
13ad49c
Compare
Use the same configuration as for Unix as these are broadly compatible.
It matters for 64b platforms like x86 for unit testing.
13ad49c
to
4d347b8
Compare
After some discussions I've decided to close this ticket and pursue different path. I'll enable use of minimal-printf as a default implementation of printf* family calls in Mbed OS. Looking on how fiddly it would be to replace all the occurrences of printf* family and prevent new ones creeping in and it still wouldn't guarantee users not using it without knowing the cost. Stay tuned for the new PR. |
Summary of changes
Replace stdlib printf family calls with minimal printf inside Mbed OS core. System components use printf family function in many places internally. Using minimal printf allows us to to save over 15k flash in basic use case. It doesn't affect users as by default it doesn't do mapping from mbed_printf to printf.
In users or other system component will use stdlib printf family it will pull both versions of printf, but the dependencies pulled will be reduced (depending on the explicit library printf usage) resulting in overall size decrease of around 6k.
I'm raising this PR as a work in progress RFC, because I want to start discussion to move the whole system to using minimal printf internally.
Open actions
mbed_printf
conditionally expand either to stdlib or minimal printf? Probably not.For simple RTOS example compiled in release
Master:
PR:
@kjbracey-arm @AnttiKauppila @SeppoTakalo @evedon
Impact of changes
Migration actions required
Documentation
ToDo
Pull request type
Test results
Reviewers