[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Bug#930980: libcrypt-openssl-dsa-perl FTCBFS: configures and builds for the wrong architecture

On Tue, Oct 15, 2019 at 11:41:09PM +0200, gregor herrmann wrote:
> On Tue, 15 Oct 2019 19:30:17 +0200, Helmut Grohne wrote:
> > I'm not sure whether replacing perl with perl-xs-dev in Build-Depends
> > will do. If that keeps building natively, it'll also work for cross. If
> > something goes missing (some perl modules, build scripts, something
> > else), you'll likely need a full, native perl. To get that, you need to
> > use "perl:any" or "perl:native". The difference is subtle. I think :any
> > works for a little longer (since oldoldoldstable rather than
> > oldoldstable), but :native is more technically correct. Doesn't really
> > matter, which one you use.

Conceptually, we need the full perl:native for the build toolchain
(mostly ExtUtils::MakeMaker and its dependencies, some of which like
Cwd are architecture specific.) So I think we should use

 Build-Depends: perl:native, perl-xs-dev

Dropping perl would not break the build as dpkg-dev (and indeed debhelper)
Depends on perl:any, but it would be a latent bug IMO.

> I'm very much in favour of finding a simple scheme and not several
> options, like:
> * arch:all -> B-D: perl
> * arch:any -> B-D: perl:native, perl-xs-dev
> I hope something like that is possible.

I'm afraid the above choice between two options is pretty much exactly
what I was aiming for. Differentiating between arch:any XS module
packages and arch:all pure-Perl module packages seems correct and not
very onerous to me. There's no sense in doing this conversion for the
myriad arch:all packages.

If we really need to make the build dependencies for arch:all packages
equivalent to arch:any packages, I suppose B-D: perl:native, perl-xs-dev
would work for them too. The :native part is presumably a no-op for
arch:all builds, and perl-xs-dev would not hurt but the name would
be weird.

So if this is a hard requirement, I guess we should reopen the naming
part while it's not too late?

In other news, I'm attaching a prototype implementation for
Debian::Debhelper::Buildsystem::perl_makemaker that seems to work great;
I've been able to cross build all the simple XS modules [1] I tested so
far after fixing the build dependencies to "perl:native, perl-xs-dev",
adding <!nocheck> annotations, and a :native qualifier in one case
(libjson-xs-perl needing libcanary-stability-perl in the configure phase).

I haven't looked at perl_build (= Module::Build / Build.PL based build
system) support yet.

>From 6c45694964ac8685bab76cbb3115c9905b5099de Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Tue, 15 Oct 2019 16:51:47 +0300
Subject: [PATCH] perl_makemaker: support cross building XS modules

 .../Debhelper/Buildsystem/perl_makemaker.pm   | 21 +++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm b/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
index 6a6f452..c267eae 100644
--- a/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
+++ b/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::perl_makemaker;
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value is_cross_compiling);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 use Config;
@@ -51,12 +51,29 @@ sub configure {
 	if ($ENV{CFLAGS} && ! compat(8)) {
+	my $cross_flag = '';
+	if (is_cross_compiling()) {
+		my $triplet = dpkg_architecture_value("DEB_HOST_MULTIARCH");
+		my $perl_version = $Config{version};
+		my $incdir = "/usr/lib/$triplet/perl/cross-config-${perl_version}";
+		die("Fatal: $incdir/Config.pm does not exist (missing build dependency on perl-xs-dev?)")
+		   if !-e "$incdir/Config.pm";
+		$cross_flag = "-I$incdir";
+	}
 	if ($ENV{LDFLAGS} && ! compat(8)) {
-		push @flags, "LD=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}";
+		my $ld = $Config{ld};
+		if (is_cross_compiling()) {
+			$ld = qx/perl $cross_flag -MConfig -e 'print \$Config{ld}'/;
+		}
+		push @flags, "LD=$ld $ENV{CFLAGS} $ENV{LDFLAGS}";
 	push(@perl_flags, '-I.') if compat(10);
+	if (is_cross_compiling()) {
+		push @perl_flags, $cross_flag;
+	}
 	$this->doit_in_sourcedir("perl", @perl_flags, "Makefile.PL", "INSTALLDIRS=vendor",
 		# if perl_build is not tested first, need to pass packlist
 		# option to handle fallthrough case

Reply to: