Fix a check for PL_infix_plugin

This commit is contained in:
Petr Písař 2023-07-27 12:36:23 +02:00
parent 4358fffb14
commit fee4c47b5b
2 changed files with 84 additions and 3 deletions

View File

@ -0,0 +1,78 @@
From 2e2114556330296d7451b7dd11f9ead7d0b40b4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 26 Jul 2023 13:21:20 +0200
Subject: [PATCH] No special linker flags for checking for PL_infix_plugin
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$Config{libs} lists all discovered libraries for optional perl
extensions. If perl is built dynamically, there is no need to link an
executable to all the libraries. For this purpose there is
$Config{perllibs}.
Actually the extensions can be uninstalled when building
XS-Parse-Keyword and the check would fail like this:
Checking for PL_infix_plugin...
test-56-1.c: In function 'main':
test-56-1.c:6:29: warning: variable 'def' set but not used [-Wunused-but-set-variable]
6 | struct Perl_custom_infix def;
| ^~~
/usr/bin/ld: cannot find -lgdbm: No such file or directory
/usr/bin/ld: cannot find -ldb: No such file or directory
$Config{perllibs} should be used instead.
In reality both $Config{libs} and $Config{perllibs} are wrong because
they list libraries used for building perl. The only library needed for
building perl extensions is -lperl itself. Unfortunately %Config does
not make the distinction and does not provide any variable which would
contain only required flags (i.e. -lperl and additional libraries
necessary for a statically linked perl).
At the end, the Keyword.so is also not linked to all the libraries.
In the actual reallity, the check program does use any perl function
or variable, hence strictely speaking the program does not have to
link to libper.so at all and @linker_flags should be empty.
That's what this patch does.
It might breaks what upstream fixed in 0.24, but for dynamic ELF
systems it's the best solution.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Build.PL | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/Build.PL b/Build.PL
index 27aa208..560dc75 100644
--- a/Build.PL
+++ b/Build.PL
@@ -40,21 +40,11 @@ EOF
{
print "Checking for PL_infix_plugin...\n";
- # Teach $cc how to find and link to libperl
- require Config;
- require Text::ParseWords;
-
- my @linker_flags = (
- "-L" . File::Spec->catdir($Config::Config{archlibexp}, "CORE"),
- "-lperl", Text::ParseWords::shellwords( $Config::Config{libs} ),
- );
-
my $have_pl_infix_plugin = 0;
$have_pl_infix_plugin = 1 if grep { $_ eq "--have-pl_infix_plugin" } @ARGV;
$have_pl_infix_plugin ||= $cc->try_compile_run(
- extra_linker_flags => \@linker_flags,
source => <<'EOF'
#include "EXTERN.h"
#include "perl.h"
--
2.41.0

View File

@ -3,12 +3,14 @@
Name: perl-XS-Parse-Keyword
Version: 0.36
Release: 1%{?dist}
Release: 2%{?dist}
Summary: XS functions to assist in parsing keyword syntax
License: GPL-1.0-or-later OR Artistic-1.0-Perl
URL: https://metacpan.org/release/XS-Parse-Keyword
Source0: https://cpan.metacpan.org/authors/id/P/PE/PEVANS/XS-Parse-Keyword-%{version}.tar.gz
Source1: macros.perl-XS-Parse-Keyword
# Fix a check for PL_infix_plugin, not suitable for upstream, bug #2226738
Patch0: XS-Parse-Keyword-0.36-No-special-linker-flags-for-checking-for-PL_infix_pl.patch
BuildRequires: coreutils
BuildRequires: perl-devel
BuildRequires: perl-generators
@ -16,13 +18,11 @@ BuildRequires: perl-interpreter
BuildRequires: perl(:VERSION) >= 5.14
BuildRequires: perl(B)
BuildRequires: perl(base)
BuildRequires: perl(Config)
BuildRequires: perl(ExtUtils::CBuilder)
BuildRequires: perl(ExtUtils::CChecker) >= 0.11
BuildRequires: perl(lib)
BuildRequires: perl(Module::Build)
BuildRequires: perl(strict)
BuildRequires: perl(Text::ParseWords)
BuildRequires: perl(warnings)
# Run-time:
BuildRequires: perl(constant)
@ -146,6 +146,9 @@ export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print
%{_libexecdir}/%{name}
%changelog
* Wed Jul 26 2023 Petr Pisar <ppisar@redhat.com> - 0.36-2
- Fix a check for PL_infix_plugin
* Tue Jul 25 2023 Petr Pisar <ppisar@redhat.com> - 0.36-1
- 0.36 bump