Trying to compile Lua code with luajit for openresty

200 views
Skip to first unread message

Siddharth Chhabra

unread,
Mar 30, 2022, 1:46:56 PM3/30/22
to openre...@googlegroups.com
Hi
I have a large lua codebase which works perfectly fine.
The code is kept across a couple of directories for ease of use and management.
It also includes a couple of open source lua modules.
I used the code mentioned here to compile the lua code by luajit - 
for f in *.lua; do
    luajit -b $f `basename $f .lua`.o
done
ar rcus libmyluafiles.a *.o
And had a couple of questions:
1. After building the .a and trying to link it I am seeing errors like below
/buildroot/lua/lib/libluafiles.a(upstream_health.o):(.rodata+0x0): multiple definition of `luaJIT_BC_upstream_health'
/buildroot/lua/lib/libluafiles.a(upstream_health.o):(.rodata+0x0): first defined here
/usr/bin/ld: Warning: size of symbol `luaJIT_BC_upstream_health' changed from 2381 in /buildroot/lua/lib/libluafiles.a(upstream_health.o) to 1445 in 
This is happening since I have upstream_health.lua defined in 2 different folders and they  seem to be clashing.
1.a. Do I have to rename one of the files to something else for it to work (Doesnt luajit bytecode have the directory/module name in there for them to be distinguishable as 2 separate entities)?
On the above link it states that if I have to use a "foo.bar" in the require lua statement then I should be renaming that file to foo_bar.lua, so 
1.b. what should I do if the file already has an "_" in the name ?
1.c. Do I have to rename all the files in my directory structure and third party modules with "_" as opposed to directories ? 
1.d. And also rename filenames with "_" to a hypen so that luajit doesnt get confused?


2. Also once .a is properly linked with the resty module can I get rid of these directives 
#lua_package_path "/nginx/lua/?.lua;;";
#lua_package_cpath "/nginx/luac/?.so;;";
Any help or experience with this would be really appreciated.
Thanks



Reply all
Reply to author
Forward
0 new messages