summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiko Tyni <ntyni@debian.org>2019-10-17 07:55:28 +0100
committerNiko Tyni <ntyni@debian.org>2019-10-18 17:52:44 +0100
commite3458777c16a5371df1677a308dc92cf72caced6 (patch)
tree6436c3f2d540f363c29d4715fbcd40c9d585bf1d
parent07f286f700cb41e06a6cc48b8ae7064e37b4f408 (diff)
downloaddebhelper-e3458777c16a5371df1677a308dc92cf72caced6.tar.gz
perl_build: support cross building XS modules
When cross building, run Build.PL and Build with host arch Config.pm (provided by the perl-xs-dev package since perl/5.30.0-7) first on @INC. We need to set PERL5LIB because Module::Build forks a child process to sanity check the Config it's seeing, so the modified search path has to be propagated via the environment.
-rw-r--r--lib/Debian/Debhelper/Buildsystem/perl_build.pm22
1 files changed, 19 insertions, 3 deletions
diff --git a/lib/Debian/Debhelper/Buildsystem/perl_build.pm b/lib/Debian/Debhelper/Buildsystem/perl_build.pm
index 2817797c..4e10d361 100644
--- a/lib/Debian/Debhelper/Buildsystem/perl_build.pm
+++ b/lib/Debian/Debhelper/Buildsystem/perl_build.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::perl_build;
use strict;
use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat is_cross_compiling perl_cross_incdir);
use parent qw(Debian::Debhelper::Buildsystem);
use Config;
@@ -29,7 +29,17 @@ sub check_auto_buildable {
sub do_perl {
my $this=shift;
- $this->doit_in_sourcedir("perl", @_);
+ my %options;
+ if (is_cross_compiling()) {
+ my $cross_incdir = perl_cross_incdir();
+ if (defined $cross_incdir) {
+ my $perl5lib = $cross_incdir;
+ $perl5lib .= $Config{path_sep} . $ENV{PERL5LIB}
+ if defined $ENV{PERL5LIB};
+ $options{update_env} = { PERL5LIB => $perl5lib };
+ }
+ }
+ $this->doit_in_sourcedir(\%options, "perl", @_);
}
sub new {
@@ -47,7 +57,13 @@ sub configure {
push @flags, "--config", "optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}";
}
if ($ENV{LDFLAGS} && ! compat(8)) {
- push @flags, "--config", "ld=$Config{ld} $ENV{CFLAGS} $ENV{LDFLAGS}";
+ my $ld = $Config{ld};
+ if (is_cross_compiling()) {
+ my $incdir = perl_cross_incdir();
+ $ld = qx/perl -I$incdir -MConfig -e 'print \$Config{ld}'/
+ if defined $incdir;
+ }
+ push @flags, "--config", "ld=$ld $ENV{CFLAGS} $ENV{LDFLAGS}";
}
push(@perl_flags, '-I.') if compat(10);
$this->do_perl(@perl_flags, "Build.PL", "--installdirs", "vendor", @flags, @_);