Skip to content

Rulua 1.0 — Lua 5.1, ported to Rust, binary-compatible with lua5.1.dll / .so / .dylib

Choose a tag to compare

@felipedaragon felipedaragon released this 27 Sep 14:21
· 3 commits to main since this release

First public release of Rulua, a port of the Lua 5.1 shared library to Rust. It is binary-compatible with the original PUC-Rio C library: it exports the complete Lua 5.1 C API (123 functions) with the same names and calling conventions, so existing programs and C modules built for Lua 5.1 load it without being recompiled.

Downloads

Platform Package Status
Windows x64 lua5.1-win64.zip in production use
Windows x86 (Win32) lua5.1-win32.zip tested (Windows 11 and Wine)
Windows ARM64 lua5.1-winarm64.zip preview: builds cleanly, not yet verified on ARM64 hardware
macOS Apple Silicon lua5.1-macos-arm64.tar.gz tested on real hardware (M3)
macOS Intel lua5.1-macos-x86_64.tar.gz tested on real hardware
Linux x86_64 lua5.1-linux-x86_64.tar.gz tested; needs glibc ≥ 2.28
Linux ARM64 lua5.1-linux-arm64.tar.gz tested (QEMU); needs glibc ≥ 2.28

Each package contains the library, import libraries (Windows) or headers, the stock lua interpreter linked to it, and a self-test. On Windows, packages also include a lua51.dll compatibility proxy.

Try it

Unpack and run the self-test. It compares the C API test output with the original PUC-Rio Lua 5.1.4:

run-tests.bat          (Windows)
./run-tests.sh         (macOS / Linux)

Add bench to also run the 26-test benchmark against the original interpreter.

Highlights

  • Full Lua 5.1 C API: C functions and closures, userdata with __gc, coroutines (including lua_yield from C), the debug API and hooks, and require of C modules.
  • Lua errors raised in C modules work with any compiler. On 32-bit Windows they use setjmp/longjmp like PUC-Rio, so modules built by MSVC or Delphi work too.
  • Verified by differential tests against PUC-Rio 5.1.4, plus the LPeg and lua-cjson test suites.
  • Performance: 1.5–2.4× slower than the original C Lua depending on the machine, and on Windows 1.24× faster than upstream rilua (up to 300× on very large strings).

Known differences

  • Language behaviour follows rilua, which targets Lua 5.1.1, so a few error messages are worded differently from 5.1.4.
  • PUC-Rio internal functions (luaD_*, luaH_*, …) are not provided. Only modules that bypass the public API use them.

See the README for details. Licensed under MIT OR Apache-2.0.