| Message ID | 20261027184420.75223-1-valter.jansons@gmail.com |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <location+bounces-66-patchwork=ipfire.org@lists.ipfire.org>
Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)
server-digest SHA384
client-signature RSA-PSS (4096 bits) client-digest SHA256)
(Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified))
by web04.haj.ipfire.org (Postfix) with ESMTPS id 4jDfYB2p9Vz3xVH
for <patchwork@web04.haj.ipfire.org>; Tue, 27 Oct 2026 18:44:30 +0000 (UTC)
Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org
[IPv6:2001:678:b28::201])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange x25519)
(Client CN "mail02.haj.ipfire.org", Issuer "YE2" (not verified))
by mail01.ipfire.org (Postfix) with ESMTPS id 4jDfY94bdgz6Kx
for <patchwork@ipfire.org>; Tue, 27 Oct 2026 18:44:29 +0000 (UTC)
Received: from mail02.haj.ipfire.org (localhost [IPv6:::1])
by mail02.haj.ipfire.org (Postfix) with ESMTP id 4jDfY91s7fz30TW
for <patchwork@ipfire.org>; Tue, 27 Oct 2026 18:44:29 +0000 (UTC)
X-Original-To: location@lists.ipfire.org
Received: from mail01.ipfire.org (mail01.haj.ipfire.org
[IPv6:2001:678:b28::25])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange x25519 server-signature ECDSA (secp384r1 raw public key)
server-digest SHA384
client-signature RSA-PSS (4096 bits) client-digest SHA256)
(Client CN "mail01.haj.ipfire.org", Issuer "YR1" (not verified))
by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4jDfY83bBHz2xLJ
for <location@lists.ipfire.org>; Tue, 27 Oct 2026 18:44:28 +0000 (UTC)
Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com
[IPv6:2607:f8b0:4864:20::102d])
(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
key-exchange x25519 server-signature RSA-PSS (4096 bits) server-digest
SHA256
client-signature RSA-PSS (2048 bits) client-digest SHA256)
(Client CN "smtp.gmail.com", Issuer "WR4" (verified OK))
by mail01.ipfire.org (Postfix) with ESMTPS id 4jDfY66Xklz2WH
for <location@lists.ipfire.org>; Tue, 27 Oct 2026 18:44:26 +0000 (UTC)
Authentication-Results: mail01.ipfire.org;
dkim=pass header.d=gmail.com header.s=20260707 header.b=dC0iG6rA;
spf=pass (mail01.ipfire.org: domain of valter.jansons@gmail.com designates
2607:f8b0:4864:20::102d as permitted sender)
smtp.mailfrom=valter.jansons@gmail.com;
dmarc=pass (policy=none) header.from=gmail.com
ARC-Seal: i=1; a=rsa-sha256; d=lists.ipfire.org; s=202003rsa; cv=none;
t=1793126667;
b=xZceygCLbtkk3GbYAPaKnxI99olQalJfoBrnj2Itr0CbBz7wrkzNdzkaGSwcoCaFI41VKL
AojEhG77cGiSC1zdpyiSgEJmlm9BnBO6Fsj1IvViTB8FGhT3GjpJxhm5e9fbd00Nwbvo64
JC1Z/cLN1rpQyRE7ziW5iBTqTJHKdzHcPGkff2LeDVr4T2ob1CLVa5TFtLG2kEdd//V7nR
S+sM9yjkvNeQ/Wxuyv67Pj++E4c50TNYdX2MQrv8rpX2Udi+Kk9JmRKQmcmy5oFVgeYEgw
fetkN2tCiQYqGrOSFt7PPCoxHwpvK3m0stVQg3MdNdMZT49EHLtX+HOFjsM01A==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed;
d=lists.ipfire.org;
s=202003rsa; t=1793126667;
h=from:from:reply-to:subject:subject:date:date:message-id:message-id:
to:to:cc:mime-version:mime-version:
content-transfer-encoding:content-transfer-encoding:dkim-signature;
bh=ShnosKXPn3qpisNk+jNpfzgaj7t8VBc7IlNhlBykYtc=;
b=hE+JGJT/ZNJHEZj7zj2fldJTxVxgx7iRYr284gWAzmCl0d6+8Ot0Zz4kmSY84ibDp474Mq
FABwKVTgxylcU52/ymS3xglwuPl+srrjf5GFUwYR5yP4NyImj/igq2jtTgZy91DST4QxO7
pIU2ur2SFrdlU4cE0d7mLc+N5bme5IDV6D3JcqxlQR+Z0GUkakLUQSwKEbtohDdv5RJQA+
Rorlc1X+2i/7abCfeM5X/V0aUt41KAV8+6KJoVNHMiQ52/CElXqCPnFal2mb/9krReh47W
n/0LVQs8DxuN0c+RS3goPxQYp58pFvwPOu6HL2pYf1rMnrWXrLWeYfSBeRAQ2Q==
ARC-Authentication-Results: i=1;
mail01.ipfire.org;
dkim=pass header.d=gmail.com header.s=20260707 header.b=dC0iG6rA;
spf=pass (mail01.ipfire.org: domain of valter.jansons@gmail.com designates
2607:f8b0:4864:20::102d as permitted sender)
smtp.mailfrom=valter.jansons@gmail.com;
dmarc=pass (policy=none) header.from=gmail.com
Received: by mail-pj1-x102d.google.com with SMTP id
98e67ed59e1d1-3ab752f6244so230932a91.2
for <location@lists.ipfire.org>; Tue, 27 Oct 2026 11:44:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1793126665; x=1793731465;
darn=lists.ipfire.org;
h=content-transfer-encoding:mime-version:message-id:date:subject:to
:from:from:to:cc:subject:date:message-id:reply-to:content-type;
bh=ShnosKXPn3qpisNk+jNpfzgaj7t8VBc7IlNhlBykYtc=;
b=dC0iG6rA3KXtGj0sKiBm941xRmjZlIFXe4exNEa+IQdRux+ROcVYzVxiGSF+05Zn/5
rLanY/XSLy8MjYTQDRUfuZE38LA+7iy5a9ONU2a2MXvssAwSvlgmzKd2EPpITfqGWR7D
nsmNCJyK51UMa+/G7pKnA+nXSQqyQNHWvuG8W17fGe/i3BrSe3DJftw2inS9LNQC7YHk
6obGGAlJAFqBh0/vbAO8Mbr/VNhERHuZtLwIqmkHm9B4ldjS1oyKC6fOabQ/pHQazjL+
Lln9Fi15SJVNVtTlCKdx6UBVG3MIPnaCxhCpt5hnyOu6tq2uPp9wOqcCJtKjZxrdBeWO
U6rg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1793126665; x=1793731465;
h=content-transfer-encoding:mime-version:message-id:date:subject:to
:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id
:reply-to:content-type;
bh=ShnosKXPn3qpisNk+jNpfzgaj7t8VBc7IlNhlBykYtc=;
b=YGj6iLZ+HgpLNjBhQCukG6YmBt8go36r65ezFbzeZF43bp3rCmirNdUeTV5twdR8AK
Z1mTzg3PO7XXnurvEzFTJD7DWVvRkN6qFnFkOsiyOihtkwWiLLzrBYD+LoYuxQX2luhf
C6bSVPPd2twCjK8LQ7/OMH9qZnscIW7PZk4+9tpkRuQZ0WRBT8f/oLN6Yi1lIKPD0Dry
BR8qDR0pGC6xPd6JsYvwgc9Y9G1SXKsQnZXodLjsqOGZ5bNJDTnGUtgCrE1ZZkLhNPff
h+9COPt1s8BGBIOI1yHDzOjid5b2TxQS6iSph1tixHcTQ4YZjYKXvoYKP5D48/qJ3mCs
SMjw==
X-Gm-Message-State: AFq9FYKIPITOvq90ojjCI/f3HftRxJxiNj3Ji2M3p/hPHw8g4est5JMY
xFBOBT2F7zBqQ7QxZ/RpbN6CpSNCDohcAV464UHY0kVmz0lY3rayAXIUA4MaMnza
X-Gm-Gg: AYBFou2WCxdnKiWkC8r2neO3GpG6y9Jw8nlW4a9ESNq9PIixImXoqgOk4ba3CrA6Y+Y
N1D+xcMK/apQZWCo/OS6h0DOORG+7x5E1eiGaSNy+O2MjHdlXOub5RSjsxq67UUJCvw/xbQtjsO
8uRt/xjAbRPn6U3ngsfWIjRPh7Fxy+VgOIw7kaBypnBU/NlnHzBNPyNy2merLbT4jDYtTgyRjyD
DyE/nKCvF0R83aDzMgTO57VckLENxF8gA0OeIevPDMYsKPWrhZoXOrVgfh7M37mUu/WADt81nlB
Ib1uHRj4G42CIjGp82TeDMbPynuzkiqtPWZOWLedZbZR/c/AP7+Qp9mxWowzO/pjqyP5OV2uhM+
8rOKu/V83+VtgDUnY9NHs905G6wfSFMtEVvYoq1TOdV0hxMK/yzJPJ7FtmddLmru8x1Sx5myFjF
7Ie4bg22GGANQNzyee/laARWWZAUiS59CmvWhmnczMH23jqnlx2BBB5O/7InvShs4b9Di4mDABx
vM2u1dVOY9ua1thi2WouNvBtejf3Wn6fRkGcqM3z6Gb219BIby8b3Po1oRJDRmpMwv8Ccef
X-Received: by 2002:a17:90b:56ce:b0:3a8:9d0d:ca50 with SMTP id
98e67ed59e1d1-3adeaae618emr8958372a91.10.1793126664847;
Tue, 27 Oct 2026 11:44:24 -0700 (PDT)
Received: from VT14-G5.localdomain ([221.146.12.107])
by smtp.gmail.com with ESMTPSA id
98e67ed59e1d1-3ae57a1609esm39413a91.2.2026.10.27.11.44.23
for <location@lists.ipfire.org>
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Tue, 27 Oct 2026 11:44:24 -0700 (PDT)
From: Valters Jansons <valter.jansons@gmail.com>
To: location@lists.ipfire.org
Subject: [PATCH] lua: Use LUA_VERSION_NUM for compatibility checks
Date: Wed, 28 Oct 2026 03:44:20 +0900
Message-ID: <20261027184420.75223-1-valter.jansons@gmail.com>
X-Mailer: git-send-email 2.56.0
Precedence: list
List-Id: <location.lists.ipfire.org>
List-Subscribe: <https://lists.ipfire.org/>,
<mailto:location+subscribe@lists.ipfire.org?subject=subscribe>
List-Unsubscribe: <https://lists.ipfire.org/>,
<mailto:location+unsubscribe@lists.ipfire.org?subject=unsubscribe>
List-Post: <mailto:location@lists.ipfire.org>
List-Help: <mailto:location+help@lists.ipfire.org?subject=help>
Sender: <location@lists.ipfire.org>
Mail-Followup-To: <location@lists.ipfire.org>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-Rspamd-Action: no action
X-Spamd-Result: default: False [-6.83 / 11.00];
BAYES_HAM(-3.00)[100.00%];
R_DKIM_ALLOW(-1.60)[gmail.com:s=20260707];
DKIM_REPUTATION(-0.97)[-0.96867091216071];
SPF_REPUTATION_HAM(-0.77)[-0.76580553271572];
DMARC_POLICY_ALLOW(-0.50)[gmail.com,none];
R_MISSING_CHARSET(0.50)[];
R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4864::/56];
R_DKIM_ALIGNED(-0.10)[strict];
MX_GOOD(-0.10)[gmail-smtp-in.l.google.com];
MIME_GOOD(-0.10)[text/plain];
IP_REPUTATION_HAM(0.00)[asn: 15169(-0.29), country: US(-0.01),
ip: 2607:f8b0:4864:20::(-0.80)];
RCVD_TLS_LAST(0.00)[];
DWL_DNSWL_NONE(0.00)[gmail.com:dkim];
MIME_TRACE(0.00)[0:+];
FREEMAIL_ENVFROM(0.00)[gmail.com];
ARC_NA(0.00)[];
RCPT_COUNT_ONE(0.00)[1];
FREEMAIL_FROM(0.00)[gmail.com];
TO_MATCH_ENVRCPT_ALL(0.00)[];
DKIM_TRACE(0.00)[gmail.com:+];
ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US];
TO_DN_NONE(0.00)[];
RCVD_COUNT_TWO(0.00)[2];
FROM_EQ_ENVFROM(0.00)[];
RCVD_IN_DNSWL_NONE(0.00)[2607:f8b0:4864:20::102d:from];
ARC_SIGNED(0.00)[lists.ipfire.org:s=202003rsa:i=1];
ALIAS_RESOLVED(0.00)[];
PREVIOUSLY_DELIVERED(0.00)[location@lists.ipfire.org];
RCVD_VIA_SMTP_AUTH(0.00)[];
MID_RHS_MATCH_FROM(0.00)[];
FROM_HAS_DN(0.00)[]
X-Rspamd-Server: mail01.haj.ipfire.org
X-Rspamd-Queue-Id: 4jDfY66Xklz2WH
|
| Series |
lua: Use LUA_VERSION_NUM for compatibility checks
|
|
Commit Message
Valters Jansons
27 Oct 2026, 6:44 p.m. UTC
luaL_setmetatable, luaL_setfuncs, and luaL_newlib were added to
lauxlib.h in Lua 5.2. This project added compatibility functions to
allow building on older Lua versions. It checks whether the version
number is below 502 as to determine if the functions will be missing.
However, LUA_VERSION_RELEASE_NUM was erroneously used for this check.
This value was only added in Lua 5.4, and it follows a different
numbering scheme - including the release/patch number, such as 50409
for Lua 5.4.9. The proper constant to use is LUA_VERSION_NUM, which
follows the expected scheme, such as 504 for Lua 5.4.9. This same
constant is already used later in the same compat.h file.
This commit ensures the older Lua versions build as expected. Otherwise
"Lua 5.1 or older" compatibility logic is triggered even for Lua 5.2 and
5.3 where the preprocessor will automatically replace the undefined
version identifier with zero. Even more worryingly, if someone attempts
to enforce stricter definition safety with `-Werror=undef` then the
libloc 0.9.20 build will fail outright on versions older than Lua 5.4.
Signed-off-by: Valters Jansons <valter.jansons@gmail.com>
---
Essentially, if the packages only build for Lua 5.1 and 5.4 and nobody
sets `-Werror=undef`, then there are no issues. However, if either of
those assumptions breaks, then the builder will not be happy.
src/lua/compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hello Valters, Thank you for the patch, I will merge it shortly. Initially I was developing the Lua bindings against Lua 5.4 which was the latest version at the time. I am also using this in PowerDNS to serve the database over DNS which using LuaJIT which in only compatible to Lua 5.1. God knows why. That is why I was building them that way. Normally the bistro build systems only build against one version of Lua, but Debian can build against multiple, because there are some other things stuck on 5.2, 5.3 and so on. So I am happy to keep the code compatible and I am also happy to build against all of the versions. There will be someone out there using it. —— Regarding your and other people’s submissions, I am very happy to have them and merge them. This is great and I want this project to be a community effort. I want to avoid however that your patches are aging in the branch for a long time until there is a release tagged. So would it be helpful to communicate this beforehand? Is there anything you guys are working on, or integrating this library in? I don’t know much about your use-cases and applications, so I did not really think of reaching out before tagging a release. Please let me know if this would help, so that we can coordinate it better and get any code shipped quickly. We now have an extensive test suite and so making any changes feels a lot less risky and requires less testing out in the field. All the best, -Michael > On 27 Oct 2026, at 18:44, Valters Jansons <valter.jansons@gmail.com> wrote: > > luaL_setmetatable, luaL_setfuncs, and luaL_newlib were added to > lauxlib.h in Lua 5.2. This project added compatibility functions to > allow building on older Lua versions. It checks whether the version > number is below 502 as to determine if the functions will be missing. > > However, LUA_VERSION_RELEASE_NUM was erroneously used for this check. > This value was only added in Lua 5.4, and it follows a different > numbering scheme - including the release/patch number, such as 50409 > for Lua 5.4.9. The proper constant to use is LUA_VERSION_NUM, which > follows the expected scheme, such as 504 for Lua 5.4.9. This same > constant is already used later in the same compat.h file. > > This commit ensures the older Lua versions build as expected. Otherwise > "Lua 5.1 or older" compatibility logic is triggered even for Lua 5.2 and > 5.3 where the preprocessor will automatically replace the undefined > version identifier with zero. Even more worryingly, if someone attempts > to enforce stricter definition safety with `-Werror=undef` then the > libloc 0.9.20 build will fail outright on versions older than Lua 5.4. > > Signed-off-by: Valters Jansons <valter.jansons@gmail.com> > --- > Essentially, if the packages only build for Lua 5.1 and 5.4 and nobody > sets `-Werror=undef`, then there are no issues. However, if either of > those assumptions breaks, then the builder will not be happy. > > src/lua/compat.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/src/lua/compat.h b/src/lua/compat.h > index c1a13a2..a5106c6 100644 > --- a/src/lua/compat.h > +++ b/src/lua/compat.h > @@ -20,7 +20,7 @@ > #include <lua.h> > #include <lauxlib.h> > > -#if LUA_VERSION_RELEASE_NUM < 502 > +#if LUA_VERSION_NUM < 502 > > static inline void luaL_setmetatable(lua_State* L, const char* name) { > luaL_checkstack(L, 1, "not enough stack slots"); > -- > 2.56.0 > >
> Thank you for the patch, I will merge it shortly. Thank you! > I don’t know much about your use-cases and applications, so I did not really think of reaching out before tagging a release. There has been a change in my day-to-day tasks, so I am not actively involved in running libloc in production now. My latest personal use-case was a simple one - for geo-limiting in nftables. However, I continue contributing to ensure updates get shipped to the main Debian archive. I initially thought everything builds fine and didn't notice all the concerns that got flagged later in extended testing suites and more exotic scenarios (for example, this latest issue with older Lua versions cropped up when building with `-Werror=undef` -- otherwise the default preprocessor logic hides it). In any case, I think it's reasonable for you to just tag a release if it looks good for you. If something pops up, I will circle back around. I am not sure if a "release candidate" workflow is really warranted, and I think it would just make the whole process more cumbersome for everyone involved. So, although this cycle of release feels more messy (notably due to there being various packaging changes), I also think that future releases will be more smooth as most concerns get ironed out. Let me know as well, if you see some potential improvements. Best regards Valters
diff --git a/src/lua/compat.h b/src/lua/compat.h index c1a13a2..a5106c6 100644 --- a/src/lua/compat.h +++ b/src/lua/compat.h @@ -20,7 +20,7 @@ #include <lua.h> #include <lauxlib.h> -#if LUA_VERSION_RELEASE_NUM < 502 +#if LUA_VERSION_NUM < 502 static inline void luaL_setmetatable(lua_State* L, const char* name) { luaL_checkstack(L, 1, "not enough stack slots");