Lua for Debian needs help

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Lua for Debian needs help

Eduardo Ochs-2
Hi people,

I'm trying to release a new version of the Debian package of Lua
4.0, but I'm stuck with an error concerning dynamic linking...

Here's the whole story. For personal reasons I wanted to have a Lua
with a "loadlib" function that would let me link with ".so"s
containing new Lua functions; so I took the "loadlib.c" file of cgilua
and created another Lua library file, "libdllua.so", with it, and
another binary, "dllua", that links with that library and registers
its functions.

Note: loadlib.c needs the functions dlopen, dlsym and dlclose, that
live in libdl. If I had just added loadlib.c to liblualib then
everybody would have to use "gcc -llua -llualib -ldl" instead of
"gcc -llua -llualib" and that would make compilation scripts would
crash. That's why I had to create an extra library and an extra
binary.

But my "dllua" was segfaulting at very simple Lua programs, and when I
tried to find what was wrong I discovered that its list of libraries
to link with was severely brain-damaged:

/usr/src/lua-4.0/debian/tmp-lua/usr# ldd bin/lua bin/dllua
bin/lua:
        liblua.so => /usr/lib/liblua.so (0x40021000)
        liblualib.so => /usr/lib/liblualib.so (0x40032000)
        libm.so.6 => /lib/libm.so.6 (0x40040000)
        libc.so.6 => /lib/libc.so.6 (0x4005d000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
bin/dllua:
        libdl.so.2 => /lib/libdl.so.2 (0x40021000)
        libm.so.6 => /lib/libm.so.6 (0x40024000)
        libc.so.6 => /lib/libc.so.6 (0x40042000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

and when I tried to discover the causes for that I got brain-damaged
too: I can't figure out why in some cases gcc creates a binary with
the right DL info and in some cases it doesn't (tee the output of
creating the package with "debian/rules binary" and search for "dllua"
and "ldd" to see what I'm talking about) and why stripping seems to
drops DL information.

I need help.

P.S.: I have sent this message:

  http://lists.debian.org/debian-mentors-0107/msg00253.html

to a Debian list but got no answer yet.

Cheers,
  Eduardo Ochs
  http://angg.twu.net/
  [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Lua for Debian needs help

Tomas Guisasola Gorham-2
> Here's the whole story. For personal reasons I wanted to have a Lua
> with a "loadlib" function that would let me link with ".so"s
> containing new Lua functions; so I took the "loadlib.c" file of cgilua
> and created another Lua library file, "libdllua.so", with it, and
> another binary, "dllua", that links with that library and registers
> its functions.
	I made something like that and it's working perfectly!
It was a merge of lua.c and cgilua's makefile (just to link loadlib
statically).  I'll put a copy of the package in a few minutes at:

http://www.tecgraf.puc-rio.br/~tomas/lual

	The package is distributed with some other libraries (md5,
luasocket, luasql and poslib).  Take a look!

	Tomas


Reply | Threaded
Open this post in threaded view
|

Re: Lua for Debian needs help

Eduardo Ochs-2
In reply to this post by Eduardo Ochs-2
Hi,

> I'm trying to release a new version of the Debian package of Lua
> 4.0, but I'm stuck with an error concerning dynamic linking...
>
> Here's the whole story. For personal reasons I wanted to have a Lua
> with a "loadlib" function that would let me link with ".so"s
> containing new Lua functions; so I took the "loadlib.c" file of cgilua
> and created another Lua library file, "libdllua.so", with it, and
> another binary, "dllua", that links with that library and registers
> its functions.
>
> ...
>
> But my "dllua" was segfaulting at very simple Lua programs, and when I
> tried to find what was wrong I discovered that its list of libraries
> to link with was severely brain-damaged:
>
> ...
>
> and when I tried to discover the causes for that I got brain-damaged
> too: I can't figure out why in some cases gcc creates a binary with
> the right DL info and in some cases it doesn't (tee the output of
> creating the package with "debian/rules binary" and search for "dllua"
> and "ldd" to see what I'm talking about) and why stripping seems to
> drops DL information.

Some hours ago my brain damage went away (thanks to the good vibes of
the people of the list:) and I was able to spot the error and fix
it... if someone is curious, it was just that I wasn't deleting the
bin/dllua that was generated by "make all" (and that used the ".a"
libraries, not the ".so"s), and so "make sobin" didn't try to generate
another dllua that used the ".so"s.

Now there's a working (AFAIK) source package of Lua-4.0 in
http://angg.twu.net/tmp/. Quick installation instructions:

  apt-get install texinfo yada

  cd ~/tmp/
  wget http://angg.twu.net/tmp/lua_4.0-0.2.dsc
  wget http://angg.twu.net/tmp/lua_4.0-0.2.diff.gz
  wget http://angg.twu.net/tmp/lua_4.0.orig.tar.gz

  rm -Rv /usr/src/lua*
  cd /usr/src/
  dpkg-source -sn -x ~/tmp/lua_4.0-0.2.dsc

  cd /usr/src/lua-4.0/
  yada yada; yada rebuild rules
  dpkg-buildpackage -b -rfakeroot -us -uc

  # as root:
  dpkg -i /usr/src/lua_4.0-0.2_i386.deb

I'll try to make the package a bit more official in the next days, by
adding it to my Debian repository, creating a page on Lua with better
instructions, etc. I'm also planning to write some simple examples of
use of "loadlib", but that will go only in 4.0-0.3.

Cheers,
  Eduardo Ochs
  http://angg.twu.net/
  [hidden email]


P.S.: Thanks to all that have tried to help... and hey Tomas, the URL
that you gave me points to an empty directory, so I couldn't use your
Makefile because it wasn't there.