Hello,
I'm trying to build uClibc-based userspace for uclinux. It builds and works as long as I keep uClibc single-threaded. If I enable TLS and NPTL support first I face build errors (one caused by reference to fork from libpthread/nptl/sysdeps/unix/sysv/linux/fork.c, other outside uClibc, in the elf2flt, which cannot deal with .tbss section overlapping .data section) and then runtime errors (an attempt to allocate TLS memory with sbrk which doesn't work in uclinux and then inability to initialize TLS data, which I haven't tracked yet). All that makes me think that either I'm doing something terribly wrong, or TLS + NPTL are not supported by uClibc for uclinux.
So my questions are: - are TLS and NPTL supported by uClibc for uclinux? - if not, what are the supported threading options?
Hello Max,
On Tue, 22 Sep 2015 18:38:06 +0300 Max Filippov jcmvbkbc@gmail.com wrote:
Hello,
I'm trying to build uClibc-based userspace for uclinux. It builds and works as long as I keep uClibc single-threaded. If I enable TLS and NPTL support first I face build errors (one caused by reference to fork from libpthread/nptl/sysdeps/unix/sysv/linux/fork.c, other outside uClibc, in the elf2flt, which cannot deal with .tbss section overlapping .data section) and then runtime errors (an attempt to allocate TLS memory with sbrk which doesn't work in uclinux and then inability to initialize TLS data, which I haven't tracked yet). All that makes me think that either I'm doing something terribly wrong, or TLS + NPTL are not supported by uClibc for uclinux.
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
Try linuxthreads.old, it works for us (0.9.33.2, Cortex-M3/M4. Toolchain is an old CodeSourcery arm-uclinuxeabi arm-2010q1).
Regards, Sergei
Sergei,
On Tue, Sep 22, 2015 at 7:10 PM, Sergei Poselenov sposelenov@emcraft.com wrote:
On Tue, 22 Sep 2015 18:38:06 +0300 Max Filippov jcmvbkbc@gmail.com wrote:
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
Try linuxthreads.old, it works for us (0.9.33.2, Cortex-M3/M4. Toolchain is an old CodeSourcery arm-uclinuxeabi arm-2010q1).
Ok, I was able to build uClibc with linuxthreads.old and it works. Thank you!
I'm a bit concerned about the toolchain that it compiled source with TLS variables without a single warning, but the variables weren't actually thread-local. Oh, well...
Max, On Tue, 2015-09-22 at 21:55 +0300, Max Filippov wrote:
Sergei,
On Tue, Sep 22, 2015 at 7:10 PM, Sergei Poselenov sposelenov@emcraft.com wrote:
On Tue, 22 Sep 2015 18:38:06 +0300 Max Filippov jcmvbkbc@gmail.com wrote:
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
Try linuxthreads.old, it works for us (0.9.33.2, Cortex-M3/M4. Toolchain is an old CodeSourcery arm-uclinuxeabi arm-2010q1).
Ok, I was able to build uClibc with linuxthreads.old and it works. Thank you!
I'm a bit concerned about the toolchain that it compiled source with TLS variables without a single warning, but the variables weren't actually thread-local. Oh, well...
Just for my information - what is your hardware platform and what toolchain combo you tried to build?
Regards, Sergei
On Tue, Sep 22, 2015 at 10:04 PM, Sergei Poselenov sposelenov@emcraft.com wrote:
Max, On Tue, 2015-09-22 at 21:55 +0300, Max Filippov wrote:
Sergei,
On Tue, Sep 22, 2015 at 7:10 PM, Sergei Poselenov sposelenov@emcraft.com wrote:
On Tue, 22 Sep 2015 18:38:06 +0300 Max Filippov jcmvbkbc@gmail.com wrote:
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
Try linuxthreads.old, it works for us (0.9.33.2, Cortex-M3/M4. Toolchain is an old CodeSourcery arm-uclinuxeabi arm-2010q1).
Ok, I was able to build uClibc with linuxthreads.old and it works. Thank you!
I'm a bit concerned about the toolchain that it compiled source with TLS variables without a single warning, but the variables weren't actually thread-local. Oh, well...
Just for my information - what is your hardware platform and what toolchain combo you tried to build?
It's xtensa, binutils-2.24, gcc-5.2.0, uClibc snapshot at revision 7bf35c8b7d4a1f97174eb49f47f33946b282114c all built with the buildroot-2015.08, with corresponding patches. I also had to revert the patch that dropped xtensa-specific uClibc snapshot, otherwise there's only uClibc-ng which doesn't offer linuxthreads.old support for xtensa.
On Tue, Sep 22, 2015 at 06:38:06PM +0300, Max Filippov wrote:
Hello,
I'm trying to build uClibc-based userspace for uclinux. It builds and works as long as I keep uClibc single-threaded. If I enable TLS and NPTL support first I face build errors (one caused by reference to fork from libpthread/nptl/sysdeps/unix/sysv/linux/fork.c, other outside uClibc, in the elf2flt, which cannot deal with .tbss section overlapping .data section) and then runtime errors (an attempt to allocate TLS memory with sbrk which doesn't work in uclinux and then inability to initialize TLS data, which I haven't tracked yet). All that makes me think that either I'm doing something terribly wrong, or TLS + NPTL are not supported by uClibc for uclinux.
As far as I can tell, the bFLT format and linker scripts used have no way to represent the location/size of the TLS image, so inability to initialize TLS makes sense. I think this could be solved by having the linker script put symbols around the TLS image and referencing the symbols rather than ELF headers to find it. Of course dropping bFLT and using FDPIC or regular ELF would be the ideal solution.
I've looked at this all recently; see this and the containing thread: http://lists.nommu.org/pipermail/nommu/2015-September/000037.html
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
At this point, I think the answer is no, and it would probably be considerable work to get it working. Nothing that's prohibitively difficult for someone familiar with the code and linking/binfmt topics, but still time-consuming.
The old LinuxThreads may or may not work (for some limited definition of "work") on some NOMMU targets. It probably varies from one to another so I don't think there's a single answer to your second question without knowing which target(s) you care about.
What I would recommend if you need threads/TLS, but I'm naturally biased: I'm presently working on FDPIC-based NOMMU support in musl libc with thread and TLS support matching normal targets with MMU. It's already mostly working and progressing rapidly, but the only supported target so far is SH. Getting more NOMMU targets added would be great.
Rich
Rich,
On Tue, Sep 22, 2015 at 7:25 PM, Rich Felker dalias@libc.org wrote:
As far as I can tell, the bFLT format and linker scripts used have no way to represent the location/size of the TLS image, so inability to initialize TLS makes sense. I think this could be solved by having the linker script put symbols around the TLS image and referencing the symbols rather than ELF headers to find it. Of course dropping bFLT and using FDPIC or regular ELF would be the ideal solution.
I've looked at this all recently; see this and the containing thread: http://lists.nommu.org/pipermail/nommu/2015-September/000037.html
Thanks for the hints, I've only started looking at FDPIC ABI.
So my questions are:
- are TLS and NPTL supported by uClibc for uclinux?
- if not, what are the supported threading options?
At this point, I think the answer is no, and it would probably be considerable work to get it working. Nothing that's prohibitively difficult for someone familiar with the code and linking/binfmt topics, but still time-consuming.
The old LinuxThreads may or may not work (for some limited definition of "work") on some NOMMU targets. It probably varies from one to another so I don't think there's a single answer to your second question without knowing which target(s) you care about.
They appear to work, at least for my simple tests.
What I would recommend if you need threads/TLS, but I'm naturally biased: I'm presently working on FDPIC-based NOMMU support in musl libc with thread and TLS support matching normal targets with MMU. It's already mostly working and progressing rapidly, but the only supported target so far is SH. Getting more NOMMU targets added would be great.
I'm currently in the middle of porting musl to xtensa, I guess after making it work I'll look closer at adding noMMU support to it.