Re: LuaJIT built statically segfaults when loading external module

  • From: Mike Pall <mike-1206@xxxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 7 Jun 2012 11:41:07 +0200

Vladimir Dronnikov wrote:
> The latest LuaJIT (2.0.0-beta10 and -beta9) built statically (express
> -static option in ultimate call to the linker) segfaults when loading
> an external module: `luajit -e foo`, e.g.
> 
> I tried that for both uClibc (0.32) and glibc (debian 6.0).
> I do need it linked statically because of target system has read-only
> root filesystem and I can't easily stuff libraries into there.
> 
> What could be the kludge to cope with the problem?

The dynamic library loader (-ldl) generally doesn't work with
static builds (some toolchains give you a warning if you try).
That is a known limitation and not specific to LuaJIT.

To work around this: set LJ_TARGET_DLOPEN to 0 in src/lj_arch.h.
And yes, this means you lose the ability to load any kind of
C module at runtime with require().

--Mike

Other related posts: