The DynamicLibrary.cpp code is written and I believe it to be complete, but it hasn't been tested much (at all). llvm-ld uses it to load its plug-in optimization module. The implementation will use ltdl library if its available, otherwise it tries to use dlopen/dlsym if they are available, otherwise you get a compile time warning and (void*)0 if you try to look up a symbol. I'm not sure about the libtool implementation but it does more than just accommodate the platform differences for the interface function names. It also makes sure that platform requirements for initialization of the loaded module, etc. are taken into account (e.g. static initialization of data in the shared object). I don't think we want to re-invent this, its nasty stuff. As for whether it solves the lookup of symbols starting with __, I'm unsure. You'd have to look at the ltdl implementation. Reid. On Sun, 2004-11-28 at 10:38, Chris Lattner wrote:> On Sun, 28 Nov 2004, Reid Spencer wrote: > > FYI .. if you want to see how this works, check out > > lib/System/DynamicLibrary.cpp and platform versions of it. > > Is it an option to use this interface now? How does libtool implement > dlsym on darwin if not through the obvious interface? Can we just use > whatever it uses? > > -Chris > > > On Sun, 2004-11-28 at 10:03, Reid Spencer wrote: > > > Well, one of these days we'll be using libltdl (libtool's dynamic > > > library support) to make the interface to dynamic libraries consistent, > > > somewhat portable, and to get rid of system specific differences like > > > this. > > > > > > Reid. > > > > > > On Sun, 2004-11-28 at 10:00, Chris Lattner wrote: > > > > Hi everyone, > > > > > > > > This is just a note to mention that the PowerPC JIT is now operational and > > > > begging for testing in mainline CVS. There is one known problem (below), > > > > but otherwise it works as well as the static PowerPC backend on the test > > > > suite. > > > > > > > > The known problem is that the JIT seems unable to resolve calls to > > > > external functions that start with "__", such as __eprintf, __moddi3, etc. > > > > This appears to be something funny in the darwin implementation of dlsym > > > > (returning null for symbols that are valid if they start with __). If > > > > anyone has any ideas of how to make this work, we would love to hear them. > > > > :) > > > > > > > > -Chris > > > > > > ______________________________________________________________________ > > > _______________________________________________ > > > LLVM Developers mailing list > > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > -Chris-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20041128/4317c628/attachment.sig>
On Sun, 28 Nov 2004, Reid Spencer wrote:> The DynamicLibrary.cpp code is written and I believe it to be complete, > but it hasn't been tested much (at all). llvm-ld uses it to load its > plug-in optimization module. The implementation will use ltdl library > if its available, otherwise it tries to use dlopen/dlsym if they are > available, otherwise you get a compile time warning and (void*)0 if you > try to look up a symbol.Okay, interesting. How hard would it be to replace the DynamicLinker.cpp functionality with your code?> I'm not sure about the libtool implementation but it does more than just > accommodate the platform differences for the interface function names. > It also makes sure that platform requirements for initialization of the > loaded module, etc. are taken into account (e.g. static initialization > of data in the shared object). I don't think we want to re-invent this, > its nasty stuff. As for whether it solves the lookup of symbols > starting with __, I'm unsure. You'd have to look at the ltdl > implementation.It looks like it uses the darwin dylib interfaces directly instead of going through the dlsym compatibility layer darwin provides. This might do exactly what we want. -Chris> > On Sun, 28 Nov 2004, Reid Spencer wrote: > > > FYI .. if you want to see how this works, check out > > > lib/System/DynamicLibrary.cpp and platform versions of it. > > > > Is it an option to use this interface now? How does libtool implement > > dlsym on darwin if not through the obvious interface? Can we just use > > whatever it uses? > > > > -Chris > > > > > On Sun, 2004-11-28 at 10:03, Reid Spencer wrote: > > > > Well, one of these days we'll be using libltdl (libtool's dynamic > > > > library support) to make the interface to dynamic libraries consistent, > > > > somewhat portable, and to get rid of system specific differences like > > > > this. > > > > > > > > Reid. > > > > > > > > On Sun, 2004-11-28 at 10:00, Chris Lattner wrote: > > > > > Hi everyone, > > > > > > > > > > This is just a note to mention that the PowerPC JIT is now operational and > > > > > begging for testing in mainline CVS. There is one known problem (below), > > > > > but otherwise it works as well as the static PowerPC backend on the test > > > > > suite. > > > > > > > > > > The known problem is that the JIT seems unable to resolve calls to > > > > > external functions that start with "__", such as __eprintf, __moddi3, etc. > > > > > This appears to be something funny in the darwin implementation of dlsym > > > > > (returning null for symbols that are valid if they start with __). If > > > > > anyone has any ideas of how to make this work, we would love to hear them. > > > > > :) > > > > > > > > > > -Chris > > > > > > > > ______________________________________________________________________ > > > > _______________________________________________ > > > > LLVM Developers mailing list > > > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > > > > > > -Chris >-Chris -- http://llvm.org/ http://nondot.org/sabre/
On Sun, 2004-11-28 at 10:56, Chris Lattner wrote:> Okay, interesting. How hard would it be to replace the DynamicLinker.cpp > functionality with your code?Not hard. That's just one of the many lib/System things on my plate for 1.5. If you want to do it now, that would be fine. There's only a few places DynamicLinker.cpp is used.> It looks like it uses the darwin dylib interfaces directly instead of > going through the dlsym compatibility layer darwin provides. This might > do exactly what we want.I expect so. libltdl was designed to address exactly the problem we're having. Reid. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20041128/079e82fa/attachment.sig>