Skip to content

philanc/slua

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI

slua

A static build of Lua 5.4 for Linux, with a few extension libraries.

For convenience, a slua binary is provided for x86_64.

Preloaded libraries

Additional libraries are pre-loaded. They must be require()'d before use.

  • luazen, a small library with LZMA compression and various crypto functions.
  • lualinux, a minimal binding to common Linux/Posix functions. -- see a list of lualinux available functions)
  • linenoise - slua is built on Linux with linenoise to replace readline. A limited Lua binding to linenoise is also provided to allow usage of linenoise in applications.

Extension mechanism

srlua by Luiz Henrique de Figueiredo (lhf@tecgraf.puc-rio.br) is included. As put by its author, this is a self-running Lua interpreter. It is meant to be combined with a Lua program into a single, stand-alone program that will execute the given Lua program when it is run.

It has been slightly modified:

  • srlua and its companion program srglue are statically built (do make srlua). They are used exactly as the original srlua and srglue. See for example the target srlua in the Makefile.

  • The additional slua libraries are also built in srlua.

  • srlua uses /proc/self/exe instead of argv[0] to find the executable program and read the embedded Lua code. It allows the program to be placed somewhere in $PATH and called by just its name from anywhere.

Static build

slua is linked completely statically. It uses no dynamic library, not even libc. So it can be used anywhere, whatever the platform dynamic linker and libraries versions. It is built with the Musl C library which allows a very compact executable.

It can be dropped and run from any directory, without interference with the local dynamic libraries and linker.

On the other end, obviously, slua cannot load dynamic C libraries. It is not intended to be a replacement for a full fledged Lua installation.

slua respects the environment variables LUA_PATH and LUA_CPATH.

Installation

The src directory includes all the required sources, so building slua doesn't require any external dependencies.

There is no installation. The slua executable is static. It can be placed and executed anywhere.

The default slua build procedure assumes that the C compiler is gcc and that musl libc is installed. It uses the musl-gcc wrapper.

With a recent Debian (or Ubuntu, Mint, ...) musl libc can be installed with

 sudo apt install  musl  musl-dev musl-tools

In that case, the makefile can be used as-is.

Other distributions may include musl packages. Alternatively musl libc can easily be built form source. See instructions at https://www.musl-libc.org/

If the musl-gcc wrapper is not accessible in $PATH, or if another toolchain is used, the makefile must be adjusted accordingly.

Then run 'make' at the root of the project tree:

  make

The default target buils the slua executable, the associated sluac Lua compiler, and srlua and its companion srglue (See "extension mechanism" above). All these programs are statically linked.

Pre-built binary

A binary version of slua is provided here for convenience. This is a standalone executable, statically compiled with musl-1.2.2 for Linux x86_64.

Package versions

lua-5.4.3 - http://www.lua.org/ftp/lua-5.4.3.tar.gz

luazen-2.1 - https://github.com/philanc/luazen

lualinux-0.3 - https://github.com/philanc/lualinux

linenoise - The full readline library is not used. It is replaced by the much smaller linenoise library. The linenoise implementation included here has been simplified to keep only functions used by the Lua REPL and extended to include a Lua binding. It is derived from Linenoise v1.0 - commit 027dbce - https://github.com/antirez/linenoise

Modifications of the vanilla Lua

lua.c is not used. It is replaced with src/slua.c. The only differences between lua.c and slua.c are the replacement of the readline interface with linenoise, and the addition of the preloaded libraries (look for "preloaded libraries", close to the end of slua.c)

License and credits

Lua and all extension libraries are distributed under the terms of their respective licenses (MIT or equivalent - see in the ./src directory).

I am of course grateful to the PUC-Rio team for the great Lua language.

The built-in libraries include some code from various authors:

slua itslef and the library bindings are distributed under the MIT License (see file LICENSE)

Copyright (c) 2022 Phil Leblanc

About

A static build of Lua for Linux, with compression and crypto built-in

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages