Author Topic: LUA 5.2  (Read 8413 times)

0 Members and 1 Guest are viewing this topic.

Offline Steel01

  • 25
Has it really been six years since I posted around here? Wow...

Anyways, I upgraded my gaming desktop and buildbot to Fedora 20 and noticed my rpm build failed for fs2_open current svn trunk. Seems Fedora is now shipping LUA 5.2, which isn't supported by fs2_open yet. I don't know how much changed between 5.1 and 5.2, but it seems fairly small. After removing the configure.ac version cap, I got one warning and three errors, but I know how those can spiderweb. I can post logs later if that would help. If Fedora is shipping it now, other distros will likely follow suit soon.

In other news, I've got a lot to catch up on around here now that I'm out of college and have somewhat more time. A lot of good changes have happened in that time. Good job, devs.

Steel01
Snips from Hackers Defend Liberty (Definitions for hacker):
But I like rescuing good words from sad bad fates, and so I cling to Eric Raymond's definition:
    "1. A person who enjoys exploring the details of programmable systems and how to stretch their capabilities, as opposed to most users, who prefer to learn only the minimum necessary...
    "7. One who enjoys the intellectual challenge of creatively overcoming or circumventing limitations.

I also like tinkerer, as defined by Freedom to Tinker:
    "Your freedom to understand, discuss, repair, and modify the technological devices you own."

 

Offline niffiwan

  • 211
  • Eluder Class
I threw the lua < 5.2 check into configure.ac because there were reports of it not working properly in FSO. And unfortunately Fedora20 doesn't seem to provide lua5.1 as a separate package. IIRC, there has been some discussion about adding 5.2 support, or moving to luajit.  I can't remember exactly what the status of that is though.

Anyway - posting the logs would be good anyway - were they build errors or FSO errors?
Creating a fs2_open.log | Red Alert Bug = Hex Edit | MediaVPs 2014: Bigger HUD gauges | 32bit libs for 64bit Ubuntu
----
Debian Packages (testing/unstable): Freespace2 | wxLauncher
----
m|m: I think I'm suffering from Stockholm syndrome. Bmpman is starting to make sense and it's actually written reasonably well...

 

Offline chief1983

  • Still lacks a custom title
  • Moderator
  • 212
  • ⬇️⬆️⬅️⬅️🅰➡️⬇️
    • Minecraft
    • Skype
    • Steam
    • Twitter
    • Fate of the Galaxy
I think my Ubuntu VM has both 5.1 and 5.2 available so I think I can experiment a bit with 5.2.
Fate of the Galaxy - Now Hiring!  Apply within | Diaspora | SCP Home | Collada Importer for PCS2
Karajorma's 'How to report bugs' | Mantis
#freespace | #scp-swc | #diaspora | #SCP | #hard-light on EsperNet

"You may not sell or otherwise commercially exploit the source or things you created based on the source." -- Excerpt from FSO license, for reference

Nuclear1:  Jesus Christ zack you're a little too hamyurger for HLP right now...
iamzack:  i dont have hamynerge i just want ptatoc hips D:
redsniper:  Platonic hips?!
iamzack:  lays

 

Offline Steel01

  • 25
Build errors. They're at the end of the post. And yeah, not surprised F20 doesn't ship the last version. Bleeding edge distro and all. I've come to expect this, and it's half the fun. If y'all get a patch that needs testing, let me know. I've got a 64-bit F20 install to run on and a 32-bit F20 build bot with a 64-bit compiler grafted in available for testing.

Steel01

Code: [Select]
parse/lua.cpp: In function ‘int l_Object___tostring_f(lua_State*)’:
parse/lua.cpp:4786:68: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘int’ [-Wformat=]
    sprintf(buf, "Object %ld [%d]", OBJ_INDEX(objh->objp), objh->sig);
                                                                    ^
parse/lua.cpp: In member function ‘int script_state::CreateLuaState()’:
parse/lua.cpp:14615:26: error: ‘lua_open’ was not declared in this scope
  lua_State *L = lua_open();
                          ^
parse/lua.cpp:14629:16: error: ‘LUA_GLOBALSINDEX’ was not declared in this scope
  lua_rawget(L, LUA_GLOBALSINDEX);
                ^
parse/lua.cpp: In member function ‘int ade_table_entry::SetTable(lua_State*, int, int)’:
parse/lua.cpp:15454:20: error: ‘LUA_GLOBALSINDEX’ was not declared in this scope
    if(p_amt_ldx != LUA_GLOBALSINDEX)
                    ^
make[1]: *** [lua.o] Error 1

Edit: Just for kicks, I fired off the executable from my last F19 rpm build. Runs like a charm. Guess the vanilla fs2 campaign doesn't use lua. That or fs2_open gracefully handles the failure to open the lua interpreter and doesn't output any errors to stdout about it.

Edit to my edit: Or it's statically linked. Brain cramp moment... *scurries back off*
« Last Edit: December 17, 2013, 06:39:37 pm by Steel01 »
Snips from Hackers Defend Liberty (Definitions for hacker):
But I like rescuing good words from sad bad fates, and so I cling to Eric Raymond's definition:
    "1. A person who enjoys exploring the details of programmable systems and how to stretch their capabilities, as opposed to most users, who prefer to learn only the minimum necessary...
    "7. One who enjoys the intellectual challenge of creatively overcoming or circumventing limitations.

I also like tinkerer, as defined by Freedom to Tinker:
    "Your freedom to understand, discuss, repair, and modify the technological devices you own."

 

