[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: dependencies between C modules, RTLD_GLOBAL
- From: William Ahern <william@...>
- Date: Wed, 13 May 2015 16:23:17 -0700
On Wed, May 13, 2015 at 01:03:40PM -0700, Josh Haberman wrote:
> On Tue, May 12, 2015 at 7:16 PM, Jonathan Goble <jcgoble3@gmail.com> wrote:
> > On Tue, May 12, 2015 at 9:42 PM, Josh Haberman <jhaberman@gmail.com> wrote:
> >> Since package.loadlib bypasses require(), it seems like this approach
> >> will involve re-implementing the require() logic? Stuff like checking
> >> package.preload, splitting LUA_CPATH on ";", looking in each
> >> directory, etc?
> >
> > Yes, you'd have to check package.preload, but if not found there,
> > `package.searchpath(libname, package.cpath)` ought to return the
> > filename for passing to package.loadlib.
>
> I tried this out and it seems to work!
>
> One caveat: require() will load the module RTLD_LOCAL. On OS X at
> least, it appears that once you load a module as RTLD_LOCAL,
> subsequent loads as RTLD_GLOBAL don't appear to have any effect.
That's because Lua will only load the library once, regardless of the
scoping. As it's already been loaded before it won't call dlopen again with
RTLD_GLOBAL, but instead uses the cached handle.
See ll_loadfunc in the Lua 5.2 source and lookforfunc in the 5.3 source.
- References:
- dependencies between C modules, RTLD_GLOBAL, Josh Haberman
- Re: dependencies between C modules, RTLD_GLOBAL, Luiz Henrique de Figueiredo
- Re: dependencies between C modules, RTLD_GLOBAL, Josh Haberman
- Re: dependencies between C modules, RTLD_GLOBAL, Jonathan Goble
- Re: dependencies between C modules, RTLD_GLOBAL, Josh Haberman