Control: tag -1 patch

On Wed, Jul 05, 2023 at 01:21:15PM +0300, Niko Tyni wrote:
> Source: libdata-swap-perl
> Version: 0.08-2
> Severity: important
> Tags: ftbfs trixie sid
> Forwarded: https://rt.cpan.org/Ticket/Display.html?id=144619
> User: debian-p...@lists.debian.org
> Usertags: perl-5.38-transition
> 
> This package fails to build from source with Perl 5.38 (currently in
> experimental):
> 
>   x86_64-linux-gnu-gcc -g -O2 -ffile-prefix-map=/<<PKGBUILDDIR>>=. 
> -fstack-protector-strong -Wformat -Werror=format-security -Wl,-z,relro 
> -Wl,-z,now  -shared -L/usr/local/lib -fstack-protector-strong  Swap.o  -o 
> blib/arch/auto/Data/Swap/Swap.so  \
>         \
>     
>   /usr/bin/ld: Swap.o: in function `extract_backrefs':
>   ././Swap.c:63: undefined reference to `Perl_hv_backreferences_p'
>   /usr/bin/ld: Swap.o: in function `install_backrefs':
>   ././Swap.c:88: undefined reference to `Perl_hv_backreferences_p'
>   /usr/bin/ld: blib/arch/auto/Data/Swap/Swap.so: hidden symbol 
> `Perl_hv_backreferences_p' isn't defined
>   /usr/bin/ld: final link failed: bad value
>   collect2: error: ld returned 1 exit status
>   make[1]: *** [Makefile:474: blib/arch/auto/Data/Swap/Swap.so] Error 1

This is because 5.38 hides internal C API functions with with 
__attribute__((hidden)).
Perl_hv_backreferences_p was never part of the official API.

That said, the attached patch works around this by duplicating the
functionality from the core function. It's not a proper solution but I
guess it could buy some time. The module is clearly abandoned upstream
so I suppose we should aim for its eventual removal from Debian?

I've no idea how bad form this is but it seems to work for me on perls
at least from 5.20 up to 5.38.

Tentatively adding the patch tag...
-- 
Niko Tyni   nt...@debian.org
>From c41631c7d037b455053a235b507ff925db4dd0ba Mon Sep 17 00:00:00 2001
From: Niko Tyni <nt...@debian.org>
Date: Tue, 18 Jul 2023 15:41:50 +0100
Subject: [PATCH] Work around Perl_hv_backreferences_p hidden in 5.38

Bug-Debian: https://bugs.debian.org/1040386
Bug: https://rt.cpan.org/Ticket/Display.html?id=144619
---
 Swap.xs | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/Swap.xs b/Swap.xs
index 36edc0a..8730499 100644
--- a/Swap.xs
+++ b/Swap.xs
@@ -55,12 +55,23 @@
 
 #define DA_DEREF_ERR "Can't deref string (\"%.32s\")"
 
+/* copied (and slightly simplified) from core because Perl_hv_backreferences_p
+   is hidden on all platforms since 5.38 */
+
+STATIC AV **my_backreferences_p(pTHX_ HV *hv) {
+	if (!SvOOK(hv)) {
+		hv_iterinit(hv);
+	}
+	struct xpvhv_aux * const iter = HvAUX(hv);
+	return &(iter->xhv_backreferences);
+}
+
 STATIC AV *extract_backrefs(pTHX_ SV *sv) {
 	AV *av = NULL;
 
 #if BACKREFS_IN_HV
 	if (SvTYPE(sv) == SVt_PVHV && SvOOK(sv)) {
-		AV **const avp = Perl_hv_backreferences_p(aTHX_ (HV *) sv);
+		AV **const avp = my_backreferences_p(aTHX_ (HV *) sv);
 		av = *avp;
 		*avp = NULL;
 	}
@@ -85,7 +96,7 @@ STATIC void install_backrefs(pTHX_ SV *sv, AV *backrefs) {
 
 #if BACKREFS_IN_HV
 	if (SvTYPE(sv) == SVt_PVHV) {
-		AV **const avp = Perl_hv_backreferences_p(aTHX_ (HV *) sv);
+		AV **const avp = my_backreferences_p(aTHX_ (HV *) sv);
 		*avp = backrefs;
 		return;
 	}
-- 
2.39.1

Reply via email to