-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Provide support for Picolibc #26545
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
Provide support for Picolibc #26545
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,7 +1,11 @@ | ||||||||||||||||||||||||||||||||||
| # SPDX-License-Identifier: Apache-2.0 | ||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||
| if(CONFIG_PICOLIBC) | ||||||||||||||||||||||||||||||||||
| add_subdirectory(picolibc) | ||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||
| if(CONFIG_NEWLIB_LIBC) | ||||||||||||||||||||||||||||||||||
| add_subdirectory(newlib) | ||||||||||||||||||||||||||||||||||
| else() | ||||||||||||||||||||||||||||||||||
| add_subdirectory(minimal) | ||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||
| endif() | ||||||||||||||||||||||||||||||||||
|
Comment on lines
+3
to
+11
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please make an
Suggested change
|
||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
|
|
||
| zephyr_library() | ||
| zephyr_library_sources(libc-hooks.c) | ||
|
|
||
| # Zephyr normally uses -ffreestanding, which with current GNU toolchains | ||
| # means that the flag macros used by picolibc <inttypes.h> to signal | ||
| # support for PRI.64 macros are not present. To make them available we | ||
| # need to hook into the include path before the system files and | ||
| # explicitly include the picolibc header that provides those macros. | ||
| zephyr_include_directories(include) | ||
|
|
||
| # define __LINUX_ERRNO_EXTENSIONS__ so we get errno defines like -ESHUTDOWN | ||
| # used by the network stack | ||
| zephyr_compile_definitions(__LINUX_ERRNO_EXTENSIONS__) | ||
|
|
||
| zephyr_link_libraries( | ||
| m | ||
| c | ||
| gcc # Lib C depends on libgcc. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No changes requested, but with the fact that Zephyr is working towards more toolchains, especially LLVM, and thus also the support of compiler-rt runtime library, I was wondering if picolib could be used in that case. Also this makes me wonder if the use of picolib should be restricted, based on toolchain in use. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. picolibc built with llvm still requires libgcc as that has all of the helper functions required by the underlying ABI, such as the __aeabi functions for ARM. -lgcc would be automatically inserted into the link command by the compiler front-end (either clang or gcc) if zephyr wasn't using -nostdlib. zephyr could probably remove that flag and simply let the compiler front end insert both -lc and -lgcc. |
||
| ) | ||
|
|
||
| # The -T/dev/null avoids pulling in picolibc.ld | ||
| zephyr_link_libraries( | ||
| --specs=picolibc.specs | ||
| -T/dev/null | ||
| ) | ||
|
|
||
| zephyr_compile_options( | ||
| --specs=picolibc.specs | ||
| -D_GNU_SOURCE | ||
| ) | ||
|
|
||
| if(CONFIG_PICOLIBC_INTEGER_PRINTF) | ||
| zephyr_compile_options( | ||
| -DPICOLIBC_INTEGER_PRINTF_SCANF | ||
| ) | ||
| zephyr_link_libraries( | ||
| -DPICOLIBC_INTEGER_PRINTF_SCANF | ||
| ) | ||
| endif() | ||
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.
How about: