Subject: | linker flags are wrong when loader != $CC |
ccdlflags is designed to pass the loader flags to $CC (as correctly used on line ±185 - after patch), not when $Config{ld} is not $CC, which will cause link failures like
Running Mkbootstrap for Compress::Bzip2 ()
chmod 644 "Bzip2.bs"
"/opt/perl32/bin/perl" "/opt/perl32/lib/5.22.0/ExtUtils/xsubpp" -typemap "/opt/perl32/lib/5.22.0/ExtUtils/typemap" -typemap "typemap" Bzip2.xs > Bzip2.xsc && mv Bzip2.xsc Bzip2.c
gcc -c -Ibzlib-src -mpa-risc-2-0 -fPIC -DPERL_DONT_CREATE_GVSV -D_HPUX_SOURCE -fwrapv -fno-strict-aliasing -pipe -I/usr/local/pa20_32/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2 -g -O -DVERSION=\"2.22\" -DXS_VERSION=\"2.22\" -fPIC "-I/opt/perl32/lib/5.22.0/PA-RISC2.0/CORE" Bzip2.c
rm -f blib/arch/auto/Compress/Bzip2/Bzip2.sl
/usr/bin/ld -b -L/usr/local/pa20_32/lib -L/usr/local/lib -L/pro/local/lib -Wl,-E -Wl,-B,deferred Bzip2.o -o blib/arch/auto/Compress/Bzip2/Bzip2.sl bzlib-src/libbz2.a \
\
/usr/bin/ld: Unrecognized argument: -Wl,-E
/usr/bin/ld: Usage: /usr/bin/ld [options] [flags] files
I think that a safe workaround would be something like this:
--8<---
--- /tmp/Makefile.PL 2015-06-08 18:23:44 +0200
+++ Makefile.PL 2015-06-08 18:20:29 +0200
@@ -24,6 +24,15 @@ ParseCONFIG() ;
my %Bzip2 = ( pm => catfile( qw( lib Compress Bzip2.pm ) ),
lib => catfile( 'bzlib-src', 'libbz2'.$Config{_a} ) );
+my $dlflags = $Config{ccdlflags};
+if ($Config{ld} =~ m{^(.*/)?\w*ld\w*$}) {
+ my @flags;
+ for (split m/\s+/ => $dlflags) {
+ s/^-Wl,(-+[-\w]+),/$1 / or s/^-Wl,//;
+ push @flags, $_;
+ }
+ $dlflags = join " " => @flags;
+ }
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
WriteMakefile(
@@ -45,7 +54,7 @@ WriteMakefile(
AUTHOR => 'Rob Janes <arjay@cpan.org>') : ()),
LIBS => $BUILD_BZLIB ? [] : [ $BZLIB_LIB ? "-L$BZLIB_LIB -lbz2" : '-lbz2' ],
# ccdlflags needed for -R [cpan #68572]
- LDDLFLAGS => $Config{lddlflags} . " " . $Config{ccdlflags},
+ LDDLFLAGS => $Config{lddlflags} . " " . $dlflags,
INC => $BUILD_BZLIB ? '-Ibzlib-src' : $BZLIB_INCLUDE ? "-I$BZLIB_INCLUDE" : '',
clean => {
FILES=>
-->8---
which at least makes Compress::Bzip2 work out-of-the-box on all my HP-UX boxes.
Feel free to apply your own style of course