2020-04-18 08:10:42 +01:00
|
|
|
{ stdenv, fetchFromGitHub, buildPackages
|
2019-01-30 14:13:15 +00:00
|
|
|
, name ? "luajit-${version}"
|
|
|
|
, isStable
|
|
|
|
, sha256
|
2020-04-18 08:10:42 +01:00
|
|
|
, rev
|
2019-01-30 14:13:15 +00:00
|
|
|
, version
|
|
|
|
, extraMeta ? {}
|
|
|
|
, callPackage
|
|
|
|
, self
|
|
|
|
, packageOverrides ? (self: super: {})
|
2019-03-23 05:21:37 +00:00
|
|
|
, enableFFI ? true
|
|
|
|
, enableJIT ? true
|
|
|
|
, enableJITDebugModule ? enableJIT
|
2020-10-01 05:41:13 +01:00
|
|
|
, enableGC64 ? true
|
2019-03-23 05:21:37 +00:00
|
|
|
, enable52Compat ? false
|
|
|
|
, enableValgrindSupport ? false
|
|
|
|
, valgrind ? null
|
|
|
|
, enableGDBJITSupport ? false
|
|
|
|
, enableAPICheck ? false
|
|
|
|
, enableVMAssertions ? false
|
|
|
|
, useSystemMalloc ? false
|
2019-01-30 14:13:15 +00:00
|
|
|
}:
|
2019-03-23 05:21:37 +00:00
|
|
|
assert enableJITDebugModule -> enableJIT;
|
|
|
|
assert enableGDBJITSupport -> enableJIT;
|
|
|
|
assert enableValgrindSupport -> valgrind != null;
|
2019-01-30 14:13:15 +00:00
|
|
|
let
|
|
|
|
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
|
2019-03-23 05:21:37 +00:00
|
|
|
|
|
|
|
XCFLAGS = with stdenv.lib;
|
|
|
|
optional (!enableFFI) "-DLUAJIT_DISABLE_FFI"
|
|
|
|
++ optional (!enableJIT) "-DLUAJIT_DISABLE_JIT"
|
|
|
|
++ optional enable52Compat "-DLUAJIT_ENABLE_LUA52COMPAT"
|
2020-04-18 08:10:42 +01:00
|
|
|
++ optional (!enableGC64) "-DLUAJIT_DISABLE_GC64"
|
2019-03-23 05:21:37 +00:00
|
|
|
++ 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"
|
|
|
|
;
|
2019-01-30 14:13:15 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
inherit name version;
|
2020-04-18 08:10:42 +01:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "LuaJIT";
|
|
|
|
repo = "LuaJIT";
|
|
|
|
inherit sha256 rev;
|
2019-01-30 14:13:15 +00:00
|
|
|
};
|
2013-11-15 16:20:29 +00:00
|
|
|
|
2019-01-30 14:13:15 +00:00
|
|
|
luaversion = "5.1";
|
2013-11-15 16:20:29 +00:00
|
|
|
|
2019-02-21 09:35:42 +00:00
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile --replace ldconfig :
|
2019-03-23 05:21:37 +00:00
|
|
|
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
|
2019-01-30 14:13:15 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
configurePhase = false;
|
2013-11-15 16:20:29 +00:00
|
|
|
|
2019-03-23 05:21:37 +00:00
|
|
|
buildInputs = stdenv.lib.optional enableValgrindSupport valgrind;
|
|
|
|
|
|
|
|
buildFlags = [
|
|
|
|
"amalg" # Build highly optimized version
|
|
|
|
];
|
2019-02-21 09:35:42 +00:00
|
|
|
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"
|
2019-03-23 05:21:37 +00:00
|
|
|
] ++ stdenv.lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)";
|
2019-01-30 14:13:15 +00:00
|
|
|
enableParallelBuilding = true;
|
2019-03-23 05:21:37 +00:00
|
|
|
NIX_CFLAGS_COMPILE = XCFLAGS;
|
2019-01-30 14:13:15 +00:00
|
|
|
|
2019-02-21 09:35:42 +00:00
|
|
|
postInstall = ''
|
2019-03-23 05:21:37 +00:00
|
|
|
( cd "$out/include"; ln -s luajit-*/* . )
|
|
|
|
ln -s "$out"/bin/luajit-* "$out"/bin/lua
|
|
|
|
'' + stdenv.lib.optionalString (!isStable) ''
|
|
|
|
ln -s "$out"/bin/luajit-* "$out"/bin/luajit
|
|
|
|
'';
|
2019-01-30 14:13:15 +00:00
|
|
|
|
|
|
|
LuaPathSearchPaths = [
|
|
|
|
"lib/lua/${luaversion}/?.lua" "share/lua/${luaversion}/?.lua"
|
|
|
|
"share/lua/${luaversion}/?/init.lua" "lib/lua/${luaversion}/?/init.lua"
|
|
|
|
"share/${name}/?.lua"
|
|
|
|
];
|
|
|
|
LuaCPathSearchPaths = [ "lib/lua/${luaversion}/?.so" "share/lua/${luaversion}/?.so" ];
|
|
|
|
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
|
|
|
|
|
|
|
|
passthru = rec {
|
|
|
|
buildEnv = callPackage ../lua-5/wrapper.nix {
|
|
|
|
lua = self;
|
|
|
|
inherit (luaPackages) requiredLuaModules;
|
|
|
|
};
|
|
|
|
withPackages = import ../lua-5/with-packages.nix { inherit buildEnv luaPackages;};
|
|
|
|
pkgs = luaPackages;
|
|
|
|
interpreter = "${self}/bin/lua";
|
2014-04-09 03:15:55 +01:00
|
|
|
};
|
2017-07-07 09:44:33 +01:00
|
|
|
|
2019-10-13 12:57:48 +01:00
|
|
|
meta = with stdenv.lib; {
|
2017-07-10 13:07:54 +01:00
|
|
|
description = "High-performance JIT compiler for Lua 5.1";
|
2020-04-01 02:11:51 +01:00
|
|
|
homepage = "http://luajit.org";
|
2017-07-10 13:07:54 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2020-08-06 14:33:38 +01:00
|
|
|
maintainers = with maintainers; [ thoughtpolice smironov vcunat andir lblasc ];
|
2019-10-13 12:57:48 +01:00
|
|
|
} // extraMeta;
|
2013-11-15 16:20:29 +00:00
|
|
|
}
|