[phobos] Showstopper bug: Hello world fails on OSX!

Sean Kelly sean at invisibleduck.org
Tue Nov 9 07:40:44 PST 2010


On Nov 9, 2010, at 3:47 AM, Michel Fortin wrote:

> Le 2010-11-09 à 3:33, Jacob Carlborg a écrit :
> 
>> See my replay to Michel Fortin.
>> 
>> Just out of curiosity why does DMD use this approach with begin, content, end to determine a section on Mac OS X? Looking at the source code for object_.d in Tango for LDC, the same implementation is used for all Posix systems and that is the same approach which is used in druntime for Linux, Solaris and FreeBSD.
> 
> I believed the reason was that Walter could not find at the time a way to get the size of a section, so he developed this little hack.
> 
> Now, that's surprising because if you look at rt/memory_osx.c in druntime you'll find it does exactly that: it calls getsectbynamefromheader to get a section's address and size to add ranges to the GC, and _dyld_register_func_for_add_image/_dyld_register_func_for_remove_image to register callbacks for when an image is loaded/unloaded. That file's authors are Walter Bright and Sean Kelly. I don't see a reason the same technique can't be used to handle modules infos, tls, and the like.

It certainly could.  The current approach is used mostly because it works everywhere, weird OSX linker behavior notwithstanding.

> Looking at druntime makes me wonder why the initialization code is scattered everywhere... surely it'd be easier to figure out these kinds of problems if initialization was all happening in one place.

Better dynamic library support will probably mean integrating these two bits of code somehow.


More information about the phobos mailing list