Skip to content

Update version checks for lua 5.5#74

Merged
hishamhm merged 4 commits intolunarmodules:masterfrom
tobil4sk:feature/lua-5.5
Mar 16, 2026
Merged

Update version checks for lua 5.5#74
hishamhm merged 4 commits intolunarmodules:masterfrom
tobil4sk:feature/lua-5.5

Conversation

@tobil4sk
Copy link
Copy Markdown
Contributor

@tobil4sk tobil4sk commented Feb 9, 2026

No description provided.

@luau-project
Copy link
Copy Markdown
Member

hi @tobil4sk

Today, during my tests with luarocks, I tried to apply the changes you wrote on this PR to build lua-compat-5.3 on Lua 5.5.

Then, I had a few findings.

Findings

  • When you try to build lua-compat-5.3 on Lua 5.5 on Linux, macOS and Windows, the line

    lua_assert(lo + r4 <= p && p <= up - r4);
    should throw during the build phase, because the macro lua_assert is no longer part of Lua's public API (see the commit lua/lua@a08d82e, it was removed from lauxlib.h);

  • I prepared a GitHub workflow to demonstrate this: https://github.com/luau-project/ci-tests/actions/runs/21880992467. Even though Lua 5.5 + Ubuntu didn't error'ed, it should (inpect it, the lua_assert symbol isn't defined).

Toogle the GitHub workflow
name: Test

on: push

jobs:
  test:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        luaVersion: ["5.1", "5.2", "5.3", "5.4", "5.5", "luajit"]
        os: ["ubuntu-latest", "macos-latest", "windows-latest"]

    steps:
    # We are going to install
    # lua-compat-5.3 from source
    # patched by https://github.com/lunarmodules/lua-compat-5.3/pull/74
    # to test lua-compat-5.3 on Lua 5.5
    - uses: actions/checkout@master
      with:
        repository: lunarmodules/lua-compat-5.3

    - uses: ilammy/msvc-dev-cmd@v1
      if: ${{ runner.os == 'Windows' && !startsWith(matrix.luaVersion, 'luajit') }}

    - uses: luarocks/gh-actions-lua@master
      with:
        luaVersion: ${{ matrix.luaVersion }}

    - uses: luarocks/gh-actions-luarocks@master

    - name: Download lua-compat-5.3 patch
      run: curl -kLO "https://github.com/lunarmodules/lua-compat-5.3/pull/74.patch"

    - name: Apply lua-compat-5.3 patch
      run: git apply "74.patch"

    - name: Lint development rockspec
      run: luarocks lint "rockspecs/compat53-scm-1.rockspec"

    - name: Install the patched lua-compat-5.3
      run: luarocks make "rockspecs/compat53-scm-1.rockspec"

Note

Since your PR is dealing with Lua 5.5 support, could you fix this?

I guess that placing something in the direction of the following excerpt

#if defined(LUA_VERSION_NUM) && LUA_VERSION_NUM >= 505
#if !defined(lua_assert)
  #include <assert.h>
  #define lua_assert(c)		assert(c)
#endif
#endif

on lua-compat-5.3 headers would solve this build issue.

@tobil4sk
Copy link
Copy Markdown
Contributor Author

Hello! I've found how lua 5.5 defines lua_assert:
https://www.lua.org/source/5.5/llimits.h.html#lua_assert

I have preserved the LUAI_ASSERT check, because I want to prevent asserts from appearing in cases where they used to be omitted.

I'm also wondering how this should be handled "properly". Maybe this is outside of the scope of this library, since it only lists 5.3 compatibility for 5.1 and 5.2? It's also worth noting, I don't think the lua_assert macro was ever considered public.

As an aside, the fact that there is no compile time or link time error on ubuntu is worrying. On my local environment, I get:

compat53 scm-1 depends on lua >= 5.1, < 5.6 (5.5-1 provided by VM: success)
gcc -O2 -fPIC -I/.../include -c lstrlib.c -o lstrlib.o
lstrlib.c: In function ‘reprepstate’:
lstrlib.c:603:3: error: implicit declaration of function ‘lua_assert’; did you mean ‘lua_insert’? [-Wimplicit-function-declaration]
  603 |   lua_assert(ms->matchdepth == MAXCCALLS);
      |   ^~~~~~~~~~
      |   lua_insert

Error: Build error: Failed compiling object lstrlib.o

@luau-project
Copy link
Copy Markdown
Member

I have preserved the LUAI_ASSERT check, because I want to prevent asserts from appearing in cases where they used to be omitted.

yes. I considered that as well. Later, reading the code on compat-5.3.h carefully, I had a few doubts because it seems to follow some pattern, e.g.:

