lights FAQ Forum   github.com/luapower/luajit
luajit

Runtimes
luajit

luajit

LuaJIT binary


What

LuaJIT binaries (frontend, static library, dynamic library).

Comes bundled with the luajit and luajit32 commands, which are simple shell scripts that find and load the appropriate luajit executable for your platform/arch, so that typing ./luajit or ./luajit32 (that's luajit and luajit32 on Windows) always works.

LuaJIT was compiled using its own makefile.

NEW! You can now browse the LuaJIT source code and the DynASM source code online. The html is updated daily from the github mirror which is updated hourly.

Making portable apps

To make portable apps that run from any directory, every subsystem that ultimately opens a file must look for that file in a location relative to the app's directory. This means at least three things:

  • Lua's require() must look in exe-relative dirs first,
  • the OS's shared library loader must look in exe-relative dirs first,
  • the app itself must look for assets, config files, etc. in exe-relative dirs first.

The solutions for the first two problems are platform-specific and are described below. As for the third problem, you can extract the exe's path from arg[-1]. To get the location of the running script, as opposed to that of the executable, use glue.bin. To add more paths to package.path and package.cpath at runtime, use glue.luapath and glue.cpath.

Finding Lua modules

Windows

!\..\..\?.lua;!\..\..\?\init.lua was added to the default package.path in luaconf.h. This allows luapower modules to be found regardless of what the current directory is, making the distribution portable.

The default package.cpath was also modified from !\?.dll to !\clib\?.dll. This is to distinguish between Lua/C modules and other binary dependencies.

Linux and OSX

In Linux and OSX, luajit is a shell wrapper script that sets LUA_PATH and LUA_CPATH to acheive the same effect and assure isolation from system libraries.

The current directory

Lua modules (including Lua/C modules) searched for in the current directory first (on any platform), so the isolation from the host system is not absolute.

This is the Lua's default setting and although it's arguably a security risk, it's convenient for when you want to have a single luapower tree, possibly added to the system PATH, to be shared between many apps. In this case, starting luajit in the directory of the app makes the app's modules accessible automatically.

Finding shared libraries

Windows

Windows looks for dlls in the directory of the executable first by default, and that's where the luapower dlls are, so isolation from system libraries is acheived automatically in this case.

Linux

Linux binaries are built with rpath=$ORIGIN which makes ldd look for shared objects in the directory of the exe first.

OSX

OSX binaries are built with rpath=@loader_path which makes the dynamic loader look for dylibs in the directory of the exe first.

The current directory

The current directory is not used for finding shared libraries on Linux and OSX. It's only used on Windows, but has lower priority than the exe's directory (except on WinXP before SP2 where it has higher priority).

Finding terra modules

Windows

TODO

Linux and OSX

The luajit wrapper sets TERRA_PATH just like it sets LUA_PATH, so terra files are searched for in the same directories as Lua files.


Last updated: 2 years ago | Edit on GitHub

Pkg type:Lua
Version: 2.1.0-beta2-4-g336d420
Last commit:
License: MIT
Import ver: 2.1.0-beta2
Requires: none
Required by: bitmap  blake2  blur  bmp  bundle  cairo  cbframe  chipmunk  clipper  crc32  dynasm  expat  fbclient  ffi_reflect  freetype  fribidi  genx  giflib  glue  harfbuzz  hmac  hpdf  hunspell  libb64  libcurl  libexif  libjpeg  libogg  libpng  libsoundio  libunibreak  libvlc  libvorbis  luapower  luastate  md4  md5  minizip  mmap  murmurhash3  mysql  nanojpeg  nw  obj_parser  opengl  openvg  pmurhash  portaudio  pthread  ringbuffer  sg  sha2  stdio  terra  thread  time  ucdn  xxhash  zlib  codedit  path2d  socketloop  svg_parser  unit  utf8  bnet  cjson  cplayer  glut  lanes  lfs  lpeg  socket  struct  vararg  winapi  lfrb  libsodium  shm  syscall  xlib  objc  syscall  videoinput 

Top