Fix building on 32-bit platforms by respecting perl's ccflags

This commit is contained in:
Petr Písař 2017-03-15 09:17:39 +01:00
parent 9fdb12fd79
commit 2ad1cf9f15
2 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,50 @@
From a4ff521ebcb5f3d65e723b13821d53e7e4e320ad Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 15 Mar 2017 09:03:34 +0100
Subject: [PATCH] Respect $Config{ccflags}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
$Config{ccflags} must be passed to all XS compiler invocations
because they define ABI. Not doing so can lead to mismatched shared
library ABI as can bee seen on 32-bit perl with enabled 64-bit file
offsets (-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64):
armv7hl-redhat-linux-gnueabi-gcc -c -I/usr/include/pkgconf -DMY_PKGCONF_VERSION=1.3.0 -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=hard -DVERSION=\"0.06\" -DXS_VERSION=\"0.06\" -fPIC "-I/usr/lib/perl5/CORE" LibPkgConf.c
[...]
make test
"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- LibPkgConf.bs blib/arch/auto/PkgConfig/LibPkgConf/LibPkgConf.bs 644
PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
LibPkgConf.c: loadable library and perl binaries are mismatched (got handshake key 0x8e00080, needed 0x9000080)
t/00_diag.t ...
Dubious, test returned 1 (wstat 256, 0x100)
This patch fixes Makefile.PL to respect ccflags value provided by perl.
Signed-off-by: Petr Písař <ppisar@redhat.com>
---
Makefile.PL | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/Makefile.PL b/Makefile.PL
index af43fe5..2c99278 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -94,8 +94,12 @@ sub try
return ('','', '');
}
-my($ccflags, $ldflags, $version) = try 'libpkgconf';
+my $ccflags = $Config{ccflags};
+my($libpkgconf_cflags, $ldflags, $version) = try 'libpkgconf';
+if (defined $libpkgconf_cflags and $libpkgconf_cflags ne '') {
+ $ccflags .= ' ' . $libpkgconf_cflags;
+}
unless($alien)
{
$ccflags .= "-DMY_PKGCONF_VERSION=$version";
--
2.7.4

View File

@ -5,6 +5,9 @@ Summary: Interface to pkg-config files via libpkgconf
License: GPL+ or Artistic
URL: http://search.cpan.org/dist/PkgConfig-LibPkgConf/
Source0: http://www.cpan.org/authors/id/P/PL/PLICEASE/PkgConfig-LibPkgConf-%{version}.tar.gz
# Fix building on 32-bit platforms by respecting perl's ccflags,
# <https://github.com/plicease/PkgConfig-LibPkgConf/pull/5>
Patch0: PkgConfig-LibPkgConf-0.06-Respect-Config-ccflags.patch
BuildRequires: findutils
BuildRequires: gcc
BuildRequires: make
@ -45,6 +48,7 @@ files. This package provides a Perl-level API using libpkgconf to these files.
%prep
%setup -q -n PkgConfig-LibPkgConf-%{version}
%patch0 -p1
%build
unset FFI_PLATYPUS_DEBUG