Skip Menu |

This queue is for tickets about the ExtUtils-PkgConfig CPAN distribution.

Report information
The Basics
Id: 84026
Status: resolved
Priority: 0/
Queue: ExtUtils-PkgConfig

People
Owner: XAOC [...] cpan.org
Requestors: myra.nelson [...] hughes.net
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.14
Fixed in: (no value)



Subject: ExtUtils::PkgConfig version 1.14 fails to behave as system pkg-config command
I encountered the following problem with ExtUtils::PkgConfig while trying to install Math::GSL. I'm pinpointing the problem to ExtUtils::PkgConfig based on other tests I ran after the build failure. Attached are some simple tests and the results I wrote using IPC::Cmd to run the system pkg-config utility to test the output. Using the system pkg-config utility gsl is located and the results are the same as gsl-config. The attached files are PkgConf gsl.pl, pkgconfig.pl, and ipccmd_results.txt. [myra@gandalf ~/workspace/perl/Math-GSL/Math-GSL-0.27-test]$ perl Build.PL Checking for GSL.. Found GSL 1.15 (via gsl-config) installed in /usr, CFLAGS=-I/usr/include, -L/usr/lib -lgsl -lgslcblas -lm Asking ExtUtils::PkgConfig with ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/pkgconfig:/usr/libdata/pkgconfig:/usr/local/libdata/pkgconfig:/opt/pkgconfig: *** can't find cflags for "gsl" *** is it properly installed and available in PKG_CONFIG_PATH? at Build.PL line 157. ExtUtils::PkgConfig version (1.14) installed. ExtUtils::Depends (0.304) installed ls /usr/lib/pkgconfig | grep gsl gsl.pc most /usr/lib/pkgconfig/gsl.pc prefix=/usr exec_prefix=/usr libdir=/usr/lib includedir=/usr/include GSL_CBLAS_LIB=-lgslcblas Name: GSL Description: GNU Scientific Library Version: 1.15 Libs: -L/usr/lib -lgsl ${GSL_CBLAS_LIB} -lm -lm Cflags: -I/usr/include perl -V Summary of my perl5 (revision 5 version 17 subversion 9) configuration: Platform: osname=linux, osvers=3.8.2-1-arch, archname=x86_64-linux-thread-multi uname='linux gandalf 3.8.2-1-arch #1 smp preempt mon mar 4 09:06:43 cet 2013 x86_64 gnulinux ' config_args='-de -Dprefix=/home/myra/perl5/perlbrew/perls/perl-5.17.9 -Dusethreads -Duseshrplib -Doptimize=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -Dcccdlflags=-fPIC -Dlddlflags=-shared -Wl,-O1,--sort-common,--as-needed,-z,relro -Dusedevel -Aeval:scriptdir=/home/myra/perl5/perlbrew/perls/perl-5.17.9/bin' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.7.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib /lib64 /usr/lib64 libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.17.so, so=so, useshrplib=true, libperl=libperl.so gnulibc_version='2.17' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/home/myra/perl5/perlbrew/perls/perl-5.17.9/lib/5.17.9/x86_64-linux-thread-multi/CORE' cccdlflags='-fPIC', lddlflags='-shared -Wl,-O1,--sort-common,--as-needed,-z,relro -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: HAS_TIMES MULTIPLICITY PERLIO_LAYERS PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP PERL_NEW_COPY_ON_WRITE PERL_PRESERVE_IVUV PERL_USE_DEVEL USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_LOCALE USE_LOCALE_COLLATE USE_LOCALE_CTYPE USE_LOCALE_NUMERIC USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Mar 6 2013 23:15:22 %ENV: PERLBREW_BASHRC_VERSION="0.59" PERLBREW_HOME="/home/myra/.perlbrew" PERLBREW_MANPATH="/home/myra/perl5/perlbrew/perls/perl-5.17.9/man" PERLBREW_PATH="/home/myra/perl5/perlbrew/bin:/home/myra/perl5/perlbrew/perls/perl-5.17.9/bin" PERLBREW_PERL="perl-5.17.9" PERLBREW_ROOT="/home/myra/perl5/perlbrew" PERLBREW_VERSION="0.59" @INC: /home/myra/perl5/perlbrew/perls/perl-5.17.9/lib/site_perl/5.17.9/x86_64-linux-thread-multi /home/myra/perl5/perlbrew/perls/perl-5.17.9/lib/site_perl/5.17.9 /home/myra/perl5/perlbrew/perls/perl-5.17.9/lib/5.17.9/x86_64-linux-thread-multi /home/myra/perl5/perlbrew/perls/perl-5.17.9/lib/5.17.9
Subject: gsl.pl
use Modern::Perl '2012' ; use IPC::Cmd qw[can_run run run_forked]; use Perl6::Say ; # system gsl-config # my $full_path1 = can_run('gsl-config') or warn 'gsl is not installed!'; my $full_path2 = can_run('pkg-config') or warn 'pkg is not installed!'; my $cmd1 = "$full_path1 --version"; my $cmd2 = "$full_path1 --prefix"; my $cmd3 = "$full_path1 --libs"; my $cmd4 = "$full_path1 --cflags"; my $cmd5 = "$full_path2 --exists gsl"; my $cmd6 = "$full_path2 --modversion gsl"; my $cmd7 = "$full_path2 --libs gsl"; my $cmd8 = "$full_path2 --cflags gsl"; my $buffer; say "Testing gsl with system gsl-config using IPC::Cmd" ; ## in scalar context if( scalar run( command => $cmd1, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd2, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd3, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd4, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } say "Testing gsl with system pkg-config using IPC::Cmd" ; if( scalar run( command => $cmd5, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd6, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd7, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; } if( scalar run( command => $cmd8, verbose => 1, buffer => \$buffer, timeout => 20 ) ) { say "result: $buffer\n"; }
Subject: pkgconfig.pl
#use Test::Most 'no_plan' ; use Modern::Perl '2012' ; use Config; use Data::Dumper; use Module::Build; use File::Spec::Functions qw/:ALL/; use ExtUtils::PkgConfig ; use Perl6::Say ; #this test passes! #BEGIN { # use_ok( 'ExtUtils::PkgConfig' ); #} say "Asking ExtUtils::PkgConfig with ENV{PKG_CONFIG_PATH}=" . ($ENV{PKG_CONFIG_PATH} || '') . "\n"; my %gsl_pkgcfg = ExtUtils::PkgConfig->find ('gsl'); my $pkgcfg_ver = $gsl_pkgcfg{'modversion'};
Subject: ipccmd_results.txt
[myra@gandalf ~/workspace/perl/Math-GSL/ipccmd]$ perl gsl.pl Testing gsl with system gsl-config using IPC::Cmd Running [/usr/bin/gsl-config --version]... 1.15 result: 1.15 Running [/usr/bin/gsl-config --prefix]... /usr result: /usr Running [/usr/bin/gsl-config --libs]... -L/usr/lib -lgsl -lgslcblas -lm result: -L/usr/lib -lgsl -lgslcblas -lm Running [/usr/bin/gsl-config --cflags]... -I/usr/include result: -I/usr/include Testing gsl with system pkg-config using IPC::Cmd Running [/usr/bin/pkg-config --exists gsl]... result: -I/usr/include Running [/usr/bin/pkg-config --modversion gsl]... 1.15 result: 1.15 Running [/usr/bin/pkg-config --libs gsl]... -lgsl -lgslcblas -lm result: -lgsl -lgslcblas -lm
From: ppisar [...] redhat.com
Dne Po 18.bře.2013 12:43:05, myra.nelson@hughes.net napsal(a): Show quoted text
> [myra@gandalf ~/workspace/perl/Math-GSL/Math-GSL-0.27-test]$ perl > Build.PL > Checking for GSL.. > Found GSL 1.15 (via gsl-config) installed in /usr, > CFLAGS=-I/usr/include, -L/usr/lib -lgsl -lgslcblas -lm > > Asking ExtUtils::PkgConfig with > ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/pkgconfig:/usr/libdata/pkgconfig:/usr/local/libdata/pkgconfig:/opt/pkgconfig: > > *** can't find cflags for "gsl" > *** is it properly installed and available in PKG_CONFIG_PATH? > at Build.PL line 157. > > ExtUtils::PkgConfig version (1.14) installed. > ExtUtils::Depends (0.304) installed > > ls /usr/lib/pkgconfig | grep gsl > gsl.pc > > most /usr/lib/pkgconfig/gsl.pc > > prefix=/usr > exec_prefix=/usr > libdir=/usr/lib > includedir=/usr/include > GSL_CBLAS_LIB=-lgslcblas > > Name: GSL > Description: GNU Scientific Library > Version: 1.15 > Libs: -L/usr/lib -lgsl ${GSL_CBLAS_LIB} -lm -lm > Cflags: -I/usr/include >
Attached patch should fix it. The patch is maybe to much benevolent. I'm not a master of pkg-config specification.
Subject: ExtUtils-PkgConfig-1.12-Empty-cflags-are-valid-cflags.patch
From be149af1735ba52aefd85d6d318b11e45c3244b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com> Date: Mon, 22 Jul 2013 09:32:29 +0200 Subject: [PATCH] Empty cflags are valid cflags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ExtUtils::PkgConfig-find() croaked on emptry cflags: $ pkg-config --cflags 'libffi >= 3.0.0'| hexdump -C 00000000 0a |.| 00000001 $ perl -MData::Dumper -MExtUtils::PkgConfig -e 'print Dumper(ExtUtils::PkgConfig->find(q{libffi}))' *** can't find cflags for "libffi" *** is it properly installed and available in PKG_CONFIG_PATH? at -e line 1. That's wrong. Empty string cflags are valid cflafs too. <https://rt.cpan.org/Public/Bug/Display.html?id=84026> Signed-off-by: Petr Písař <ppisar@redhat.com> --- lib/ExtUtils/PkgConfig.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ExtUtils/PkgConfig.pm b/lib/ExtUtils/PkgConfig.pm index 075d8dc..0f68256 100644 --- a/lib/ExtUtils/PkgConfig.pm +++ b/lib/ExtUtils/PkgConfig.pm @@ -129,7 +129,7 @@ sub find { $data{$what} =~ s/[\015\012]+$//; croak "*** can't find $what for \"$data{pkg}\"\n" . "*** is it properly installed and available in PKG_CONFIG_PATH?\n" - unless $data{$what}; + unless defined $data{$what}; } return %data; } -- 1.8.1.4
Subject: Re: [rt.cpan.org #84026] ExtUtils::PkgConfig version 1.14 fails to behave as system pkg-config command
Date: Tue, 06 Aug 2013 20:05:28 +0200
To: bug-ExtUtils-PkgConfig [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 22.07.2013 09:44, Petr Pisar via RT wrote: Show quoted text
> Attached patch should fix it. The patch is maybe to much benevolent. > I'm not a master of pkg-config specification.
The patch looks good to me, thanks. Can you be bothered to also provide a unit test?
From: myra.nelson [...] hughes.net
On Tue Aug 06 14:05:50 2013, TSCH wrote: Show quoted text
> On 22.07.2013 09:44, Petr Pisar via RT wrote:
> > Attached patch should fix it. The patch is maybe to much benevolent. > > I'm not a master of pkg-config specification.
> > The patch looks good to me, thanks. Can you be bothered to also provide > a unit test?
This patch would be one solution, but gsl.pc on my machine has the following line Cflags: -I/usr/include and something I seriously overlooked on the initial report was running pkg-config --cflags gsl from the command line returns zip, zilch, nada, nothing, etc adnausem. So simply bypassing the check, at least in this case, seems wrong. I just tested the Math::GSL install again for reference with the following results Running [/usr/bin/perl -e use strict; BEGIN { my $old = select STDERR; $|++; select $old; $|++; $0 $ Checking for GSL.. Found GSL 1.15 (via gsl-config) installed in /usr, CFLAGS=-I/usr/include, -L/usr/lib -lgsl -lgslcbl$ Asking ExtUtils::PkgConfig with ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/l$ *** can't find cflags for "gsl" *** is it properly installed and available in PKG_CONFIG_PATH? at /home/myra/.cpanplus/5.18.1/build/Math-GSL-0.27/Build.PL line 156. BEGIN failed--compilation aborted at -e line 1. [ERROR] Build.PL failed: Checking for GSL.. Found GSL 1.15 (via gsl-config) installed in /usr, CFLAGS=-I/usr/include, -L/usr/lib -lgsl -lgslcbl$ Asking ExtUtils::PkgConfig with ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/l$ *** can't find cflags for "gsl" *** is it properly installed and available in PKG_CONFIG_PATH? at /home/myra/.cpanplus/5.18.1/build/Math-GSL-0.27/Build.PL line 156. BEGIN failed--compilation aborted at -e line 1. As can be seen, gsl is found via gsl-config and the attached test script finds gsl with pkg-config, but no cflags are returned via pkg-config. I've attached two scripts that return values for gsl and alsa. They are based on the routines used in ExtUtils-PkgConfig-1.14/lib/ExtUtils/PkgConfig.pm. There a couple of simplifications but the results should be the same. It appears there is a problem returning the --cflags variable from gsl.pc. On to more research. Myra
Subject: pkgconfig_alsa.pl
#!/usr/bin/perl use Modern::Perl '2013' ; use Carp ; my $candidate = "alsa" ; my $output = qx/pkg-config --exists --print-errors "$candidate" 2>&1/ ; if ( not $output ) { say "package found: $candidate" ; } my $output2 = qx/pkg-config --exists "$candidate" 2>&1/ ; if ( not $output2 ) { say "package found: $candidate" ; } my @output3 = qx/pkg-config --libs "$candidate" 2>&1/ ; if (@output3) { say $output3[0] ; } my $output4 = qx/pkg-config --cflags "$candidate" 2>&1/ ; if ($output4) { say $output4; } else { say "somethings fubar" ; }
Subject: pkgconfig_gsl.pl
#!/usr/bin/perl use Modern::Perl '2013' ; use Carp ; my $candidate = "gsl" ; my $output = qx/pkg-config --exists --print-errors "$candidate" 2>&1/ ; if ( not $output ) { say "package found: $candidate" ; } my $output2 = qx/pkg-config --exists "$candidate" 2>&1/ ; if ( not $output2 ) { say "package found: $candidate" ; } my @output3 = qx/pkg-config --libs "$candidate" 2>&1/ ; if (@output3) { say $output3[0] ; } my $output4 = qx/pkg-config --cflags "$candidate" 2>&1/ ; if ($output4) { say $output4; } else { say "somethings fubar" ; }
From: myra.nelson [...] hughes.net
On Sun Sep 08 19:03:56 2013, myra.nelson@hughes.net wrote: Show quoted text
> On Tue Aug 06 14:05:50 2013, TSCH wrote:
> > On 22.07.2013 09:44, Petr Pisar via RT wrote:
> > > Attached patch should fix it. The patch is maybe to much > > > benevolent. > > > I'm not a master of pkg-config specification.
> > > > The patch looks good to me, thanks. Can you be bothered to also > > provide > > a unit test?
> > > This patch would be one solution, but gsl.pc on my machine has the > following line > > Cflags: -I/usr/include > > and something I seriously overlooked on the initial report was running > > pkg-config --cflags gsl > > from the command line returns zip, zilch, nada, nothing, etc adnausem. > So simply bypassing the check, at least in this case, seems wrong. > > I just tested the Math::GSL install again for reference with the > following results > > Running [/usr/bin/perl -e use strict; BEGIN { my $old = select STDERR; > $|++; select $old; $|++; $0 $ > Checking for GSL.. > Found GSL 1.15 (via gsl-config) installed in /usr, CFLAGS=- > I/usr/include, -L/usr/lib -lgsl -lgslcbl$ > Asking ExtUtils::PkgConfig with > ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/l$ > > *** can't find cflags for "gsl" > *** is it properly installed and available in PKG_CONFIG_PATH? > at /home/myra/.cpanplus/5.18.1/build/Math-GSL-0.27/Build.PL line 156. > BEGIN failed--compilation aborted at -e line 1. > [ERROR] Build.PL failed: Checking for GSL.. > Found GSL 1.15 (via gsl-config) installed in /usr, CFLAGS=- > I/usr/include, -L/usr/lib -lgsl -lgslcbl$ > Asking ExtUtils::PkgConfig with > ENV{PKG_CONFIG_PATH}=/usr/pkgconfig:/usr/lib/pkgconfig:/usr/local/l$ > > *** can't find cflags for "gsl" > *** is it properly installed and available in PKG_CONFIG_PATH? > at /home/myra/.cpanplus/5.18.1/build/Math-GSL-0.27/Build.PL line 156. > BEGIN failed--compilation aborted at -e line 1. > > As can be seen, gsl is found via gsl-config and the attached test > script finds gsl with pkg-config, but no cflags are returned via pkg- > config. > > I've attached two scripts that return values for gsl and alsa. They > are based on the routines used in ExtUtils-PkgConfig- > 1.14/lib/ExtUtils/PkgConfig.pm. There a couple of simplifications but > the results should be the same. > > It appears there is a problem returning the --cflags variable from > gsl.pc. > > On to more research. > > Myra
To All: Spiraling on down into pkg-config. The behaviour, like it or not, of the output of pkg-config --cflags gsl is correct with the gsl.pc file as it is on my machine prefix=/usr exec_prefix=/usr libdir=/usr/lib includedir=/usr/include GSL_CBLAS_LIB=-lgslcblas Name: GSL Description: GNU Scientific Library Version: 1.15 Libs: -L/usr/lib -lgsl ${GSL_CBLAS_LIB} -lm -lm Cflags: -I/usr/include Please take note of the Cflags line. By changing the Clfags line to Cflags: -I/usr/include/gsl [myra@gandalf ~/build/perl-repo/perl-pkgconfig]$ pkg-config --cflags gsl returns -I/usr/include/gsl which is the correct information. The test script I posted earlier produces the same result. The configuration for Math::GSL and build works as it should. Alas some of the tests fail but that's for another time and place, as is informing the gnu gsl devs of the problem with their gsl.pc file. So in the in ExtUtils::PkgConfig works as it should. Thank you for your time and patience with this issue. IMHO this bug report could be closed.
On Mon Sep 09 00:24:23 2013, myra.nelson@hughes.net wrote: Show quoted text
> So in the in ExtUtils::PkgConfig works as it should. Thank you for > your time and patience with this issue. IMHO this bug report could be > closed.
Glad to see the problem was found. Changing ticket status to: Resolved. Thanks
On Mon Sep 09 00:49:58 2013, XAOC wrote: Show quoted text
> On Mon Sep 09 00:24:23 2013, myra.nelson@hughes.net wrote:
> > So in the in ExtUtils::PkgConfig works as it should. Thank you for > > your time and patience with this issue. IMHO this bug report could be > > closed.
> > Glad to see the problem was found.
But I think Petr's patch is still correct, so I went ahead and committed it.