Package Details: mingw-w64-luajit-2.1 2.1.0.beta3-3

Git Clone URL: https://aur.archlinux.org/mingw-w64-luajit-2.1.git (read-only, click to copy)
Package Base: mingw-w64-luajit-2.1
Description: Just-in-time compiler and drop-in replacement for Lua 5.1
Upstream URL: http://luajit.org/
Licenses: MIT
Conflicts: mingw-w64-luajit
Provides: mingw-w64-luajit
Submitter: edub4rt
Maintainer: edub4rt
Last Packager: edub4rt
Votes: 0
Popularity: 0.000000
First Submitted: 2017-11-24 14:01 (UTC)
Last Updated: 2020-05-23 16:41 (UTC)

Latest Comments

Jarcode commented on 2022-06-19 23:24 (UTC)

In addition to UncombedCoconut's comments, there's a much more annoying issue with this particular version of LuaJIT: luajit bytecode is incompatible with the native luajit package. This might seem confusing, since they are both versioned at 2.1, but the author has since abandoned versioned releases and has broken bytecode compatibility since the last release (beta3-3).

There a couple ways around this issue:

  • run the version of luajit.exe that this package compiles (but does not include in the final package for some reason) through wine to produce compatible bytecode for Windows

  • do not distribute lua bytecode with Windows builds of your software and only distribute sources instead

  • use the same version of luajit for both Linux and Windows builds of your software. This means you either need to downgrade the native version on your machine to match this AUR package, or update the AUR package to the same commit used by the official arch package

I have opted for the last option which required altering the PKGBUILD accordingly for this MinGW package:

# Maintainer: edub4rt <edub4rt@gmail.com>
pkgname=mingw-w64-luajit-2.1
_commit=68bb11405ce8b6356cb90dac010b5c87b933bbab
pkgver="2.1.0.beta3.r411.g${_commit::8}"
pkgrel=1
pkgdesc='Just-in-time compiler and drop-in replacement for Lua 5.1'
arch=('i686' 'x86_64')
url='http://luajit.org/'
license=('MIT')
depends=(mingw-w64-crt)
makedepends=(mingw-w64-gcc patch)
conflicts=('mingw-w64-luajit')
provides=('mingw-w64-luajit')
source=("LuaJIT-${_commit}.tar.gz::https://repo.or.cz/luajit-2.0.git/snapshot/${_commit}.tar.gz"
        001-make-import-library.patch
        002-fix-pkg-config-file.patch)
sha256sums=('49ab008c5775982e426e7179cf4701125d37109a6687d69ccd4ab64d4d14dcf8')
options=(!strip !buildflags staticlibs)

_targets="i686-w64-mingw32 x86_64-w64-mingw32"

prepare() {
  cd "luajit-2.0-${_commit::7}"
  # patch -b -p1 -i ${srcdir}/001-make-import-library.patch
  patch -b -p1 -i ${srcdir}/002-fix-pkg-config-file.patch
}

build() {
  unset LDFLAGS

  for _target in ${_targets}; do
    mkdir -p ${srcdir}/luajit-build-${_target} && cd ${srcdir}/luajit-build-${_target}
    cp -R $srcdir/luajit-2.0-${_commit::7}/* .
    cd src

    sed -i 's/^BUILDMODE= [a-z]*$/BUILDMODE= dynamic/' Makefile
    make clean
    if [ "$_target" == "i686-w64-mingw32" ]; then
        make PREFIX=/usr/$_target HOST_CC="gcc -m32" CROSS=${_target}- TARGET_SYS=Windows lua51.dll
    else
        make PREFIX=/usr/$_target HOST_CC="gcc -m64" CROSS=${_target}- TARGET_SYS=Windows lua51.dll
    fi
    cp lua51.dll ../

    sed -i 's/^BUILDMODE= [a-z]*$/BUILDMODE= static/' Makefile
    make clean
    if [ "$_target" == "i686-w64-mingw32" ]; then
        make PREFIX=/usr/$_target HOST_CC="gcc -m32" CROSS=${_target}- TARGET_SYS=Windows amalg
    else
        make PREFIX=/usr/$_target HOST_CC="gcc -m64" CROSS=${_target}- TARGET_SYS=Windows amalg
    fi
  done
}

package() {
  for _target in ${_targets}; do
      cd ${srcdir}/luajit-build-${_target}
      mkdir -p $pkgdir/usr/${_target}/{bin,lib}
      mkdir -p $pkgdir/usr/${_target}/include/luajit-2.1
      mkdir -p $pkgdir/usr/${_target}/lib/pkgconfig
      cp lua51.dll $pkgdir/usr/${_target}/bin/luajit-2.1.dll
      cp src/libluajit.a $pkgdir/usr/${_target}/lib/
      cp src/libluajit-5.1.dll.a $pkgdir/usr/${_target}/lib/libluajit-2.1.dll.a
      cp src/luajit.exe $pkgdir/usr/${_target}/bin/
      cp src/{lauxlib.h,lua.h,lua.hpp,luaconf.h,luajit.h,lualib.h} $pkgdir/usr/$_target/include/luajit-2.1/
      cp etc/luajit.pc "$pkgdir"/usr/${_target}/lib/pkgconfig/
      ${_target}-strip --strip-unneeded "$pkgdir"/usr/${_target}/bin/*.dll
      ${_target}-strip -g "$pkgdir"/usr/${_target}/lib/*.a
  done
}

Hope this is helpful to anyone dealing with cross-compilation woes.

UncombedCoconut commented on 2020-11-09 04:26 (UTC)

Hi! I noticed some issues with using the dynamic library in this package.

1: The LuaJIT install instructions [1] contain the phrasing "lua51.dll created by the LuaJIT build (do not rename the DLL)". Based on my testing, they are serious!! Binaries linked against luajit wind up containing references to "lua51.dll". Therefore, I think the package() function must be adjusted.
2: The installed pkgconfig file said "prefix=/usr/local" instead of "prefix=/usr/x86_64-w64-mingw32" (for example), so pkg-config unfortunately provides incorrect output.

While looking into this, I noticed the MSYS2 project had a very helpful PKGBUILD of its own. (It's for their Windows-based environment which happens to use Pacman, not Arch Linux, but its patches and the decisions in its package() seem to contain useful information!)

[1] https://luajit.org/install.html [2] https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-luajit

maxmitti commented on 2018-11-28 14:11 (UTC)

mingw-w64-gcc should be a dependency instead of gcc-multilib.

Also it should be a makedepend instead of a normal dependency, i guess.