unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH 0/5] Lua: enable shared library loading, build liblua.so
@ 2015-11-02 17:46 Leo Famulari
  2015-11-02 17:46 ` [PATCH 1/5] gnu: Remove tabulation from luajit Leo Famulari
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Leo Famulari @ 2015-11-02 17:46 UTC (permalink / raw)
  To: guix-devel

These patches do 4 things:
1) Build lua-5.1 and lua-5.2 so that they can load shared libraries.
2) Make the build process for lua-5.1 and lua-5.2 emit liblua.so.
3) Rewrite the build arguments to lua-5.1 and lua-5.2 for clarity.
4) Replace some tabs with spaces in the luajit package definition.

Things that still need to be done for Lua:
* Make a pkg-config .pc file for lua-5.1, or figure out if lua-5.2's can
  be re-used.
* Figure out the best way to find shared Lua libraries at runtime (nix
  uses 'makeWrapper', which I think is like 'wrap-program'. See the
  nixpkg for Prosody).

Details about changes:
1) Build lua-5.1 and lua-5.2 so that they can load shared libraries.

This involved making sure that the compiler gets some platform specific
instructions on how to load shared libraries. This wasn't happening
before.

2) Make the build process for lua-5.1 and lua-5.2 emit a working
liblua.so.

This involved adding the patch lua52-liblua-so.patch and applying it
from the lua-5.2 package definition. Lua-5.2's make-flags also had to be
altered to pass "-fPIC" to the linker.

For lua-5.1, I set the execute bit of liblua.so (it seems a convention
that Guix makes shared libraries executable). Also, I moved the
instruction that sets "-fPIC" from lua51-liblua-so.patch into the
package definition's make-flags. The lua-5.1 Makefile is not as general
as lua-5.2's and so the make-flags are a little messier.

Also, for lua-5.1, I regenerated lua51-liblua-so.patch rather than
patching the patch. A patched patch seems too difficult for humans to
understand.

3) Rewrite the build arguments to lua-5.1 and lua-5.2 to use
modify-phases and #:make-flags, which I think is much clearer than the
'alist-' procedures.

For lua-5.2, this change is separated into its own commit (49aea9d). I
didn't do this for lua-5.1 (3056c20) because I needed to alter
lua-5.1-liblua-so.patch, and git wouldn't separate those "hunks"
properly. If you want me to spend more time trying to split that commit
up, I will try.

4) Replace some tabs with spaces.

Leo Famulari (5):
  gnu: Remove tabulation from luajit.
  gnu: Build lua-5.2 with dynamic library support.
  gnu: Build lua-5.2 with a dynamic library
  gnu: Use make-flags and modify-phases for lua-5.2.
  gnu: Build lua-5.1 with dynamic library support and a dynamic library.

 gnu/packages/lua.scm                       | 46 ++++++++++--------
 gnu/packages/patches/lua51-liblua-so.patch | 53 ++++++++++++--------
 gnu/packages/patches/lua52-liblua-so.patch | 78 ++++++++++++++++++++++++++++++
 3 files changed, 139 insertions(+), 38 deletions(-)
 create mode 100644 gnu/packages/patches/lua52-liblua-so.patch

-- 
2.6.1

^ permalink raw reply	[flat|nested] 15+ messages in thread
* Re: [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support.
@ 2015-11-11  0:53 Leo Famulari
  2015-11-11 21:28 ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Leo Famulari @ 2015-11-11  0:53 UTC (permalink / raw)
  To: guix-devel

Forgot to send this to the list...

On Sun, Nov 8, 2015, at 16:08, Ludovic Courtès wrote:
> Leo Famulari <leo@famulari.name> 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)

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2015-12-14  6:23 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-02 17:46 [PATCH 0/5] Lua: enable shared library loading, build liblua.so Leo Famulari
2015-11-02 17:46 ` [PATCH 1/5] gnu: Remove tabulation from luajit Leo Famulari
2015-11-02 17:46 ` [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support Leo Famulari
2015-11-08 21:08   ` Ludovic Courtès
2015-12-14  6:23     ` Leo Famulari
2015-11-02 17:46 ` [PATCH 3/5] gnu: Build lua-5.2 with a dynamic library Leo Famulari
2015-11-08 21:12   ` Ludovic Courtès
2015-11-02 17:46 ` [PATCH 4/5] gnu: Use make-flags and modify-phases for lua-5.2 Leo Famulari
2015-12-13 16:24   ` Ludovic Courtès
2015-12-14  6:22     ` Leo Famulari
2015-11-02 17:46 ` [PATCH 5/5] gnu: Build lua-5.1 with dynamic library support and a dynamic library Leo Famulari
2015-12-13 16:27   ` Ludovic Courtès
2015-12-14  6:22     ` Leo Famulari
  -- strict thread matches above, loose matches on Subject: below --
2015-11-11  0:53 [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support Leo Famulari
2015-11-11 21:28 ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).