Lua53 revision 3
Needs ReviewPublic

Authored by russ.haley_gmail.com on Dec 30 2017, 7:09 AM.

Details

Reviewers
jbeich
Summary

Hello,

The logic behind this revision is:

  • Review old notes and assumptions and clean up things unrequired
  • Apply some logic to the way the port is built
  • Prepare for possible inclusion of luarocks in base lua package
  • [Possible integration of ports between lua revisions]

I will put comments inline about the changes, but the overall consideration is to patch the source and makefile as to be correct for the platform, then build it using the standard lua build target of "freebsd". I would like to eliminate the MAKEARGS in the middle and instead rename the files during install, or a preinstall step to copy the files. This further modification leaves the port output in a vanilla state and the executables can be used for other things.

Test Plan

I have none at this point and am looking for input. A search of freshports for things dependent on lua53 brings up 5 items. Suggestions ways to test these items would be appreciated. (Is it simply good enough if they build in my ports tree?)

I will be testing this on Arm as soon as I can get one of my boards spun up again. Famous last words: "I see no reason it shouldn't work".

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Makefile
16

This is simply handled in the code patch to lua.c. As far as I can tell, editline is a standard package in FreeBSD 4.4?

https://www.freebsd.org/cgi/man.cgi?editline

28

These variable have been added to standardize with lua.mk and hopefully other packages if I have time.

29

Unnecessary if the standard editline package is used.
https://www.freebsd.org/cgi/man.cgi?editline

30

As per an email with Jan Beich:

-pthread was inherited from
https://svnweb.freebsd.org/changeset/ports/324286
which was probably fixed by
https://svnweb.freebsd.org/changeset/base/276630

How do I test this?

34

I would like to remove the renaming of the lua build output and postpone it until the install step, or a preinstall rename. Input appreciated.

61

Added to the base Makefile

64

The code that this patches is not reachable due to the USE_POSIX.

http://lua-users.org/lists/lua-l/2017-09/msg00089.html

From lmathlib.c

#if !defined(l_rand) /* { */
#if defined(LUA_USE_POSIX)
#define l_rand() random()
#define l_srand(x) srandom(x)
#define L_RANDMAX 2147483647 /* (2^31 - 1), following POSIX */
#else
#define l_rand() rand()
#define l_srand(x) srand(x)
#define L_RANDMAX RAND_MAX
#endif
#endif /* } */

from luaconf.h

#if defined(LUA_USE_LINUX)
#define LUA_USE_POSIX
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */
#define LUA_USE_READLINE /* needs some extra libraries */
#endif

66

luaconf.h contains no readline reference and I instead created a patch for lua.c. This makes the code changes in one place (patch files) and the changes required are easily visible (in the patch file).

files/patch-src__Makefile
63

This is the simplest way to patch the original make file to compile it on FreeBSD. I don't have my arm boards handy, but this is essentially what I do when I build lua manually. Again, the changes are applied to the base makefile so the lua sources are as vanilla as possible and the base make system works.

files/patch-src_lua.c
9

Eliminates all shared dependencies and the code is 100% portable on FreeBSD.

Makefile
33

This is the standard make target for freebsd in lua.

andrew_tao173.riddles.org.uk added inline comments.
files/patch-src_lua.c
9

As I pointed out in email, this change should be eliminated in favour of adding -I/usr/include/edit to cflags.

Note that the USES=libedit can be removed, since that pulls in the ports libedit. (Unless there's some reason to use the ports libedit...)

Makefile
66

This removal isn't quite right because the point of editing luaconf.h here is not to deal with readline, but rather to fix LUA_ROOT to ensure it matches ${PREFIX}. By default these are both /usr/local, so it's not obvious if this step is missed, but if ${PREFIX} is set to something else it's important that LUA_ROOT in luaconf.h be updated to match.

Hi Andrew,

Once you're happy with the 5.4 patch i will back-port to 5.3 and add the missing Lua patches.