Offline m!m

  • 211
LuaJIT works fine (see my cmake branch) but it exposes the Lua 5.1 API so if we want to switch to luajit at some point we will have to keep using Lua 5.1.

 

Offline ni1s

  • 26
LuaJIT works fine (see my cmake branch) but it exposes the Lua 5.1 API so if we want to switch to luajit at some point we will have to keep using Lua 5.1.
Does it? IIRC debug builds segfault, although it was along time ago I played with LuaJIT so things might have changed.

 

Offline m!m

  • 211
It works for me on windows but you could try it on Linux as I am not able to run FSO in my VM (I would also appreciate any testing done with the cmake changes). If you are interested I could give you further instructions.

 

Offline AddiB

  • 22
Are there any news regarding the support for lua 5.2?


 

Offline Echelon9

  • 210
I'm also interested in seeing where m!m's good work on LuaJIT got to.

Is there a thread with link to the Github code or patches that can be bumped for review m!m?

 

Offline m!m

  • 211
The LuaJIT integration is included in the CMake branch: https://github.com/asarium/fs2open.github.com/tree/cmake
Just set FSO_USE_LUAJIT to ON and you are ready to go (at least on Windows or on Linux, I can't test the project files for Mac so I couldn't do much to support it).

 

Offline AddiB

  • 22
LuaJIT still needs Lua 5.1, doesn't it?

 

Offline m!m

  • 211
Yes, LuaJIT only implements Lua 5.1 which is also why we are not moving to Lua 5.2 with the engine.

 

Offline joram

  • 21
I'm also interested in fs2_open in Fedora 20. When I try to build the cmake branch, I get the following error:

[ 16%] Building CXX object code/CMakeFiles/code.dir/ai/aiturret.cpp.o
In file included from /builddir/build/BUILD/fs2_open_3_7_0cmake/lib/lua/luajit/s
rc/luajit/src/lua.h:16:0,
                 from /builddir/build/BUILD/fs2_open_3_7_0cmake/lib/lua/luajit/src/luajit/src/lauxlib.h:15,
                 from /builddir/build/BUILD/fs2_open_3_7_0cmake/code/parse/lua.h:5,
                 from /builddir/build/BUILD/fs2_open_3_7_0cmake/code/parse/scripting.h:6,
                 from /builddir/build/BUILD/fs2_open_3_7_0cmake/code/ai/aiturret.cpp:24:
/builddir/build/BUILD/fs2_open_3_7_0cmake/lib/lua/luajit/src/luajit/src/luaconf.h:118:28: error: expected constructor, destructor, or type conversion before '(' token
 #define LUA_API  __declspec(dllimport)
                            ^
/builddir/build/BUILD/fs2_open_3_7_0cmake/lib/lua/luajit/src/luajit/src/lua.h:110:1: note: in expansion of macro 'LUA_API'
 LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);
 ^


Would it also be possible to modify the source to check if luajit is already available instead of downloading and building from source? Fedora 20 already has luajit 2.0.2.

  

Offline m!m

  • 211
The problem is that the luajit libraries are not named the same way everywhere which makes finding them hard.
If you can post the necessary changes I can add support for that but I won't be able to do the necessary changes myself.

 

Offline joram

  • 21
Here is a sample patch I added to find luajit library without downloading and compiling, and it seems to detect the library.

--- lib/lua/CMakeLists.txt.orig   2014-05-04 09:22:58.000000000 -0700
+++ lib/lua/CMakeLists.txt   2014-05-27 01:16:11.692412543 -0700
@@ -2,6 +2,12 @@
 IF(FSO_USE_LUAJIT)
    MESSAGE(STATUS "Using luajit as lua interpreter")
 
+   FIND_PACKAGE(PkgConfig REQUIRED)
+   pkg_check_modules(LUA luajit)
+   IF(LUA_FOUND)
+   INCLUDE(util)
+   ADD_IMPORTED_LIB(lua "${LUA_INCLUDE_DIRS}" "${LUA_LIBRARIES}" SHARED)
+   ELSE(LUA_FOUND)
    INCLUDE(ExternalProject)
    INCLUDE(util)
 
@@ -78,6 +84,7 @@ IF(FSO_USE_LUAJIT)
    FILE(MAKE_DIRECTORY "${source_dir}/src")
 
    SET(LUA_LIBS luajit_lib CACHE INTERNAL "LuaJIT library")
+   ENDIF(LUA_FOUND)
 ELSE(FSO_USE_LUAJIT)
    IF(NOT FSO_BUILD_INCLUDED_LIBS)
       FIND_PACKAGE(Lua51 QUIET)


Now I have the following problem. How/where do I add LUA_INCLUDE_DIRS in cmake configuration so it can find the include header? I'm not familiar with cmake.

[ 12%] Building CXX object code/CMakeFiles/code.dir/ai/aiturret.cpp.o
In file included from /builddir/build/BUILD/fs2_open_3_7_0cmake/code/parse/scripting.h:6:0,
                 from /builddir/build/BUILD/fs2_open_3_7_0cmake/code/ai/aiturret.cpp:24:
/builddir/build/BUILD/fs2_open_3_7_0cmake/code/parse/lua.h:5:22: fatal error: lauxlib.h: No such file or directory
  #include <lauxlib.h>
                      ^
compilation terminated.

 

Offline m!m

  • 211
Thanks, I think I fixed your issue on my side (at least it works if I try it :nervous:) and pushed my changes to the github branch.