Getting tls symbols out of the compiler.
Johannes Pfau
nospam at example.com
Thu May 30 03:13:24 PDT 2013
Am Thu, 30 May 2013 10:42:17 +0100
schrieb Iain Buclaw <ibuclaw at ubuntu.com>:
>
> This is more of a lazy init that won't affect start-up speed. Note:
> this idea is based off what C++ (g++) does for say - static A a = new
> A();
>
I see.
>
> I don't think it would have much slow down. Albeit the first
> initialisation would jump through the druntime library twice, but
> there after it's a single/two instruction test. Pretty negligible -
> but I'm not a speeeeeeeeed demon or freak who wants everything
> compiled with -fOMG-fast. =)
I'm more worried about adding many roots to the GC. The code which
checks the guard variable is probably neglectable.
>
>
> >> Though this should not be required if we have a proper TLS GC in
> >> place.
> >
> > Do you mean Martin Nowak's shared library/TLS work? That indeed
> > sounds like the proper solution.
> >
>
> It should certainly mean that we don't have to worry about removing
> roots once they've been added.
AFAIK he also changed how TLS sections are looked up for the main
executable. _tlsstart and _tlsend are not used anymore. Instead some
mainly undocumented obscure glibc interface is used to ask the runtime
linker for the start and end of the TLS section.
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/sections_linux.d#L122
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/sections_linux.d#L164
https://github.com/D-Programming-Language/dmd/commit/313132b6e20c119fa64c6164574818421cb522ce
>
> > (And maybe the D community should develop a sane standard interface
> > to the runtime linker to access sections. Then go lobbying all
> > major libcs out there...)
>
> You mean binutils? :-)
>
> See binutils/ld/scripttempl for the ldscripts used to lay out the tls
> data sections. (Note, only a few actually have a TLS section - and
> only winpe defines a _tls_start__ and _tls_end__ symbol).
Well the start/end symbols could be introduced in binutils linker
scripts. But the elf format already has all the information about
section size and the runtime linker (ld.so) knows where every section
starts and it also knows its size. There's just no standard interface to
receive that information. (I had a quick look at the FreeBSD runtime
linker some time ago. With some C libraries you can even get the
elf header, but it's all non-standard and undocumented)
More information about the D.gnu
mailing list