Changes between Version 5 and Version 6 of Ticket #70420, comment 9


Ignore:
Timestamp:
Aug 8, 2024, 12:48:25 AM (6 weeks ago)
Author:
wryfi
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #70420, comment 9

    v5 v6  
    33Starting with this bug report and #66077 ...
    44
    5 `luajit` is used for much of the build process, and the neovim Portfile contains `configure.args-append -DLUA_PRG=${prefix}/bin/luajit`. `luajit` is its own thing and adheres only to the lua-5.1 language spec. `luajit` works regardless of the state of other lua packages on my system. All good so far.
     5`neovim` depends on `lua51-lpeg`, which depends on `lua-luarocks`, which depends on `lua` and `lua53-luarocks`, guaranteeing that `lua` and `lua53` ports will be installed when trying to install neovim.
    66
    7 But neovim also uses some C, and builds a library, `nlua0`, from `src/nlua0.c` in the neovim source tree. The first line of this file is `#include <lua.h>`.
     7`luajit` is used for much of the build process, and the neovim Portfile contains `configure.args-append -DLUA_PRG=${prefix}/bin/luajit`. `luajit` is its own thing and adheres only to the lua-5.1 language spec. `luajit` works regardless of the state of other lua packages on my system.
    88
    9 When the `lua` port is installed, it creates `/opt/local/include/lua.h`, which contains C headers for lua 5.3. Because this is the first `lua.h` file the compiler finds in the include directory, the C compiler uses this header and then builds `nlua0` against lua 5.3.
     9But neovim also uses some C, and builds a library, `nlua0`, from `src/nlua0.c` in its source tree, which `luajit` uses later in the build process. The first line of `nlua0.c` is `#include <lua.h>`.
     10
     11The `lua` port creates `/opt/local/include/lua.h`, which contains C headers for lua 5.3. Because this is the first `lua.h` file the compiler finds in the include directory, the C compiler uses this header and then builds `nlua0` against lua 5.3.
    1012
    1113This breaks the neovim build as described in this ticket and in #66077 because `nlua0` pulls in symbols from lua 5.3 that `luajit` can't grok (because `luajit` is strictly 5.1).
    1214
    13 The fix for this is to get the compiler to look in `/opt/local/include/lua5.1` and use the `lua.h` header from the `lua51` port. ''See'' [https://github.com/macports/macports-ports/pull/25223 GitHub PR].
     15The fix for this is to get the compiler to look in `/opt/local/include/lua5.1` so that it uses the `lua.h` header from the `lua51` port. ''See'' [https://github.com/macports/macports-ports/pull/25223 GitHub PR].
    1416
    1517{{{
     
    5557Now on to some of my other discoveries while investigating this issue ...
    5658
    57 I don't think the build/install issues with `luarocks` are as simple as the commit referenced above suggests. There seem to be a few broken layers to unpack here (though to be clear this is unrelated to the neovim build).
     59I don't think the build/install issues with `luarocks` are as simple as the commit referenced [https://trac.macports.org/ticket/70420?cnum_edit=9#comment:8 above] suggests. There seem to be a few broken layers to unpack here (though to be clear this is unrelated to the neovim build).
    5860
    5961At the top of the [https://github.com/luarocks/luarocks/blob/master/src/luarocks/core/cfg.lua config file] referenced in that git commit:
     
    8688}}}
    8789
    88 Whether I run `luarocks`, `luarocks-5.1`, `luarocks-5.2`, `luarocks-5.3`, or `luarocks-5.4`, they all return the same configuration. The versioned copies are all symlinks to the same `/opt/local/bin/luarocks` script, so this comes as no shock.
     90Whether I run `luarocks`, `luarocks-5.1`, `luarocks-5.2`, `luarocks-5.3`, or `luarocks-5.4`, they all return the same info. The versioned copies are all symlinks to the same `/opt/local/bin/luarocks` script, so this comes as no shock.
    8991
    90 That `luarocks` script has lua-5.3 paths hard-coded into it:
     92That `luarocks` script also has lua 5.3 paths hard-coded into it:
    9193
    9294{{{
     
    115117So in summary:
    116118
    117 1. The `lua` port decides for you what version of lua (currently 5.3) will be the default lua on your system, and that all C libraries linking against `lua.h` will build against that version without extra care.
    118 1. Any port that depends on `lua` installs and makes the `lua` port's version (currently 5.3) your default lua, even if your lua-based port actually depends on an older version of lua.
     1191. The `lua` port decides for you what version of lua (currently 5.3) will be the default lua on your system.
     120  a. Note that all C libraries linking against `lua.h` will build against that version without extra care.
     1211. There is no facility to manage which version of lua is used as the system default.
     1221. Any port that depends on `lua` installs and makes the `lua` port's version (currently 5.3) the default, even if the dependent port is incompatible with that version.
    1191231. The `lua` port installs a 5.3 binary in `/opt/local/bin/lua` that appears to be similar, but not identical, to the `/opt/local/bin/lua5.3` binary installed by the `lua53` port.
    120 1. There is no facility to manage which version of lua is used as the system default.
    1211241. Uninstalling the `lua` port will break `luarocks` and potentially other lua ports, even though they could use a different version of lua.
    1221251. `neovim` depends on `lua51-lpeg`, which depends on `lua-luarocks`, which depends on `lua` and `lua53-luarocks`, guaranteeing that `lua53` will be installed when trying to install neovim, even though neither `lua51-lpeg` nor `neovim` wants anything to do with lua 5.3.
    123 1. Building `neovim` is breaking because it links against the `lua.h` provided by the `lua` port (currently 5.3), which is incompatible with neovim and luajit (not for any reasons having to do with `luarocks`).
     1261. Building `neovim` is breaking because it links against the `lua.h` provided by the `lua` port (currently 5.3), which is incompatible with neovim and luajit.
    1241271. `luarocks` always runs against the version of lua installed by the `lua` port, because its shebang is `/opt/local/bin/lua`, which is (currently) lua 5.3 by design of the `lua` port.
    125128  a. This remains true even if running `luarocks-5.n` because the versioned copies are all symlinks to the same `luarocks` script.
     129  a. The `luarocks-5.n` symlinks are therefore not likely useful and/or probably broken for their intended purpose.
    1261301. `luarocks` always manages packages in `/opt/local/share/lua/5.3` because this value is hard-coded in the script.
     1311. MacPorts probably needs to add a selection mechanism for setting and using the desired version of lua on the system.
    127132
    128