lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Fri, Jul 31, 2020 at 1:56 PM John Gabriele <jgabriele@fastmail.fm> wrote:
Hi,

I see that Lua 5.4 has a new platform target: linux-readline.

When building versions of Lua prior to v5.4 for linux, did the build pull in
readline if I had libreadline-dev installed on my system?

When I build 5.3, I see in the make output:

    gcc -std=gnu99 -o lua   lua.o liblua.a -lm -Wl,-E -ldl -lreadline

and running the repl I see that I get the usual expected support for
what I understand to be readline support (up and down arrows work,
^r works to search back, etc.).

Correct. In 5.3 and earlier, readline was hardcoded in the linux target recipe, and `make linux` would fail if libreadline-dev (or your distro's equivalent) was not installed. Building without readline required manual editing of the Makefile (which isn't unusual for Lua).
 
What's the difference between 5.4's linux and linux-readline?

The plain linux target is effectively an alias for linux-noreadline, which as the name implies does not link with readline. The linux-readline target does link with readline. There is no other difference.

This means that Lua 5.4 no longer assumes that readline is available, and gives you the option without Makefile editing. The downside is that if you want readline support, you must explicitly ask for it with `make linux-readline`. A bare `make` (as recommended by the 5.4 readme) which guesses Linux will build the linux target (and therefore linux-noreadline).

Ideally, the Makefile would perform feature detection and automatically link to readline if available and not if not. Unfortunately, there is no (easy) way to do so in a manner that is as portable as Lua requires (even if the feature test is only needed on Linux, the Makefile code that does it must be compatible with (i.e. not cause syntax or other errors on) every Make on every system that Lua might be compiled on).