-
Notifications
You must be signed in to change notification settings - Fork 3k
Add configuration option to disable printf entirely #13380
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
|
Thanks George. I have a need for this as well. |
|
@AGlass0fMilk, thank you for your changes. |
|
Thanks for the suggestion. If something like this was to be implemented, I would instead prefer it to be a possible option of the existing target.printf_lib. |
|
Thanks @AGlass0fMilk. But lots of code (e.g. connectivity, storage in Mbed OS, many external libraries) use |
|
@LDong-Arm @hugueskamba I agree with both statements. I did it this way to just get the PR up for discussion. I also wanted to avoid having to dive into the tools code, which I think will be necessary to add the I think it'd be an acceptable option as long as we give fair warning in the documentation. My primary use case is for small Mbed-OS bootloaders that don't need to print anything and avoid using any variant of Any suggestions on how to proceed with the |
FYI @rwalton-arm (as it involves tools changes). @AGlass0fMilk Are you aware of platform.stdio-minimal-console-only? It helps to reduce code size. |
|
@rwalton-arm how close are we to the new tools release? Should this just get implemented for the new stuff? |
|
Well, the script to select printf is in the mbed-os repo itself. mbed-os/tools/toolchains/mbed_toolchain.py Lines 1086 to 1092 in e57e325
Once we have evaluated and agreed on the support for no-printf, we can make it by ourselves (both source code change and script change in one PR). |
|
@Patater @rwalton-arm I assume this would now need to wait until the new tools as we are freezing contributions to /tools in mbed-os ? |
@adbridge |
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.
OK from tools side
The PR as it stands looks fine. However, if the suggestion of adding this as an extra |
We're still a month or two away from the new tools release. We will need a way of handling this, preferably in CMake. We don't want logic to set build flags in the new Python tools. |
|
I would suggest parking this for now and making sure it is captured in the new tools. Otherwise we will get people used to doing things one way only to potentially have to change it again in a relatively short period ? |
|
I agree with parking it. The implementation isn’t pretty and was a stopgap to get conversation started. Please capture this as a requirement for the updated tools.
On Aug 7, 2020, at 8:30 AM, Anna Bridge <[email protected]<mailto:[email protected]>> wrote:
I would suggest parking this for now and making sure it is captured in the new tools. Otherwise we will get people used to doing things one way only to potentially have to change it again in a relatively short period ?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#13380 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AACVSJHH53IBP7Z4SKC35D3R7PXUPANCNFSM4POZOEDA>.
|
|
@rwalton-arm @Patater could you please capture this as a requirement for the new tools work? |
|
Printf library selection for the new tools is implemented and being added to Mbed OS at #13615 |
|
@AGlass0fMilk please look at CMake feature branch (it will be on master soon) and create a new issue how we can do this with CMake and new tools, thanks. I'll close this. |
|
Now I think an ideal way to disable printing (and save code size) is to use a trace library (e.g. mbed-trace) which, when disabled, removes trace statements with macros. |
|
@LDong-Arm i agree, a robust trace system is the way to go. |
Summary of changes
This PR adds a configuration option under the
minimal-printfumbrella to simply replace all printf-like calls with no-ops essentially.There is probably a cleaner way of doing this but I figured it could go under the existing minimal-printf overrides... it could be considered a minimal printf implementation (one that does nothing!)
This saves around 1kB of flash if printf is not required in your application. This is useful because it is not always feasible to simply comment out printf calls throughout your code, especially if you're using external libraries.
Impact of changes
Users wishing to completely disable printf can now do so by configuring
platform.minimal-printf-disable-allto true.Migration actions required
None
Documentation
Update minimal-printf documentation upon PR approval.
Pull request type
Test results
Reviewers