guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support.


From: Leo Famulari
Subject: Re: [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support.
Date: Tue, 10 Nov 2015 19:53:59 -0500

Forgot to send this to the list...

On Sun, Nov 8, 2015, at 16:08, Ludovic Courtès wrote:
> Leo Famulari <address@hidden> skribis:
> 
> > * gnu/packages/lua.scm (lua-5.2)[arguments]: Rewrite make-flags so that
> >   Lua is built with platform-specific instructions for shared library
> >   loading (dlopen).
> 
> Please move the explanations as a comment in the code.

Okay.
 
> >         #:phases (alist-replace
> >                   'build
> > -                 (lambda _ (zero? (system* "make" "CFLAGS=-fPIC" "linux")))
> > +                 (lambda _ (zero? (system* "make"
> > +                                           "PLAT=linux"
> > +                                           "MYCFLAGS=-fPIC"
> > +                                           "MYLDFLAGS=-fPIC")))
> 
> How can I test whether this works as expected?  I tried this, but I’m
> unsure whether it’s supposed to load OpenSSL’s libssl.so directly or
> not:

There is a Lua library named luasec that provides SSL. Luasec only
supports lua-5.1 except in an alpha release (luasec-0.6). [1]

I am able to load luasec by telling Lua where to look. I have lua-5.1
and luasec in my profile:

$ LUA_PATH=~/.guix-profile/share/lua/5.1/\?.lua
LUA_CPATH=~/.guix-profile/lib/lua/5.1/\?.so lua -lssl
Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio
> 
^ That is the Lua prompt, indicating that the Lua interpreter has
successfully imported the SSL libraries. The '?' character is replaced
by the component that Lua is currently searching for. So, if you invoke
`lua -ssl`,  the "?.so" in LUA_CPATH is replaced by ssl.so.

> Apologies in advance if I’m just asking stupid questions!

Not at all, everything I know about Lua I have learned trying to get
Prosody packaged for Guix. I am about 1 week ahead of you in terms of
Lua knowledge ;)

> Besides, it would be nice to get rid of these hard-coded /usr/local in a
> subsequent patch.

This is related to my next step and I need some advice.

We need to set LUA_PATH and LUA_CPATH properly in order for programs to
load external Lua libraries. I have been installing Lua libraries into
${out}/lib/lua/${LUA_VERSION} and ${out}/share/lua/${LUA_VERSION}, so
that they end up at, for example, ~/.guix-profile/lib/lua/5.1/ssl.so [2]

Nixpkgs makes it all work by setting the paths in wrappers around
programs that need to find Lua libraries. I don't fully understand how
they generate the paths but I get the idea. Some examples:
https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/xmpp/prosody/default.nix
https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/video/quvi/tool.nix

What do you think?

Leo 

[1] I have some of these packages defined in a WIP branch:
https://github.com/lfam/guix/commits/contrib-lua

[2]
bourne shell variable syntax (don't have paredit in my email client)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]