-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Support Picolibc in addition to newlib #5762
Conversation
Picolibc defines these network macro functions, which conflict with the definitions in netdev_ipaddr.h. Signed-off-by: Keith Packard <keithp@keithp.com>
We may have included stdio.h elsewhere in the system. Signed-off-by: Keith Packard <keithp@keithp.com>
|
I cannot get permission from my employer for any CLA. |
Thank you for your contribution! |
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.
Thank you for your contribution. But, where is picolibc implementation? Is it made as a software package?
@@ -606,6 +606,14 @@ struct rt_cpu | |||
|
|||
#endif | |||
|
|||
#if defined(RT_USING_PICOLIBC) && defined(_HAVE_PICOLIBC_TLS_API) | |||
#define RT_USING_TLS |
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.
So good for this feature. It's a feature planning in v5.0.
src/thread.c
Outdated
@@ -177,12 +180,22 @@ static rt_err_t _thread_init(struct rt_thread *thread, | |||
/* init thread stack */ | |||
rt_memset(thread->stack_addr, '#', thread->stack_size); | |||
#ifdef ARCH_CPU_STACK_GROWS_UPWARD | |||
#ifdef RT_USING_TLS | |||
thread->tls = thread->stack_addr; | |||
_init_tls(thread->tls); |
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.
From my understanding, it's a porting layer for tls (in libc?). It's better to use a unify name for 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.
Agreed -- I will adjust this to use an rt-prefixed name instead of the internal picolibc name.
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've pushed an updated version which creates an rt abstraction and uses the picolibc implementation for picolibc.
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.
And another update which installs the GNU Arm Embedded Toolkit version of picolibc for CI tests.
Oh, Sorry! Yes, picolibc is available at https://github.com/picolibc/picolibc -- the current version is 1.7.6. I've given numerous presentations: https://www.youtube.com/watch?v=SC6aBezNFFQ Picolibc is also available in Debian and Debian derivatives, and is included in Crosstool-ng. Zephyr has recently approved including Picolibc as a module, which means it can be built along with the operating system. |
Oh, I should have made it more clear that the three patches modifying existing BSP are meant as demonstrations of how to use picolibc and what the benefits might be. I would not expect those to be merged unless RT-Thread is ready to accept picolibc as a hard dependency. |
59073ef
to
017f027
Compare
Not sure what happened, but I got the wrong URL for the picolibc bits somehow (an extra 'v' snuck in). Weird. |
This allows projects to set the LIBC variable to either 'newlib' or 'picolibc' to select between these two libraries. RT-Thread expects picolibc to have been built with TLS support, and that requires a small change to the project linker script to set up TLS symbols, inserting this section: . = ALIGN(8); .tdata : { *(.tdata) *(.tdata.*) *(.gnu.linkonce.td.*) } .tbss (NOLOAD) : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) } __tdata_source = ADDR(.tdata); __tdata_size = SIZEOF(.tdata); __tbss_size = SIZEOF(.tbss); __tls_size = SIZEOF(.tdata) + SIZEOF(.tbss); These should go with the section defining ROM contents as the '.tdata' section will place initialization values for the TLS block in memory. Signed-off-by: Keith Packard <keithp@keithp.com>
This adds a configuration option to replace the RT output functions with macros that refer to the underlying stdio versions from libc. Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
This adds the necessary changes to the linker script and then selects picolibc instead of the default (newlib). Before: text data bss dec hex filename 561638 2100 84928 648666 9e5da rtthread.elf After: text data bss dec hex filename 525009 692 86844 612545 958c1 rtthread.elf Signed-off-by: Keith Packard <keithp@keithp.com>
Before: text data bss dec hex filename 165330 2256 14256 181842 2c652 rtthread-vexpress.elf After: text data bss dec hex filename 156747 1200 14128 172075 2a02b rtthread-vexpress.elf Signed-off-by: Keith Packard <keithp@keithp.com>
Sorry, We cannot merged it PR. Thanks for you contribution, again. |
Add support for picolibc
Picolibc is a C library that is designed to work on 32 and 64 bit embedded systems. It is available on Debian derivatives, can be built using crosstool-ng or can be added to the GNU Arm Embedded Toolkit.
Picolibc is comprehensively tested on Arm, Aarch64, x86 and RISC-V embedded systems to ensure standards conformance. It offers significant memory savings in typical usage as well as avoiding dynamic memory allocation for even complex code paths like floating point conversions.
以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in the submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use a web browser to visit PR, and check items one by one, and ticked them if no problem.
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0
代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up