Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 842444 - dev-db/redis-6.2.6[lua_single_target_luajit] fails to build with dev-lang/luajit-2.1 - error: static declaration of ‘luaL_setfuncs’ follows non-static declaration
Summary: dev-db/redis-6.2.6[lua_single_target_luajit] fails to build with dev-lang/lua...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Petr Vaněk
URL:
Whiteboard:
Keywords: PullRequest
Depends on:
Blocks:
 
Reported: 2022-05-03 14:54 UTC by Vadim A. Misbakh-Soloviov (mva)
Modified: 2022-07-02 15:09 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
redis-6.2.6-luajit-lua52compat.patch (redis-luajit-lua52compat-7.0.0.patch,1.17 KB, patch)
2022-05-03 21:39 UTC, Vadim A. Misbakh-Soloviov (mva)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vadim A. Misbakh-Soloviov (mva) gentoo-dev 2022-05-03 14:54:03 UTC
It seems, Redis' bundled cjson doesn't have fixes from openresty ressurection fork (as original lua-cjson upstream is dead), so it redefines luaL_setfuncs functions based only on version check, and not function existance: https://github.com/redis/redis/blob/unstable/deps/lua/src/lua_cjson.c#L1295

While current version of lua-cjson uses compat-wrapping to avoid such situations, like this bug: https://github.com/openresty/lua-cjson/blob/master/lua_cjson.c#L1414 (notice another function name)


N.B.: I temporary fixed it in my overlay by this before code that copyies lua libs to build dir:

```
    if use lua_single_target_luajit && has_version dev-lang/luajit[lua52compat]; then
    ▏   sed \
    ▏   ▏   -e '/^static void luaL_setfuncs/,/^}/d' \
    ▏   ▏   -i "${S}"/deps/lua/src/lua_cjson.c
    fi
```

but, maybe, it would be better to make a patch

Reproducible: Always
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-05-03 20:49:13 UTC
Please provide a patch as seds are quite fragile (and often end up making no, or different substitutions, than intended).
Comment 2 Vadim A. Misbakh-Soloviov (mva) gentoo-dev 2022-05-03 21:39:26 UTC
Created attachment 776591 [details, diff]
redis-6.2.6-luajit-lua52compat.patch

Here it is.

Although, nevermind.

As it anyway would become ~arch because of revbumping, and you've already added 7.0.0 ebuild with dropping sharedlua and moving to bundled one, this is not so actual anymore.

Although, it would be better to fix ebuild to don't use lua.eclass and ${ELUA}, as it can cause random breakages...

So, proper fix would be:

--- a/configure.ac      2022-05-04 04:37:16.919638080 +0700
+++ b/configure.ac      2022-05-04 04:37:10.260858667 +0700
@@ -54,13 +54,5 @@ AC_FUNC_STRCOLL
 AC_FUNC_STRTOD
 AC_CHECK_FUNCS([dup2 gethostbyname gettimeofday inet_ntoa memchr memmove memset select socket strcasecmp strchr strerror strstr strtol])
 
-# Check for lua-5.1 or luajit
-AC_ARG_WITH([luajit],
-    AS_HELP_STRING([--with-luajit], [Use luajit instead of lua]))
-
-AS_IF([test "x$with_luajit" = "xyes"],
-      [PKG_CHECK_MODULES([LUA], [luajit >= 2], [], [AC_MSG_ERROR([luajit requested but not found])])],
-      [PKG_CHECK_MODULES([LUA], [lua5.1], [], [AC_MSG_ERROR([lua-5.1 required but not found])])])
-
 AC_CONFIG_FILES([ tests/modules/Makefile src/Makefile src/modules/Makefile deps/lua/src/Makefile deps/lua/etc/Makefile deps/lua/Makefile deps/linenoise/Makefile deps/hiredis/Makefile deps/hdr_histogram/Makefile deps/Makefile Makefile])
 AC_OUTPUT
Comment 3 Vadim A. Misbakh-Soloviov (mva) gentoo-dev 2022-05-03 21:44:48 UTC
they don't use neither system Lua nor LuaJIT in any way (neither link to them, nor even have mentions in binaries/libs), so, I think, this check (and with-flag) are totally pointless.
Comment 4 Larry the Git Cow gentoo-dev 2022-06-01 02:08:25 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c401269e5d01422852304a01133cdcde9c9706fc

commit c401269e5d01422852304a01133cdcde9c9706fc
Author:     Vadim Misbakh-Soloviov <mva@gentoo.org>
AuthorDate: 2022-05-03 22:27:09 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-06-01 02:07:38 +0000

    dev-db/redis: get rid of external Lua
    
    Bug: https://bugs.gentoo.org/842444
    Package-Manager: Portage-3.0.30, Repoman-3.0.1
    Signed-off-by: Vadim Misbakh-Soloviov <mva@gentoo.org>
    Closes: https://github.com/gentoo/gentoo/pull/25310
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-db/redis/files/configure.ac-7.0 |  58 ++++++++++++
 dev-db/redis/redis-7.0.0-r1.ebuild  | 173 ++++++++++++++++++++++++++++++++++++
 2 files changed, 231 insertions(+)
Comment 5 Petr Vaněk gentoo-dev 2022-07-01 13:21:35 UTC
This issue is related to dev-lang/luajit-2.1. lua52compat use flag does not change the result.
Comment 6 Larry the Git Cow gentoo-dev 2022-07-02 14:55:40 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=881481e001d00a730884606bfb07eebd5b130dde

commit 881481e001d00a730884606bfb07eebd5b130dde
Author:     Petr Vaněk <arkamar@atlas.cz>
AuthorDate: 2022-07-01 13:23:28 +0000
Commit:     Sam James <sam@gentoo.org>
CommitDate: 2022-07-02 14:55:33 +0000

    dev-db/redis: build fix for luajit-2.1
    
    luajit-2.1 integrated few extensions from lua5.2 [1] luaL_setfuncs being
    one of them. The same function is implemented in bundled lua-cjson for
    lua5.1 but is not properly guarded for luajit-2.1. This change backports
    the fix [2,3] from https://github.com/openresty/lua-cjson.
    
    [1] https://github.com/LuaJIT/LuaJIT/commit/de97b9d52bbc42effeaf1180764053a912526873
    [2] https://github.com/openresty/lua-cjson/commit/638ac2741a7f274979ac3fe2e1ea5fd6487702fe
    [3] https://github.com/openresty/lua-cjson/pull/32
    
    Closes: https://bugs.gentoo.org/842444
    Signed-off-by: Petr Vaněk <arkamar@atlas.cz>
    Signed-off-by: Sam James <sam@gentoo.org>

 dev-db/redis/files/redis-5.0-luajit-2.1-fix.patch | 47 +++++++++++++++++++++++
 dev-db/redis/redis-5.0.14.ebuild                  |  1 +
 dev-db/redis/redis-6.0.16.ebuild                  |  1 +
 dev-db/redis/redis-6.2.6.ebuild                   |  1 +
 4 files changed, 50 insertions(+)