digitalmars.D.announce - Tango built as a dynamic library
- Jacob Carlborg (25/25) Mar 16 2010 I've managed to build Tango as a dynamic library with DMD on Mac OS X. I...
- Steven Schveighoffer (5/30) Mar 16 2010 This is awesome! I would recommend that you should do Phobos 2 before
- Eldar Insafutdinov (2/36) Mar 16 2010 Thank you very much! I suppose there should not be a major problem to ma...
- Jacob Carlborg (4/40) Mar 17 2010 No I don't think so. I assume the same ideas can be applied to Linux as
- Walter Bright (6/9) Mar 16 2010 Thanks for doing this.
- Michel Fortin (8/19) Mar 16 2010 Shouldn't that also apply to TLS sections for when the linker does not
- Walter Bright (3/12) Mar 16 2010 Rainer Schuetze has found a way to work with the system TLS properly. It...
I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now. What I had to do to build it as a dynamic library was: Resolve the undefined symbol _Dmain. Remove the globals _deh_beg and _deh_end in the deh module and _minfo_beg and _minfo_end in the object module. The beg and end variables are for determine the beginning and the end of special sections in the binaries but they're not put into the dynamic library and therefore cause linker errors (undefined symbol). Get the module infos from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the object module) in the order they are loaded (the data from executable should be last in the array). Get all the exception handler tables from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the deh module) in the order they are loaded (the data from executable should be last in the array). Now when I thing about it what happens when a dynamic library built with GDC or LDC is linked with an executable built with DMD? I'm searing for specific segments and sections in the binaries that at least DMD puts there. The next step is to clean up the code, create a patch, add support for 64bit binaries and perhaps universal binaries (if that is needed). Then I'll do the same for Phobos 1 and 2. /Jacob Carlborg
Mar 16 2010
On Tue, 16 Mar 2010 06:59:19 -0400, Jacob Carlborg <doob me.com> wrote:I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now. What I had to do to build it as a dynamic library was: Resolve the undefined symbol _Dmain. Remove the globals _deh_beg and _deh_end in the deh module and _minfo_beg and _minfo_end in the object module. The beg and end variables are for determine the beginning and the end of special sections in the binaries but they're not put into the dynamic library and therefore cause linker errors (undefined symbol). Get the module infos from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the object module) in the order they are loaded (the data from executable should be last in the array). Get all the exception handler tables from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the deh module) in the order they are loaded (the data from executable should be last in the array). Now when I thing about it what happens when a dynamic library built with GDC or LDC is linked with an executable built with DMD? I'm searing for specific segments and sections in the binaries that at least DMD puts there. The next step is to clean up the code, create a patch, add support for 64bit binaries and perhaps universal binaries (if that is needed). Then I'll do the same for Phobos 1 and 2.This is awesome! I would recommend that you should do Phobos 2 before Phobos 1. Phobos 1 is pretty much dead wood IMO. I'm not even sure a patch would be accepted, since this modifies the runtime. -Steve
Mar 16 2010
Jacob Carlborg Wrote:I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now. What I had to do to build it as a dynamic library was: Resolve the undefined symbol _Dmain. Remove the globals _deh_beg and _deh_end in the deh module and _minfo_beg and _minfo_end in the object module. The beg and end variables are for determine the beginning and the end of special sections in the binaries but they're not put into the dynamic library and therefore cause linker errors (undefined symbol). Get the module infos from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the object module) in the order they are loaded (the data from executable should be last in the array). Get all the exception handler tables from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the deh module) in the order they are loaded (the data from executable should be last in the array). Now when I thing about it what happens when a dynamic library built with GDC or LDC is linked with an executable built with DMD? I'm searing for specific segments and sections in the binaries that at least DMD puts there. The next step is to clean up the code, create a patch, add support for 64bit binaries and perhaps universal binaries (if that is needed). Then I'll do the same for Phobos 1 and 2. /Jacob CarlborgThank you very much! I suppose there should not be a major problem to make it working on Linux as well?
Mar 16 2010
On 3/16/10 17:51, Eldar Insafutdinov wrote:Jacob Carlborg Wrote:No I don't think so. I assume the same ideas can be applied to Linux as well. I just don't know how to access the ModuleInfo and EH sections on Linux.I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now. What I had to do to build it as a dynamic library was: Resolve the undefined symbol _Dmain. Remove the globals _deh_beg and _deh_end in the deh module and _minfo_beg and _minfo_end in the object module. The beg and end variables are for determine the beginning and the end of special sections in the binaries but they're not put into the dynamic library and therefore cause linker errors (undefined symbol). Get the module infos from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the object module) in the order they are loaded (the data from executable should be last in the array). Get all the exception handler tables from the loaded executable and all the loaded dynamic libraries and collect them into one array (in the deh module) in the order they are loaded (the data from executable should be last in the array). Now when I thing about it what happens when a dynamic library built with GDC or LDC is linked with an executable built with DMD? I'm searing for specific segments and sections in the binaries that at least DMD puts there. The next step is to clean up the code, create a patch, add support for 64bit binaries and perhaps universal binaries (if that is needed). Then I'll do the same for Phobos 1 and 2. /Jacob CarlborgThank you very much! I suppose there should not be a major problem to make it working on Linux as well?
Mar 17 2010
Jacob Carlborg wrote:I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now.Thanks for doing this. In the next update, I plan to remove the special deh sections, and instead make the EH tables available through the ModuleInfo. This should simplify the management of multiple sections, as the only data structure that needs to be aggregated will be the ModuleInfo array.
Mar 16 2010
On 2010-03-16 15:01:43 -0400, Walter Bright <newshound1 digitalmars.com> said:Jacob Carlborg wrote:Shouldn't that also apply to TLS sections for when the linker does not support the feature? I'm thinking of Mac OS X and Windows XP with dynamically-loaded DLLs. -- Michel Fortin michel.fortin michelf.com http://michelf.com/I've managed to build Tango as a dynamic library with DMD on Mac OS X. I had some problems first but I managed to solve them and everything seems to work now.Thanks for doing this. In the next update, I plan to remove the special deh sections, and instead make the EH tables available through the ModuleInfo. This should simplify the management of multiple sections, as the only data structure that needs to be aggregated will be the ModuleInfo array.
Mar 16 2010
Michel Fortin wrote:On 2010-03-16 15:01:43 -0400, Walter Bright <newshound1 digitalmars.com> said:Rainer Schuetze has found a way to work with the system TLS properly. It's not the linker that's the problem, it's Windows systems earlier than Vista.In the next update, I plan to remove the special deh sections, and instead make the EH tables available through the ModuleInfo. This should simplify the management of multiple sections, as the only data structure that needs to be aggregated will be the ModuleInfo array.Shouldn't that also apply to TLS sections for when the linker does not support the feature? I'm thinking of Mac OS X and Windows XP with dynamically-loaded DLLs.
Mar 16 2010