lights FAQ Forum

Native Code Generation


the Terra language

local terra = require'terra'

This is a slightly modified build of the Terra library which allows the Terra runtime to be loaded from Lua as a Lua/C module. The terra module exposes the complete Terra Lua API and installs a require() loader for loading .t files from the same locations that are used for loading Lua files.

NOTE: 32bit platforms are not yet supported (the included binaries work but there's no interfacing between Terra and Lua and no debug support).


Building terra requires llvm.


Bundling terra requires bunding in the llvm static libraries. There's a script documenting what these are that can be used with bundle directly:

bundle ... -a terra -a "$(csrc/terra/bundle-libs)"

Changes to terra

The source code changes made to terra were kept to a minimum to make it easy to to merge upstream changes back into the luapower terra fork. This is similar to how dynasm was modified for luapower. Anyway, the changelist:

  • the terra dynamic lib does not bundle luajit and is exposed as a Lua/C module.
  • terralib.lua and cudalib.lua are not bundled into the binary, and are provided separately.
  • strict.lua is not loaded and not included (it's included with luajit and must be loaded manually as needed).
  • std.t and parsing.t were renamed terra_std.t and terra_parsint.t. respectively and are now in the luapower dir along with all Lua files.
  • the location of clang's resource_dir is yet to be determined.

Last updated: 2 years ago | Edit on GitHub

Pkg type:Lua/C
Version: d17849a
Last commit:
License: MIT
Import ver: aa9501
Requires: luajit 
Required by: none