libs/libc/time: Add configuration options for the strftime#19024
Merged
Conversation
acassis
previously approved these changes
Jun 2, 2026
linguini1
previously approved these changes
Jun 2, 2026
linguini1
left a comment
Contributor
There was a problem hiding this comment.
Keep the memory optimizations coming!
ed8f683 to
953f92b
Compare
85dd0aa to
560beaa
Compare
Contributor
Author
|
Rebase on latest master |
michallenc
approved these changes
Jun 3, 2026
xiaoxiang781216
approved these changes
Jun 3, 2026
Member
|
Hi: Could you Rebase your PR with the Master Branch? We fixed the Segger SystemView Error in the CI Build. Thanks :-) |
acassis
approved these changes
Jun 3, 2026
This adds 3 configuration options for the lib_strftime, which can be used to save flash memory when all the formatters are not needed by an embedded application. There is always a minimal set of formatters supported: "%a, %b/%h, %d, %H, %m, %M, %S, %Y, %%". To add on top of that one can specify: - LIBC_STRFTIME_C_STANDARD_FORMATS : All ISO-C conversion specifiers - LIBC_STRFTIME_POSIX_FORMATS : Additional posix formats - LIBC_STRFTIME_NONSTANDARD_FORMATS : Additional GNU nonstandard formats All of these are enabled by default unless building for CONFIG_DEFAULT_SMALL. Disabling these options can save over 3KB of flash on an 32-bit ARM system, when all the format specifiers are not needed. Signed-off-by: Jukka Laitinen <jukka.laitinen@tii.ae>
560beaa to
1e73a7c
Compare
Contributor
Author
|
re-based to pass the CI |
linguini1
approved these changes
Jun 3, 2026
Member
|
FYI: I restarted the CI Build to fix the Docker Image |
lupyuen
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This adds 3 configuration options for the lib_strftime, which can be used to save flash memory when all the formatters are not needed by an embedded application.
There is always a minimal set of formatters supported: "%a, %b/%h, %d, %H, %m, %M, %S, %Y, %%". To add on top of that one can specify:
All of these are enabled by default unless building for CONFIG_DEFAULT_SMALL. Disabling these options can save over 3KB of flash on an 32-bit ARM system, when all the format specifiers are not needed.
I have grouped the switch-cases according to the flags, thinking that it was nicer. Now looking at this, I realize that it is quite difficult to review. I can also keep the switch-cases in order, and just scatter the ifdefs around, if that would be preferable, just let me know!
Impact
No impact, unless building for CONFIG_BUILD_SMALL (in which case the formatters needs to be enabled specifically), or if formatters are specifically disabled in the configuration.
Testing
Compilation has been tested on nucleo-f767zi:nsh:
boards/arm/stm32f7/nucleo-f767zi/configs/nsh/defconfig:
CONFIG_STM32F7_BKPSRAM=y
CONFIG_STM32F7_BBSRAM=y
CONFIG_STM32F7_PWR=y
CONFIG_STM32F7_SAVE_CRASHDUMP=y
boards/arm/stm32f7/nucleo-f767zi/configs/nsh/defconfig:
Diff: 3284 bytes smaller image
In addition, functionality is checked with "date" on Pixhawk4 board, using only minimal set of formatters: