-
Notifications
You must be signed in to change notification settings - Fork 15
pico-sdk: Switch to picolibc #12
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
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.
Just wondering, how should it behave if CONFIG_PICOLIBC is not selected?
Usually, we use PICOLIBC
, so I think it's generally fine.
@@ -43,15 +43,16 @@ function(pico_define_boot_stage2 NAME SOURCES) | |||
if (PICO_C_COMPILER_IS_CLANG) | |||
target_link_options(${NAME} PRIVATE "-nostdlib") | |||
elseif (PICO_C_COMPILER_IS_GNU) | |||
target_link_options(${NAME} PRIVATE "--specs=nosys.specs") | |||
target_compile_options(${NAME} PRIVATE "--specs=picolibc.specs") |
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.
Please add a history about this change to ChangeLog.zephyr.md
.
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.
Thanks, done.
This selects picolibc by using --specs=picolibc.specs for compiling and linking. The linker scripts are adjusted to add KEEP to ensure that --gc-sections doesn't remove the contents of the files. Signed-off-by: Keith Packard <keithp@keithp.com>
The boot loader can use picolibc even if the app needs newlib for some reason; we still get the picolibc benefits in the boot loader. |
target_link_options(${NAME} PRIVATE "-nostartfiles") | ||
endif () | ||
|
||
# boot2_helpers include dir | ||
target_include_directories(${NAME} PRIVATE ${PICO_BOOT_STAGE2_DIR}/asminclude) | ||
|
||
target_link_libraries(${NAME} hardware_regs boot_stage2_headers) | ||
target_link_options(${NAME} PRIVATE "LINKER:--script=${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld") | ||
target_link_options(${NAME} PRIVATE "-T${PICO_BOOT_STAGE2_DIR}/boot_stage2.ld") |
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.
It's a minor point, but I think long options are easier to read in scripts.
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.
picolibc's spec fragments only look for the -T version of this option, so we must use the short variant to prevent addition of the picolibc linker script here.
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, I got it.
Thank you for your clarification.
Could you take a look, please? |
Can you expand on this? What's the benefit? I've read the commit message and it has the what, but not the why of this. |
Probably the most visible benefit is a reduction in memory usage -- picolibc has smaller implementations of many core parts of the C library (stdio, ctype, locales) as well as general memory saving architectural changes (eliminating struct reent). It's also routinely tested for the target systems. I'll be enabling these tests within the Zephyr SDK build to catch bugs introduced in any part of the system (binutils, compiler, linker, libraries). Newlib lacks any visible CI system. |
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.
Thanks for the explanation/rationale. It's a bit of a nit to say I'd prefer to see it in the commit message, but it's here in the PR instead.
Merged. Please update |
This selects picolibc by using --specs=picolibc.specs for compiling and linking. The linker scripts are adjusted to add KEEP to ensure that --gc-sections doesn't remove the contents of the files.