2021-09-18 10:52:07 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, buildPackages
|
2020-04-24 23:36:52 +00:00
|
|
|
, name ? "luajit-${version}"
|
|
|
|
, isStable
|
2022-04-27 09:35:20 +00:00
|
|
|
, hash
|
2020-05-03 17:38:23 +00:00
|
|
|
, rev
|
2020-04-24 23:36:52 +00:00
|
|
|
, version
|
2021-09-18 10:52:07 +00:00
|
|
|
, extraMeta ? { }
|
2020-04-24 23:36:52 +00:00
|
|
|
, callPackage
|
|
|
|
, self
|
2021-09-18 10:52:07 +00:00
|
|
|
, packageOverrides ? (final: prev: {})
|
2020-04-24 23:36:52 +00:00
|
|
|
, enableFFI ? true
|
|
|
|
, enableJIT ? true
|
|
|
|
, enableJITDebugModule ? enableJIT
|
2020-10-07 09:15:18 +00:00
|
|
|
, enableGC64 ? true
|
2020-04-24 23:36:52 +00:00
|
|
|
, enable52Compat ? false
|
|
|
|
, enableValgrindSupport ? false
|
|
|
|
, valgrind ? null
|
|
|
|
, enableGDBJITSupport ? false
|
|
|
|
, enableAPICheck ? false
|
|
|
|
, enableVMAssertions ? false
|
|
|
|
, useSystemMalloc ? false
|
|
|
|
}:
|
|
|
|
assert enableJITDebugModule -> enableJIT;
|
|
|
|
assert enableGDBJITSupport -> enableJIT;
|
|
|
|
assert enableValgrindSupport -> valgrind != null;
|
|
|
|
let
|
2021-09-18 10:52:07 +00:00
|
|
|
luaPackages = callPackage ../../lua-modules { lua = self; overrides = packageOverrides; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
XCFLAGS = with lib;
|
2021-09-18 10:52:07 +00:00
|
|
|
optional (!enableFFI) "-DLUAJIT_DISABLE_FFI"
|
|
|
|
++ optional (!enableJIT) "-DLUAJIT_DISABLE_JIT"
|
|
|
|
++ optional enable52Compat "-DLUAJIT_ENABLE_LUA52COMPAT"
|
|
|
|
++ optional (!enableGC64) "-DLUAJIT_DISABLE_GC64"
|
|
|
|
++ optional useSystemMalloc "-DLUAJIT_USE_SYSMALLOC"
|
|
|
|
++ optional enableValgrindSupport "-DLUAJIT_USE_VALGRIND"
|
|
|
|
++ optional enableGDBJITSupport "-DLUAJIT_USE_GDBJIT"
|
|
|
|
++ optional enableAPICheck "-DLUAJIT_USE_APICHECK"
|
|
|
|
++ optional enableVMAssertions "-DLUAJIT_USE_ASSERT"
|
2020-04-24 23:36:52 +00:00
|
|
|
;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
inherit name version;
|
2020-05-03 17:38:23 +00:00
|
|
|
src = fetchFromGitHub {
|
2021-09-18 10:52:07 +00:00
|
|
|
owner = "LuaJIT";
|
|
|
|
repo = "LuaJIT";
|
2022-04-27 09:35:20 +00:00
|
|
|
inherit hash rev;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
luaversion = "5.1";
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile --replace ldconfig :
|
|
|
|
if test -n "''${dontStrip-}"; then
|
|
|
|
# CCDEBUG must be non-empty or everything will be stripped, -g being
|
|
|
|
# passed by nixpkgs CC wrapper is insufficient on its own
|
|
|
|
substituteInPlace src/Makefile --replace "#CCDEBUG= -g" "CCDEBUG= -g"
|
|
|
|
fi
|
2021-09-18 10:52:07 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
echo -e '
|
|
|
|
#undef LUA_PATH_DEFAULT
|
|
|
|
#define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua"
|
|
|
|
#undef LUA_CPATH_DEFAULT
|
|
|
|
#define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so"
|
|
|
|
'
|
|
|
|
} >> src/luaconf.h
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = false;
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
buildInputs = lib.optional enableValgrindSupport valgrind;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"amalg" # Build highly optimized version
|
|
|
|
];
|
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=$(out)"
|
|
|
|
"DEFAULT_CC=cc"
|
|
|
|
"CROSS=${stdenv.cc.targetPrefix}"
|
|
|
|
# TODO: when pointer size differs, we would need e.g. -m32
|
|
|
|
"HOST_CC=${buildPackages.stdenv.cc}/bin/cc"
|
2021-02-05 17:12:51 +00:00
|
|
|
] ++ lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)";
|
2020-04-24 23:36:52 +00:00
|
|
|
enableParallelBuilding = true;
|
|
|
|
NIX_CFLAGS_COMPILE = XCFLAGS;
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
( cd "$out/include"; ln -s luajit-*/* . )
|
|
|
|
ln -s "$out"/bin/luajit-* "$out"/bin/lua
|
2021-02-05 17:12:51 +00:00
|
|
|
'' + lib.optionalString (!isStable) ''
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s "$out"/bin/luajit-* "$out"/bin/luajit
|
|
|
|
'';
|
|
|
|
|
2021-09-18 10:52:07 +00:00
|
|
|
LuaPathSearchPaths = luaPackages.lib.luaPathList;
|
|
|
|
LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
|
|
|
|
|
|
|
|
setupHook = luaPackages.lua-setup-hook luaPackages.lib.luaPathList luaPackages.lib.luaCPathList;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
passthru = rec {
|
|
|
|
buildEnv = callPackage ../lua-5/wrapper.nix {
|
|
|
|
lua = self;
|
|
|
|
inherit (luaPackages) requiredLuaModules;
|
|
|
|
};
|
2021-09-18 10:52:07 +00:00
|
|
|
withPackages = import ../lua-5/with-packages.nix { inherit buildEnv luaPackages; };
|
2020-04-24 23:36:52 +00:00
|
|
|
pkgs = luaPackages;
|
|
|
|
interpreter = "${self}/bin/lua";
|
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "High-performance JIT compiler for Lua 5.1";
|
2021-09-18 10:52:07 +00:00
|
|
|
homepage = "http://luajit.org";
|
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2022-01-19 23:45:15 +00:00
|
|
|
maintainers = with maintainers; [ thoughtpolice smironov vcunat lblasc ];
|
2020-04-24 23:36:52 +00:00
|
|
|
} // extraMeta;
|
|
|
|
}
|