From af2839518ef448b37fd258d0158a8546f63c7246 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 26 Jan 2023 11:31:01 +0100 Subject: luajit: fix cross build for 32 bit architectures The 32bit compiler has to be used when building on 64bit system. --- pkgs/development/interpreters/luajit/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkgs/development/interpreters/luajit') diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix index 411220870e1a..8596e379e710 100644 --- a/pkgs/development/interpreters/luajit/default.nix +++ b/pkgs/development/interpreters/luajit/default.nix @@ -52,6 +52,15 @@ let ++ optional enableVMAssertions "-DLUAJIT_USE_ASSERT" ++ optional deterministicStringIds "-DLUAJIT_SECURITY_STRID=0" ; + + # LuaJIT requires build for 32bit architectures to be build on x86 not x86_64 + # TODO support also other build architectures. The ideal way would be to use + # stdenv_32bit but that doesn't work due to host platform mismatch: + # https://github.com/NixOS/nixpkgs/issues/212494 + buildStdenv = if buildPackages.stdenv.isx86_64 && stdenv.is32bit + then buildPackages.pkgsi686Linux.buildPackages.stdenv + else buildPackages.stdenv; + in stdenv.mkDerivation rec { pname = "luajit"; @@ -88,8 +97,7 @@ stdenv.mkDerivation rec { "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" + "HOST_CC=${buildStdenv.cc}/bin/cc" ] ++ lib.optional enableJITDebugModule "INSTALL_LJLIBD=$(INSTALL_LMOD)"; enableParallelBuilding = true; NIX_CFLAGS_COMPILE = XCFLAGS; -- cgit v1.2.3