#define lua_pushlstring COMPAT53_CONCAT(COMPAT53_PREFIX, _pushlstring_53)
COMPAT53_API const char *lua_pushlstring (lua_State *L, const char *s, size_t len);
#define lua_geti COMPAT53_CONCAT(COMPAT53_PREFIX, _geti)
COMPAT53_API int lua_geti (lua_State *L, int index, lua_Integer i);
#define lua_getextraspace COMPAT53_CONCAT(COMPAT53_PREFIX, _getextraspace)
COMPAT53_API void *lua_getextraspace (lua_State *L);
#define lua_isinteger COMPAT53_CONCAT(COMPAT53_PREFIX, _isinteger)
COMPAT53_API int lua_isinteger (lua_State *L, int index);
#define lua_tointegerx COMPAT53_CONCAT(COMPAT53_PREFIX, _tointegerx_53)
COMPAT53_API lua_Integer lua_tointegerx (lua_State *L, int i, int *isnum);

In a perspective of someone from outside the project without a deep understanding about it, these changes are solving the build issue for Lua 5.5 quite well.

Thank you for taking the time to analyze my considerations and submit these changes!

@luau-project luau-project mentioned this pull request Feb 22, 2026
@Vekhir
Copy link
Copy Markdown

Vekhir commented Feb 22, 2026

What is needed to merge this? Arch Linux is currently in the process of updating to Lua 5.5, and having this fix would progress the update.

@luau-project
Copy link
Copy Markdown
Member

Maybe @hishamhm can review this.

@daurnimator
Copy link
Copy Markdown
Contributor

daurnimator commented Mar 1, 2026

I'd rather we followed along with the evolution of lua itself in terms of organisation and API:
What if we have some library-internal llimits.h header that could be used by ltablib?


Arch Linux is currently in the process of updating to Lua 5.5, and having this fix would progress the update.

@Vekhir How? (I don't understand how this issue would block that)

@Vekhir
Copy link
Copy Markdown

Vekhir commented Mar 2, 2026

How? (I don't understand how this issue would block that)

The lua-bit32 package uses this projects code. Since the compat.h doesn't support Lua 5.5, compilation fails.

lua-bit32 is required by lua-posix at runtime, meaning that building it works fine, but once the lua update hits the testing repos, it will likely fail because lua-bit32 is built against Lua 5.4, when it should be Lua 5.5.

Sometimes, patches can be backported at the discretion of the maintainer - and in this case, it's rather small - but common practice is to wait at least until the patch is upstream and can be expected to be included in the next release.

@luau-project
Copy link
Copy Markdown
Member

Hi, @Vekhir

I don't have any Arch Linux installed on my computer at the moment, but I did a quick inspection on lua-posix source code, and I got to the conclusion that lua-posix only seems to require this module (aka *-bit32 on Arch Linux repos) when running under Lua 5.1.

In short, my conclusion is: apply the following patch

--- PKGBUILD-orig	2026-03-02 11:51:26.577927670 -0300
+++ PKGBUILD	2026-03-02 11:52:50.492518591 -0300
@@ -28,7 +28,7 @@
 _package() {
 	cd "$_archive"
 	depends+=("${pkgname%-*}"
-	          "${pkgname%-*}-bit32")
+	          $([[ "x$1" == "x5.1" ]] && echo "${pkgname%-*}-bit32"))
 	luarocks --lua-version="$1" --tree="$pkgdir/usr/" \
 		make --deps-mode=none --no-manifest "$_archive-$_rockrel.rockspec"
 	install -Dm0644 -t "$pkgdir/usr/share/licenses/$pkgname/" LICENSE

to lua-posix PKGBUILD, and tell whether it works or not.

@Vekhir
Copy link
Copy Markdown

Vekhir commented Mar 12, 2026

@luau-project The maintainers have chosen to apply a minimal patch to make it build.

@daurnimator The last remaining package is lua-cqueues which uses your rockspecs at https://luarocks.org/manifests/daurnimator. Could you take a look and make a version for Lua 5.5 available?

@hishamhm
Copy link
Copy Markdown
Member

@Vekhir please rebase to the latest master, I fixed the CI checks.

@Vekhir
Copy link
Copy Markdown

Vekhir commented Mar 12, 2026

please rebase to the latest master, I fixed the CI checks

Tagging @tobil4sk as the OP

This is required by liolib.c, lstrllib.c, and ltablib.c, but was removed
from the lua 5.5 since it was never a public part of the api.
@tobil4sk
Copy link
Copy Markdown
Contributor Author

I did the rebase, CI is now passing

@hishamhm hishamhm merged commit 9c6f75a into lunarmodules:master Mar 16, 2026
15 checks passed
@tobil4sk tobil4sk deleted the feature/lua-5.5 branch March 16, 2026 15:40
@daurnimator
Copy link
Copy Markdown
Contributor

@hishamhm we should tag a release here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants