Bug#1040655: liblmdb-file-perl: FTBFS with Perl 5.38: undefined reference to `Perl_do_vecget'

2023-08-20 Thread Niko Tyni
Control: tag -1 patch

On Sat, Jul 08, 2023 at 07:17:23PM +0300, Niko Tyni wrote:
> Source: liblmdb-file-perl
> Version: 0.12-4
> Severity: important
> Tags: ftbfs trixie sid upstream
> Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=148421
> User: debian-p...@lists.debian.org
> Usertags: perl-5.38-transition
> 
> This package fails to build with Perl 5.38 (currently in experimental).

>   /usr/bin/ld: LMDB.o: in function `XS_LMDB_File__cmp':
>   ././LMDB.c:2731: undefined reference to `Perl_do_vecget'

Here's a patch I just sent upstream that works around this by copying
a simplified version of Perl_do_vecget into this module.
-- 
Niko Tyni   nt...@debian.org
>From 1469c3d13a99f401ac2457b37564bc7aedcf050a Mon Sep 17 00:00:00 2001
From: Niko Tyni 
Date: Sat, 19 Aug 2023 21:08:33 +0100
Subject: [PATCH] Lift vecget function from Perl core for 5.38 compatibility
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

As suggested by Petr Písař.

Simplified to only handle size <= 8 as the module only needs size==2.

Bug: https://rt.cpan.org/Ticket/Display.html?id=148421
Bug-Debian: https://bugs.debian.org/1040655
---
 LMDB.xs | 45 -
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/LMDB.xs b/LMDB.xs
index f474abb..647e463 100644
--- a/LMDB.xs
+++ b/LMDB.xs
@@ -110,6 +110,49 @@ S_mySvPVutf8(pTHX_ SV *sv, STRLEN *const len) {
 
 typedef IV MyInt;
 
+/* lifted from Perl core and simplified [rt.cpan.org #148421] */
+STATIC UV
+my_do_vecget(pTHX_ SV *sv, STRLEN offset, int size)
+{
+STRLEN srclen;
+const I32 svpv_flags = ((PL_op->op_flags & OPf_MOD || LVRET)
+  ? SV_UNDEF_RETURNS_NULL : 0);
+unsigned char *s = (unsigned char *)
+SvPV_flags(sv, srclen, (svpv_flags|SV_GMAGIC));
+UV retnum = 0;
+
+if (!s) {
+  s = (unsigned char *)"";
+}
+
+/* aka. PERL_ARGS_ASSERT_DO_VECGET */
+assert(sv);
+/* sanity checks to make sure the premises for our simplifications still hold */
+assert(LMDB_OFLAGN <= 8);
+if (size != LMDB_OFLAGN)
+Perl_croak(aTHX_ "This is a crippled version of vecget that supports size==%d (LMDB_OFLAGN)", LMDB_OFLAGN);
+
+if (SvUTF8(sv)) {
+if (Perl_sv_utf8_downgrade_flags(aTHX_ sv, TRUE, 0)) {
+/* PVX may have changed */
+s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+}
+else {
+Perl_croak(aTHX_ "Use of strings with code points over 0xFF"
+ " as arguments to vec is forbidden");
+}
+}
+
+STRLEN bitoffs = ((offset % 8) * size) % 8;
+STRLEN uoffset = offset / (8 / size);
+
+if (uoffset >= srclen)
+return 0;
+
+retnum = (s[uoffset] >> bitoffs) & nBIT_MASK(size);
+return retnum;
+}
+
 static void
 populateStat(pTHX_ HV** hashptr, int res, MDB_stat *stat)
 {
@@ -152,7 +195,7 @@ typedef struct {
 
 START_MY_CXT
 
-#define LMDB_OFLAGS TOHIWORD(Perl_do_vecget(aTHX_ MY_CXT.OFlags, dbi, LMDB_OFLAGN))
+#define LMDB_OFLAGS TOHIWORD(my_do_vecget(aTHX_ MY_CXT.OFlags, dbi, LMDB_OFLAGN))
 #define MY_CMP   *av_fetch(MY_CXT.Cmps, MY_CXT.curdb, 1)
 #define MY_DCMP	 *av_fetch(MY_CXT.DCmps, MY_CXT.curdb, 1)
 
-- 
2.39.1



Bug#1040655: liblmdb-file-perl: FTBFS with Perl 5.38: undefined reference to `Perl_do_vecget'

2023-07-08 Thread Niko Tyni
Source: liblmdb-file-perl
Version: 0.12-4
Severity: important
Tags: ftbfs trixie sid upstream
Forwarded: https://rt.cpan.org/Public/Bug/Display.html?id=148421
User: debian-p...@lists.debian.org
Usertags: perl-5.38-transition

This package fails to build with Perl 5.38 (currently in experimental).

  x86_64-linux-gnu-gcc -g -O2 -ffile-prefix-map=/<>=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro  -shared 
-L/usr/local/lib -fstack-protector-strong  LMDB.o  -o 
blib/arch/auto/LMDB_File/LMDB_File.so  \
 -llmdb   \

  /usr/bin/ld: LMDB.o: in function `XS_LMDB__Txn__dbi_open':
  ././LMDB.xs:835: undefined reference to `Perl_do_vecget'
  /usr/bin/ld: LMDB.o: in function `XS_LMDB_File__put':
  ././LMDB.c:2577: undefined reference to `Perl_do_vecget'
  /usr/bin/ld: LMDB.o: in function `XS_LMDB__Cursor__del':
  ././LMDB.c:2191: undefined reference to `Perl_do_vecget'
  /usr/bin/ld: LMDB.o: in function `XS_LMDB_File__get':
  ././LMDB.c:2517: undefined reference to `Perl_do_vecget'
  /usr/bin/ld: LMDB.o: in function `XS_LMDB_File__cmp':
  ././LMDB.c:2731: undefined reference to `Perl_do_vecget'
  /usr/bin/ld: LMDB.o:././LMDB.c:2785: more undefined references to 
`Perl_do_vecget' follow
  /usr/bin/ld: blib/arch/auto/LMDB_File/LMDB_File.so: hidden symbol 
`Perl_do_vecget' isn't defined
  /usr/bin/ld: final link failed: bad value
  collect2: error: ld returned 1 exit status
  make[1]: *** [Makefile:488: blib/arch/auto/LMDB_File/LMDB_File.so] Error 1
  make[1]: Leaving directory '/<>'
  dh_auto_build: error: make -j4 returned exit code 2
  make: *** [debian/rules:4: binary-arch] Error 25

Full build log at

  
http://perl.debian.net/rebuild-logs/perl-5.38/liblmdb-file-perl_0.12-4/liblmdb-file-perl_0.12-4+b3_amd64-2023-06-28T20:44:13Z.build

-- 
Niko Tyni   nt...@debian.org