From e34db5a5680d96ea2effeea29114b390af74ce46 Mon Sep 17 00:00:00 2001 From: Alexei Robyn Date: Sat, 23 Mar 2019 16:21:37 +1100 Subject: [PATCH] luajit: Expose build options, enable JIT debug module --- .../interpreters/luajit/default.nix | 50 +++++++++++++++---- 1 file 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; } -