lua-nginx-module icon indicating copy to clipboard operation
lua-nginx-module copied to clipboard

Configuration isn't checking whether the LuaJIT libraries exist in the given paths on Linux

Open pantherman594 opened this issue 5 years ago • 5 comments

I'm trying to configure and build ngx_lua with ./configure --with-compat --add-dynamic-module=../lua-nginx-module-0.10.16rc4/, but it is unable to automatically find LuaJIT, and fails the LuaJIT 2.x check with error: unsupported LuaJIT version; ngx_http_lua_module requires LuaJIT 2.x..

It seems like it's not running any of the "auto-discovery" checks, which I believe is because $ngx_found is still "yes" from the previous check. This can be fixed by removing the if statement around the first check in that else block, "LuaJIT library in /usr/local/", or explicitly setting $ngx_found to no.

Even with that change, it passes the first check, even though LuaJIT is installed in /usr/, not /usr/local/. I don't think it ever checks if the LuaJIT libraries exist in the paths. This is true when LUAJIT_LIB and LUAJIT_INC were provided explicitly as well, with paths that do not exist:

configuring additional dynamic modules
adding module in ../lua-nginx-module-0.10.16rc4/
checking for LuaJIT library in /dkfjd and /asdfdsf (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl) ... found
checking for LuaJIT 2.x ... not found
    ./configure: error: unsupported LuaJIT version; ngx_http_lua_module requires LuaJIT 2.x.

or compiling as a standard (not dynamic) module with LUAJIT_INC=/asdfdsf LUAJIT_LIB=/dkfjd ./configure --with-ld-opt="-Wl,-rpath,/usr/lib" --add-module=../lua-nginx-module-0.10.16rc4/:

configuring additional modules
adding module in ../lua-nginx-module-0.10.16rc4/
checking for LuaJIT library in /dkfjd and /asdfdsf (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl) ... found
checking for LuaJIT 2.x ... not found
    ./configure: error: unsupported LuaJIT version; ngx_http_lua_module requires LuaJIT 2.x.

I fixed this by changing line 7 from ngx_feature_incs= to ngx_feature_incs="#include <lauxlib.h>", which I believe was removed in a96e99ab1a770d261fa9eecbd9c7d112f39aa34b and added it back like it is now in 315330ac099a35f5f17a0d453b7c001fe1181148.

Looking at the ngx_feature_libs in the explicit section, it also appears that the ones in the auto discovery section should have -L/usr/local/include/luajit-2.0 / -L/usr/include/luajit-2.0 instead of -L/usr/local/lib / -L/usr/lib

It also doesn't automatically check for LuaJIT 2.1 at all.

Build Environment: ngx_lua v0.10.16rc4 nginx 1.17.9 luajit 2.0.5-2 (I have also tried luajit 2.1 0ad60cc and https://github.com/openresty/luajit2/commit/38cb695de87cfeadcba5eeaf57f39e41d529aa1f, with the same results) gcc 9.2.1 20200130

pantherman594 avatar Mar 06 '20 08:03 pantherman594

Hello, First of all thanks for the leads. I thought, I've got the same issue, but no. Compiled LuaJIT 2.0.5 in a temporary location, didn't install it to the system.

LUAJIT_LIB="/tmp/luajit/lib" LUAJIT_INC="/tmp/luajit/include/luajit-2.0" ./configure --prefix=/opt/nginx
...
adding module in ../lua-nginx-module
checking for LuaJIT library in /tmp/luajit/lib and /tmp/luajit/include/luajit-2.0 (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl) ... found
adding extra linking options needed by LuaJIT on x86_64
checking for LuaJIT 2.x ... found
checking for Lua language 5.1 ... found

I think this line is misleading:

checking for LuaJIT library in /tmp/luajit/lib and /tmp/luajit/include/luajit-2.0 (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl) ... found

pavelkim avatar Apr 03 '20 08:04 pavelkim

i solved it by specifying LUAJIT_LIB and LUAJIT_INC explicitly in the config file (at the variable initialisation)

LUAJIT_INC="/path/to/luajit/include/luajit-2.1" LUAJIT_LIB="/path/to/luajit//lib"

and it installed

anil-venkata avatar Nov 30 '20 06:11 anil-venkata

What's the path going to be on Debian / Ubuntu? Sad this is still open and not yet resolved.

sharmashivanand avatar Feb 03 '22 17:02 sharmashivanand

i solved it by specifying LUAJIT_LIB and LUAJIT_INC explicitly in the config file (at the variable initialisation)

LUAJIT_INC="/path/to/luajit/include/luajit-2.1" LUAJIT_LIB="/path/to/luajit//lib"

and it installed

this worked for me as well

peterreji avatar Mar 28 '22 09:03 peterreji