<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116562>116562</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Cross-compiling to mac-arm failed to support threa_local storage
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
addsoa
</td>
</tr>
</table>
<pre>
Try to compile
``` c
unsigned int test() {
static _Thread_local unsigned int tl_tid;
unsigned int tid = 4;
if (tl_tid) return tl_tid;
else return tid;
}
int main() {
unsigned int rc = test();
return 0;
}
```
Output:
``` bash
$ clang --target=arm64-apple-darwin-mach --sysroot=$SYSROOTPATH ./testthreadlocal.c
./testthreadlocal.c:2:9: error: thread-local storage is not supported for the current target
2 | static _Thread_local unsigned int tl_tid;
| ^
1 error generated.
```
clang:
``` bash
clang --version
Ubuntu clang version 17.0.6 (++20231209124227+6009708b4367-1~exp1~20231209124336.77)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-17/bin
```
clang16, clang18 generated the same error.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVE1v4zYQ_TXUZSCBHNGidNDBjmu0pxRd99CTQUmMzIIiBZLKJpf97YU-ktiL3fSwgmEInKeZN-8NR4age6tUTXYHsjsmcopX52vZdcHJpHHda332rxAdtG4YtVFA6JHQPSno-oN2PZjskqgDbSNEFSLBkmAFRBxWAGxPiDLqFi7nq1eyuxjXSgP3X5tL1B3Jv_vwHqM7IPkR-DvsHqyfgGC5ZcIKvIqTtz9LrUxQ75CbOBHH2-Rz4UFq-7PW7hj6diH4IcVH1a0S_UGdN1lvyz5OcZwiyfffS9_IcN3OkENrpO0hTaP0vYokP0o_FDyV42hU2kn_Vdt0kO0V0jS8Bu_cjCHIv_zz5a_Hx_Of-_PvkBE8zYzjYs7iTbYZ_ONQvkeS7yuS70F57_z8siLS1dkQnZe9Ah3AughhGkfno-rgyXmIVwXt5L2aHV1pvwuKQMQD_OLU3KbYHrL7bUWwlTH0yiovo-qyTzxYxP3Ugjf5n5UP2tn18O9msnHarNkiwERGswKWqTgQPCDFnCGtGHJEQfBQUFoJWjY8L0TKvqmXkX27AeV5kQkxT9RS47z5vYeXsrgUPB3b1Gg7vaS9nTbIohoMrlNmBo4u6Jc19IcNURqjuqNezCN4moIneDK6mf_N85AyQfDUaPt_-rCC4MPaLCs_dF1sDnJQq-CbzElX512VVzJRNRM5KyvKsEyudcebQrCy46Vsy7IQouClEuKJc4Yt5SzRNVLkjLGS0nyHIpOlqFBKQZFxRpUknKpBapPN7DPn-0SHMKmasWJXYGJko0xYNh6iVV9hiRLEeQH6emm5mfpAODU6xPCRJupoVP3gXQjpug-17eflOMg2lX6AJ6nN3LB7G_T1Mlzu7kIyeVNfYxzDPFB4InjqdbxOTda6YdP8TfrRu39VGwmeFpKB4Gnr4rnG_wIAAP__KuKu7g">