-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
add picolibc tls support #8392
Open
iDings
wants to merge
2
commits into
RT-Thread:master
Choose a base branch
from
iDings:picolibc_tls
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
add picolibc tls support #8392
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
[libc][picolibc] add tls support
- Loading branch information
commit 18373c0cfdbb8c445328f26def82de1ef4abe32f
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from building import * | ||
|
||
src = Glob('*.c') | ||
group = DefineGroup('UTest', src, depend = ['RT_USING_NEWLIBC', 'RT_USING_PTHREADS']) | ||
if GetDepend(['RT_USING_PICOLIBC']): | ||
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. example/libc目录rtthread现在没有编译,也没有看到选项可以打开去编译,但是这个tls的例子暂时没有找到合适放的位置,就先放在这个下面了 |
||
group = DefineGroup('UTest', src, depend = ['RT_USING_PTHREADS']) | ||
else: | ||
group = DefineGroup('UTest', src, depend = ['RT_USING_NEWLIBC', 'RT_USING_PTHREADS']) | ||
|
||
Return('group') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* Copyright (c) 2006-2021, RT-Thread Development Team | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Change Logs: | ||
* Date Author Notes | ||
* 2023-12-19 iDings first version | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include <unistd.h> | ||
#include <finsh.h> | ||
#include <rtthread.h> | ||
|
||
static __thread int i; | ||
|
||
static void child_routine(void *param) | ||
{ | ||
printf("child_thread: i:%d\n", i); | ||
i = 300; | ||
printf("child_thread: i:%d\n", i); | ||
} | ||
|
||
static int tls_test(void) | ||
{ | ||
rt_thread_t child; | ||
|
||
char name[RT_NAME_MAX]; | ||
rt_thread_get_name(rt_thread_self(), name, sizeof(name)); | ||
|
||
printf("i:%d\n", i); | ||
i = 200; | ||
printf("main_thread: i:%d\n", i); | ||
|
||
child = rt_thread_create("tls_thread", child_routine, NULL, 4096, 10, 20); | ||
rt_thread_startup(child); | ||
|
||
sleep(1); | ||
printf("main_thread: i:%d\n", i); | ||
|
||
return 0; | ||
} | ||
MSH_CMD_EXPORT(tls_test, thread local storage example); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
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.
这部分,如果是其他工具链 + 其他libc会怎么样?
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.
我现在的理解,这部分是看编译器,编译器如果使能了tls支持的的话,它会生成tdata,tbss的sections,picolibc的tls部分的话是封装了一些接口方便使用.
![image](https://private-user-images.githubusercontent.com/2938288/292365163-c6754bea-5d9e-4218-a285-ea97d7affb87.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5MDc4ODEsIm5iZiI6MTcyMTkwNzU4MSwicGF0aCI6Ii8yOTM4Mjg4LzI5MjM2NTE2My1jNjc1NGJlYS01ZDllLTQyMTgtYTI4NS1lYTk3ZDdhZmZiODcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjVUMTEzOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9YjNmY2Y1MmRlZjEwNGRhOGI2M2IyYWJlODhlMWNjNjU1NjhhZjhhMThkYjc5MzI2OGRjNjdlMjI0YTcyMTNjNyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.h1DEloHWsoJaGP8by0WTnMURbYw2_oyeWecHhfb1dPw)
![image](https://private-user-images.githubusercontent.com/2938288/292365808-1250813d-6096-4ac1-9908-586524cdbc11.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5MDc4ODEsIm5iZiI6MTcyMTkwNzU4MSwicGF0aCI6Ii8yOTM4Mjg4LzI5MjM2NTgwOC0xMjUwODEzZC02MDk2LTRhYzEtOTkwOC01ODY1MjRjZGJjMTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjVUMTEzOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MDEyMTMzMmQ4ODBjZWNjYjlmZDQ2ZTYyMDk4ODg0MmJjOTI5Yjc2MjMwNzk2YzU0NjM0M2RlYWQ0ZjhlMGJkMyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.u0XMlBVQMF3IfiJI7w864uHU_YmEJS3IGKKA-k5qc7k)
![image](https://private-user-images.githubusercontent.com/2938288/292366705-3dfb7ded-9f98-4fd0-917d-d2dc52f55918.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE5MDc4ODEsIm5iZiI6MTcyMTkwNzU4MSwicGF0aCI6Ii8yOTM4Mjg4LzI5MjM2NjcwNS0zZGZiN2RlZC05Zjk4LTRmZDAtOTE3ZC1kMmRjNTJmNTU5MTgucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjVUMTEzOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9M2EzNGJmYWZlN2M3NWE2NWNjMTY2NTg2NDYwOGQzZDFiYWM4NDQ5ZDk4NTE3YmQwOGQxZGVhZDMzYTlmZThkYSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.n-sHwnH5A9cW2GSaN3iPia45qF6QdnG6q_DlvTnf7m8)
arm提供的gcc+newlibc的编译器的话,我现在看到的都是
--disable-tls
的,不会生成tdata,tbss,linker script里面虽然定义了tdata,tbss,从linker map里面看这部分都不会占用空间, 对于--disable-tls
走的是emutls,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.
https://github.com/picolibc/picolibc/blob/main/doc/tls.md
![image](https://private-user-images.githubusercontent.com/2938288/292366036-09ae73ac-9f6f-415f-9a02-a11a60762f85.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3Lm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MDI0MDcyNSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjVUMTEzOTQxWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NzYwMWZlZGY0ODM0NzViMDkwMzA1MWI5NzA4MTc3NDk1NjJjNDJiZTdjYjhjY2RlZTk4OTcwYmI0Y2Q3NWViYyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.eHSn8NUxdcIUsDPV9RWTymqxGIkq9wzYHQJXsk4MWAY)
picolibc的tls-mode使用的local-exec模式, 看zephyr的话也是支持这种模式