Subject: | build with $Config{cccdlflags} |
As noted in https://bugs.debian.org/826009 the Math-GSL build system doesn't currently inject $Config{cccdlflags} into the build. This normally contains -fPIC on at least GNU/Linux. There's -fPIC hardcoded for x86_64 but that's not enough: we have many other architectures in Debian that require -fPIC for compiling code that goes into a dynamic shared object.
ExtUtils::MakeMaker and ExtUtils::CBuilder both seem to use $Config{cccdlflags} everywhere, so presumably Math-GSL should too. I note that inc/GSLBuilder has a copy-pasted compile_c() method that tries to use cccdlflags, but at least on my system there's nothing in $cf->{cccdlflags} that gets passed to the method. The corresponding function in Module::Build has long since been modified to use ExtUtils::CBuilder instead, so perhaps the interface has changed?
For reference, I'm attaching the trivial patch I applied to the Debian package to inject -fPIC everywhere for us.
Thanks for your work on Math-GSL,
--
Niko Tyni (Debian Perl Group)
ntyni@debian.org
Subject: | 0003-Use-Config-cccdlflags-in-the-build.patch |
From 5aeb4938b7e34c124f44297d447b8efbc412c02f Mon Sep 17 00:00:00 2001
From: Niko Tyni <ntyni@debian.org>
Date: Thu, 2 Jun 2016 22:56:25 +0300
Subject: [PATCH] Use $Config{cccdlflags} in the build
This properly injects -fPIC on all Debian architectures, fixing link
failures on at least mips*.
The earlier explicit injection of -fPIC on amd64 becomes redundant with
this but shouldn't harm.
It looks like inc/GSLBuilder.pm tries to use cccdlflags, but doesn't
get them in $cf from Module::Build. This may be because the copy-pasted
compile_c() method has since been rewritten in Module::Build to use
ExtUtils::CBuilder, and the interface may have changed.
Bug-Debian: https://bugs.debian.org/826009
---
Build.PL | 1 +
1 file changed, 1 insertion(+)
diff --git a/Build.PL b/Build.PL
index 7c3940a..5bc1e42 100644
--- a/Build.PL
+++ b/Build.PL
@@ -73,6 +73,7 @@ if ($Config{archname} =~ /x86_64|amd64/ ) {
$ldflags .= ' -fPIC -fno-omit-frame-pointer ';
$ccflags .= ' -fPIC -fno-omit-frame-pointer ';
}
+$ccflags = $Config{cccdlflags} . ' ' . $ldflags;
my @Subsystems = grep { ! /^Test$/ } GSLBuilder::subsystems();
--
2.8.1