>From time to time I've been trying to build Phobos and druntime as a dynamic 
>library on Mac OS X. Every time I try I hit some problem or there's a question 
>I can't answer. Now I'm planning to give it another try and I have collected a 
>couple of problems/questions below I'm hoping to get help with.

1. One of my goals was to remove all global variables referring to symbols in 
the object files. I've removed all occurrences of "_minfo_beg", "_minfo_end" 
and similar to instead use the proper API to get data from a section of the 
object file. This has been working fine except in one case and that is with 
"_tls_beg" and "_tls_end".

The thing is that accessing TLS variables seem to work fine when I do a simple 
test but when I run the unit tests for druntime they fail. The reason for the 
failure is this line:

https://github.com/jacob-carlborg/druntime/blob/master/src/core/thread.d#L3972

What I don't get is it this: I thought  ___tls_get_addr was called every time a 
TLS variable was accessed. Which would mean that my simple test should fail as 
well, but it doesn't.

2. What should happen to the _tls_beg and _tls_end sections when a library is 
dynamically loaded, i.e. using dlopen? Since _moduleinfo_array, which is 
wrapped by _minfo_beg and _minfo_end, is an array I'm just appending to the 
array when a library is dynamically loaded.

3. I think that _moduleinfo_array needs to be an associative array or similar. 
Using a mach_header, corresponding to a dynamic library, as the key and the 
current content of _moduleinfo_array as the value. This will allow to easily 
add and remove module infos when dynamic libraries are loaded and unloaded.

But if an associative array should be used we probably can't use the built-in 
one because the runtime may not be fully initialized to use it yet. In that 
case we need some kind of lightweight associative array that can work when the 
runtime isn't fully initialized. I think that creating an associative array for 
that purpose is beyond my current capabilities, but I know Sean has mentioned 
he has been thinking/wanted to created an associative array for this purpose.

It would be nice to have a low level array type that can be used in the runtime 
as well. It's easier to create but it would still be nice to have properly 
working array type in the runtime.

-- 
/Jacob Carlborg

_______________________________________________
dmd-internals mailing list
dmd-internals@puremagic.com
http://lists.puremagic.com/mailman/listinfo/dmd-internals

Reply via email to