On 8/9/2015 12:51 AM, Iain Buclaw via Digitalmars-d wrote:
On 9 August 2015 at 09:33, Walter Bright via Digitalmars-d
<digitalmars-d@puremagic.com <mailto:digitalmars-d@puremagic.com>> wrote:

    On 8/9/2015 12:18 AM, Iain Buclaw via Digitalmars-d wrote:

        If the libraries were shared, this would reduce linking time, which in
        various
        benchmarks I've done is where most small projects spend the majority of
        their
        time doing.  But no one has as of yet come up with a feasibly
        implementable idea
        to do that.


    We ship Phobos as a shared library on Linux, OSX and FreeBSD.

... By inventing your own storage section?  This doesn't work where TLS is not
natively supported.  (Though, no one has really told me how it works after years
repeatedly asking, but this is what I assume is being done).

I don't understand your question. On Linux, TLS data is inserted into the same section that gcc puts it. On OSX, where gcc didn't support TLS, dmd did create it into a data segment. Every time a new thread was created, druntime would malloc a chunk of data, and copy that data segment into it to initialize it. Then it would save a pointer to the malloced data in the thread data structure.

Accessing the OSX TLS involved finding the thread data structure for the current thread, and getting the pointer to the TLS malloced data, and adding the offset of the symbol to it.

The only reason a new data section was required was so that all the TLS data from all the object modules would be adjacent. It's the only way to do it.

Reply via email to