pigpigyyy / Yuescript

A Moonscript dialect compiles to Lua.
http://yuescript.org
MIT License
443 stars 38 forks source link

Issue building Yuescript module against LuaJIT #169

Open Shados opened 3 months ago

Shados commented 3 months ago

I've been working on a Nix package for Yuescript's Lua module. What I have works fine when built against PUC-Rio Lua 5.1 or above, but fails when I attempt to build against LuaJIT:

yuescript 0.23.8-1 depends on lua >= 5.1 (5.1-1 provided by VM: success)
-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /nix/store/9bv7dcvmfcjnmg5mnqwqlq2wxfn8d7yi-gcc-wrapper-13.2.0/bin/g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Could NOT find Lua (missing: LUA_LIBRARIES) (found version "5.1.4")
-- Lua: /nix/store/iq8s1f6d5wjwy4k7dm24qa4jpa3iby54-luajit-2.1.1693350652/bin/luajit
-- Lua include: /nix/store/iq8s1f6d5wjwy4k7dm24qa4jpa3iby54-luajit-2.1.1693350652/include/luajit-2.1
-- Lua library: LUA_LIBRARIES-NOTFOUND
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Configuring done (0.4s)
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
LUA_LIBRARIES
    linked by target "yue" in directory /build/source
    linked by target "libyue" in directory /build/source
-- Generating done (0.0s)
CMake Warning:
  Manually-specified variables were not used by the project:
    CMAKE_INCLUDE_PATH
CMake Generate step failed.  Build files cannot be regenerated correctly.
Error: Build error: Failed cmake.

Based on CMakeLists.txt it looks like it should be looking for the library directory in ${LUA_INCDIR}/../lib ${LUA_INCDIR}/../../lib, and the latter exists and has the library file:

$ tree /nix/store/iq8s1f6d5wjwy4k7dm24qa4jpa3iby54-luajit-2.1.1693350652/include/luajit-2.1/../../lib
/nix/store/iq8s1f6d5wjwy4k7dm24qa4jpa3iby54-luajit-2.1.1693350652/include/luajit-2.1/../../lib
├── libluajit-5.1.a
├── libluajit-5.1.so -> libluajit-5.1.so.2.1.1693350652
├── libluajit-5.1.so.2 -> libluajit-5.1.so.2.1.1693350652
├── libluajit-5.1.so.2.1.1693350652
├── lua
│   └── 5.1
└── pkgconfig
    └── luajit.pc

4 directories, 5 files
pigpigyyy commented 3 months ago

Currently, in the CMakeLists.txt file, only the library file named libluajit.a or libluajit.so will be matched and stored in the variable LUA_LIBRARIES for build linking. You can try renaming or creating a symbolic link from libluajit-5.1.a to libluajit.a.

Shados commented 3 months ago

You can try renaming or creating a symbolic link from libluajit-5.1.a to libluajit.a.

Hmmm. It looks like LuaJIT started including the ABI version in the .so name 10 months ago when it officially swapped to being rolling-release. I guess you'll need to update your cmake setup for that going forward...?