summaryrefslogtreecommitdiffstats
path: root/pkgs/development/interpreters/luajit
diff options
context:
space:
mode:
authorAlexei Robyn <shados@shados.net>2019-03-23 16:21:37 +1100
committerMatthieu Coudron <mattator@gmail.com>2020-02-15 18:40:02 +0100
commite34db5a5680d96ea2effeea29114b390af74ce46 (patch)
tree6a63024d761a4acae925ea708a460b57e39e2913 /pkgs/development/interpreters/luajit
parentbbb4a1be3d968e37bffc2aa218946d7d92e0b0a5 (diff)
luajit: Expose build options, enable JIT debug module
Diffstat (limited to 'pkgs/development/interpreters/luajit')
-rw-r--r--pkgs/development/interpreters/luajit/default.nix50
1 files changed, 41 insertions, 9 deletions
diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix
index 5b7761164472..08c0564847c5 100644
--- a/pkgs/development/interpreters/luajit/default.nix
+++ b/pkgs/development/interpreters/luajit/default.nix
@@ -7,9 +7,33 @@
, callPackage
, self
, packageOverrides ? (self: super: {})
+, enableFFI ? true
+, enableJIT ? true
+, enableJITDebugModule ? enableJIT
+, 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
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
+
+ XCFLAGS = with stdenv.lib;
+ optional (!enableFFI) "-DLUAJIT_DISABLE_FFI"
+ ++ optional (!enableJIT) "-DLUAJIT_DISABLE_JIT"
+ ++ optional enable52Compat "-DLUAJIT_ENABLE_LUA52COMPAT"
+ ++ 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"
+ ;
in
stdenv.mkDerivation rec {
inherit name version;
@@ -22,27 +46,36 @@ stdenv.mkDerivation rec {
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
'';
configurePhase = false;
+ buildInputs = stdenv.lib.optional enableValgrindSupport valgrind;
+
+ 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"
- ];
- buildFlags = [ "amalg" ]; # Build highly optimized version
+ ] ++ stdenv.lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)";
enableParallelBuilding = true;
+ NIX_CFLAGS_COMPILE = XCFLAGS;
postInstall = ''
- ( 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
- '';
+ ( 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
+ '';
LuaPathSearchPaths = [
"lib/lua/${luaversion}/?.lua" "share/lua/${luaversion}/?.lua"
@@ -70,4 +103,3 @@ stdenv.mkDerivation rec {
maintainers = with maintainers; [ thoughtpolice smironov vcunat andir ];
} // extraMeta;
}
-