Skip Menu |

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

Report information
The Basics
Id: 92699
Status: resolved
Worked: 1 hour (60 min)
Priority: 0/
Queue: ExtUtils-Depends

People
Owner: XAOC [...] cpan.org
Requestors: fraserbn [...] gmail.com
kmx [...] cpan.org
Cc: kmx [...] cpan.org
AdminCc:

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



Subject: [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Couple of important prefaces! Android support is brand new in core perl, so I'm still working out edge cases and just plain breakage in the port. Also, the patch below is only half of the solution for this -- the other part is this fix for MakeMaker: https://github.com/Perl-Toolchain-Gang/ExtUtils-MakeMaker/commit/9d540908bbc962715da337b308cab06983d51fd5 Which I haven't merged into MakeMaker proper yet, because I figure it ought to get a thumbs up from here as well. The attached patch does two things; the first is relatively simple, it adds support for platforms with DynaLoader::mod2fname() defined. mod2fname isn't exactly well documented, but basically, some platforms have some unusual requirements for their library names, so instead of, say, Utils.so for List::Utils, you might end up with PL_List__Utils.so; what mod2fname does is get you that library name. There's currently two systems with mod2fname defined, VMS and Android. OS/2 uses it as well, but the OS/2 port isn't functional at the moment. Additionally, Windows may start using it in the near future. (as an addendum: I have a suspicion that the module doesn't work quite right on VMS as-is, but I don't have a VMS box to confirm that) The second thing that the patch does is actually solve a problem with Android's linker. I'll copypaste a bit of the patch to explain this bit: + # Android's linker ignores the RTLD_GLOBAL flag + # and loads everything as if under RTLD_LOCAL. + # What this means in practice is that modules need + # to explicitly link to their dependencies, + # because otherwise they won't be able to locate any + # functions they define. + # We use the -l:foo.so flag to indicate that the + # actual library name to look for is foo.so, not + # libfoo.so As an example of what would happen, if i want my module to depend on mro, instead of passing LIBS something like "-L/mnt/asec/home/built/lib/perl5/5.19.9/armv7l-linux-android-thread-multi/auto/mro -lPL_mro" it ends up passing this: "-L/mnt/asec/home/built/lib/perl5/5.19.9/armv7l-linux-android-thread-multi/auto/mro -l:PL_mro.so" Which is then used during linking to get the correct dependency. I've also made this part of the patch only kicks in for Android, since to my knowledge the module is working fine elsewhere. I'm also not sure if -l: is gcc/clang only, but currently it's only possible to compile perl for/on android with gcc and potentially clang, so it's not really a worry.
Subject: 0001-Work-around-Android-s-linker-ignoring-RTLD_GLOBAL.patch
From af51eed8807de61c5ecf1485b3a02053af63ab92 Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Mon, 3 Feb 2014 09:33:18 +0100 Subject: [PATCH] Work around Android's linker ignoring RTLD_GLOBAL On Android, modules must explicitly link to their dependencies. --- lib/ExtUtils/Depends.pm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index 05ef316..5c4ca8c 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -7,12 +7,16 @@ package ExtUtils::Depends; use strict; use warnings; use Carp; +use Config; use File::Find; use File::Spec; use Data::Dumper; our $VERSION = '0.306'; +# For platforms with DynaLoader::mod2fname(), like VMS or Android +require DynaLoader; + sub import { my $class = shift; return unless @_; @@ -315,6 +319,7 @@ sub find_extra_libs { my %mappers = ( MSWin32 => sub { $_[0] . '\.(?:lib|a)' }, cygwin => sub { $_[0] . '\.dll'}, + android => sub { $_[0] . '\.' . $Config{dlext} }, ); my $mapper = $mappers{$^O}; return () unless defined $mapper; @@ -322,6 +327,10 @@ sub find_extra_libs { my @found_libs = (); foreach my $name (keys %{ $self->{deps} }) { (my $stem = $name) =~ s/^.*:://; + if ( defined &DynaLoader::mod2fname ) { + my @parts = split /::/, $name; + $stem = DynaLoader::mod2fname([@parts]); + } my $lib = $mapper->($stem); my $pattern = qr/$lib$/; @@ -336,6 +345,18 @@ sub find_extra_libs { if ($matching_file && -f $matching_file) { push @found_libs, ('-L' . $matching_dir, '-l' . $stem); + # Android's linker ignores the RTLD_GLOBAL flag + # and loads everything as if under RTLD_LOCAL. + # What this means in practice is that modules need + # to explicitly link to their dependencies, + # because otherwise they won't be able to locate any + # functions they define. + # We use the -l:foo.so flag to indicate that the + # actual library name to look for is foo.so, not + # libfoo.so + if ( $^O eq 'android' ) { + $found_libs[-1] = "-l:$stem.$Config{dlext}"; + } next; } } -- 1.7.12.4 (Apple Git-37)
Subject: Handle correctly situation when $Config{dlext} is not equal to $Config{so}
Please consider applying the following patch:
--- ExtUtils-Depends-0.306/lib/ExtUtils/Depends.pm      2013-09-29 07:04:16.000000000 +0200
+++ ExtUtils-Depends-0.306_patched/lib/ExtUtils/Depends.pm      2014-04-07 21:47:42.367135200 +0200
@@ -358,7 +358,7 @@
        return <<"__EOM__"
 # This isn't actually a static lib, it just has the same name on Win32.
 \$(INST_DYNAMIC_LIB): \$(INST_DYNAMIC)
-       $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(BASEEXT).\$(SO) \$(INST_DYNAMIC)
+       $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(BASEEXT).\$(DLEXT) \$(INST_DYNAMIC)

 dynamic:: \$(INST_DYNAMIC_LIB)
 __EOM__
It handles correctly the situation when you have for example $Config{dlext} == 'xs.dll' and  $Config{so} = 'dll'

DLEXT is the correct value as it is an extension of perl loadable module which is want is necessary here

--
kmx
 
 
Subject: Re: [rt.cpan.org #94515] Handle correctly situation when $Config{dlext} is not equal to $Config{so}
Date: Tue, 08 Apr 2014 21:46:32 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
So, in the light of <https://rt.perl.org/Public/Bug/Display.html?id=121593>, should this report be closed in favor of the patch in <https://rt.cpan.org/Public/Bug/Display.html?id=92699>?
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Tue, 08 Apr 2014 21:57:51 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
Thanks for your work on this. Since the two changes -- support for DynaLoader::mod2fname and Android compatiblity -- seem to be independent, could you split the patch up? And the comment in front of find_extra_libs() needs to be adjusted to mention Android. And could you be bothered to write unit tests for the changes? That would make me more comfortable applying the patch.
Subject: Re: [rt.cpan.org #94515] Handle correctly situation when $Config{dlext} is not equal to $Config{so}
Date: Tue, 08 Apr 2014 22:21:06 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: kmx <kmx [...] volny.cz>
On 8.4.2014 21:46, Torsten Schoenfeld via RT wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=94515 > > > So, in the light of > <https://rt.perl.org/Public/Bug/Display.html?id=121593>, should this > report be closed in favor of the patch in > <https://rt.cpan.org/Public/Bug/Display.html?id=92699>? >
The patch in RT92699 will need some update to handle correctly MS Windows - I am currently running some tests with slightly modified patch http://strawberryperl.com/package/kmx/perl-modules-patched/ExtUtils-Depends-0.306_patched.tar.gz Give me please one day. I'll be back with feedback. However you might be right, I'll merge my changes into RT92699 and you can close this RT. -- kmx
Hi,

I am sending updated patch that is based on my testing on MS Windows. I have tested it on builds:
- with $Config{dlext} = 'xs.dll'
- with d_libname_unique='define'
- with both d_libname_unique='define' + $Config{dlext} = 'xs.dll'

It seems to work fine.

On top of the patch you have to create the following (empty) files:
- t/inc/DepTest: PL_DepTest.dll
- t/inc/DepTest: PL_DepTest.lib
- t/inc/DepTest: PL_libDepTest.dll.a

The patch also fixes RT#94515 (which can be closed or merged)

--
kmx
Subject: ExtUtils-Depends-0.306.patch
diff -ru ExtUtils-Depends-0.306/lib/ExtUtils/Depends.pm ExtUtils-Depends-0.306_patched/lib/ExtUtils/Depends.pm --- ExtUtils-Depends-0.306/lib/ExtUtils/Depends.pm 2013-09-29 07:04:16.000000000 +0200 +++ ExtUtils-Depends-0.306_patched/lib/ExtUtils/Depends.pm 2014-04-08 20:58:28.000000000 +0200 @@ -7,6 +7,7 @@ use strict; use warnings; use Carp; +use Config; use File::Find; use File::Spec; use Data::Dumper; @@ -303,7 +304,7 @@ my ($self, $vars) = @_; $vars->{macro} ||= {}; $vars->{macro}{'INST_DYNAMIC_LIB'} = - '$(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)'; + '$(INST_ARCHAUTODIR)/$(DLBASE)$(LIB_EXT)'; } # Search for extra library files to link against on Windows (either native @@ -315,6 +316,7 @@ my %mappers = ( MSWin32 => sub { $_[0] . '\.(?:lib|a)' }, cygwin => sub { $_[0] . '\.dll'}, + android => sub { $_[0] . '\.' . $Config{dlext} }, ); my $mapper = $mappers{$^O}; return () unless defined $mapper; @@ -322,6 +324,10 @@ my @found_libs = (); foreach my $name (keys %{ $self->{deps} }) { (my $stem = $name) =~ s/^.*:://; + if ( defined &DynaLoader::mod2fname ) { + my @parts = split /::/, $name; + $stem = DynaLoader::mod2fname([@parts]); + } my $lib = $mapper->($stem); my $pattern = qr/$lib$/; @@ -336,6 +342,18 @@ if ($matching_file && -f $matching_file) { push @found_libs, ('-L' . $matching_dir, '-l' . $stem); + # Android's linker ignores the RTLD_GLOBAL flag + # and loads everything as if under RTLD_LOCAL. + # What this means in practice is that modules need + # to explicitly link to their dependencies, + # because otherwise they won't be able to locate any + # functions they define. + # We use the -l:foo.so flag to indicate that the + # actual library name to look for is foo.so, not + # libfoo.so + if ( $^O eq 'android' ) { + $found_libs[-1] = "-l:$stem.$Config{dlext}"; + } next; } } @@ -358,7 +376,7 @@ return <<"__EOM__" # This isn't actually a static lib, it just has the same name on Win32. \$(INST_DYNAMIC_LIB): \$(INST_DYNAMIC) - $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(BASEEXT).\$(SO) \$(INST_DYNAMIC) + $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(DLBASE).\$(DLEXT) \$(INST_DYNAMIC) dynamic:: \$(INST_DYNAMIC_LIB) __EOM__
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Tue, 22 Apr 2014 19:08:45 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 09.04.2014 20:08, kmx via RT wrote: Show quoted text
> I am sending updated patch that is based on my testing on MS Windows. I have > tested it on builds: > - with $Config{dlext} = 'xs.dll' > - with d_libname_unique='define' > - with both d_libname_unique='define' + $Config{dlext} = 'xs.dll' > > It seems to work fine.
The code looks good to me, but I'd still like to see the patch split up into logically independent pieces: the DLEXT fix, the mod2fname support, and the Android support. And doesn't t/04_extra_libs.t need to be changed to be run on Android? Show quoted text
> On top of the patch you have to create the following (empty) files: > - t/inc/DepTest: PL_DepTest.dll > - t/inc/DepTest: PL_DepTest.lib > - t/inc/DepTest: PL_libDepTest.dll.a
Where is the "PL_" coming from? From d_libname_unique? Can we rely on it always adding a prefix "PL_"? What about builds with, say, $Config{dlext} = 'xs.dll' like you suggested? Wouldn't they look for a different file in t/inc/DepTest?
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Tue, 22 Apr 2014 19:27:39 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Brian Fraser <fraserbn [...] gmail.com>
On Tue, Apr 8, 2014 at 9:58 PM, Torsten Schoenfeld via RT <bug-ExtUtils-Depends@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92699 > > > Thanks for your work on this. Since the two changes -- support for > DynaLoader::mod2fname and Android compatiblity -- seem to be > independent, could you split the patch up? And the comment in front of > find_extra_libs() needs to be adjusted to mention Android. > > And could you be bothered to write unit tests for the changes? That > would make me more comfortable applying the patch. >
Sure, can do. Pardons for the delay; I haven't been able to do much hacking in the last couple of months due to moving continents, but I can probably get to this either today or tomorrow.
On Tue Apr 08 16:21:20 2014, kmx@volny.cz wrote: Show quoted text
> Give me please one day. I'll be back with feedback. > > However you might be right, I'll merge my changes into RT92699 and you > can > close this RT.
Any updates on this? Leave it open, apply patch, or close without applying?
Patch is needed.

I have attached my patch to https://rt.cpan.org/Public/Bug/Display.html?id=92699

Show quoted text
> The code looks good to me, but I'd still like to see the patch split
> up into logically independent pieces

See ExtUtils-Depends-part1-dlext.diff ExtUtils-Depends-part2-mod2fname.diff ExtUtils-Depends-part3-android.diff

On top of the patch you have to create the following (empty) files related to d_libname_unique:
- t/inc/DepTest: PL_DepTest.dll
- t/inc/DepTest: PL_DepTest.lib
- t/inc/DepTest: PL_libDepTest.dll.a


Show quoted text
> Where is the "PL_" coming from? From d_libname_unique?

yes


Show quoted text
> Can we rely on it always adding a prefix "PL_"?

I do not know


Show quoted text
> What about builds with, say, $Config{dlext} = 'xs.dll'
> like you suggested? Wouldn't they look for a
> different file in t/inc/DepTest?

They will but if ModName.xs.dll (using $Config{dlext}) is not found it will fall back to ModName.dll (using $Config{so}) and succeed

Please note that the latest strawberry perl 5.20.0 was already released with $Config{dlext} = 'xs.dll' so it might be worth to apply at least ExtUtils-Depends-part1-dlext.diff in the near future


--
kmx
Subject: ExtUtils-Depends-part1-dlext.diff
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index a449176..2a5b527 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -356,7 +356,7 @@ sub static_lib { return <<"__EOM__" # This isn't actually a static lib, it just has the same name on Win32. \$(INST_DYNAMIC_LIB): \$(INST_DYNAMIC) - $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(BASEEXT).\$(SO) \$(INST_DYNAMIC) + $DLLTOOL --def \$(EXPORT_LIST) --output-lib \$\@ --dllname \$(DLBASE).\$(DLEXT) \$(INST_DYNAMIC) dynamic:: \$(INST_DYNAMIC_LIB) __EOM__
Subject: ExtUtils-Depends-part2-mod2fname.diff
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index 2a5b527..3e87162 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -301,7 +301,7 @@ sub build_dll_lib { my ($self, $vars) = @_; $vars->{macro} ||= {}; $vars->{macro}{'INST_DYNAMIC_LIB'} = - '$(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)'; + '$(INST_ARCHAUTODIR)/$(DLBASE)$(LIB_EXT)'; } # Search for extra library files to link against on Windows (either native @@ -320,6 +320,10 @@ sub find_extra_libs { my @found_libs = (); foreach my $name (keys %{ $self->{deps} }) { (my $stem = $name) =~ s/^.*:://; + if ( defined &DynaLoader::mod2fname ) { + my @parts = split /::/, $name; + $stem = DynaLoader::mod2fname([@parts]); + } my $lib = $mapper->($stem); my $pattern = qr/$lib$/;
Subject: ExtUtils-Depends-part3-android.diff
diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index 3e87162..6ce8682 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -7,6 +7,7 @@ package ExtUtils::Depends; use strict; use warnings; use Carp; +use Config; use File::Find; use File::Spec; use Data::Dumper; @@ -313,6 +314,7 @@ sub find_extra_libs { my %mappers = ( MSWin32 => sub { $_[0] . '\.(?:lib|a)' }, cygwin => sub { $_[0] . '\.dll'}, + android => sub { $_[0] . '\.' . $Config{dlext} }, ); my $mapper = $mappers{$^O}; return () unless defined $mapper; @@ -338,6 +340,18 @@ sub find_extra_libs { if ($matching_file && -f $matching_file) { push @found_libs, ('-L' . $matching_dir, '-l' . $stem); + # Android's linker ignores the RTLD_GLOBAL flag + # and loads everything as if under RTLD_LOCAL. + # What this means in practice is that modules need + # to explicitly link to their dependencies, + # because otherwise they won't be able to locate any + # functions they define. + # We use the -l:foo.so flag to indicate that the + # actual library name to look for is foo.so, not + # libfoo.so + if ( $^O eq 'android' ) { + $found_libs[-1] = "-l:$stem.$Config{dlext}"; + } next; } }
From: fraserbn [...] gmail.com
On Tue Jun 03 04:17:30 2014, KMX wrote: Show quoted text
> > The code looks good to me, but I'd still like to see the patch split > > up into logically independent pieces
> > See ExtUtils-Depends-part1-dlext.diff ExtUtils-Depends-part2- > mod2fname.diff > ExtUtils-Depends-part3-android.diff > > On top of the patch you have to create the following (empty) files > related to > d_libname_unique: > - t/inc/DepTest: PL_DepTest.dll > - t/inc/DepTest: PL_DepTest.lib > - t/inc/DepTest: PL_libDepTest.dll.a
also please add t/inc/DepTest/PL_DepTest.so, which will be used on Unixy systems. Show quoted text
> >
> > Where is the "PL_" coming from? From d_libname_unique?
> > yes > >
> > Can we rely on it always adding a prefix "PL_"?
> > I do not know
Yes. The behavior is the same on everywhere. Er, except OS/2, but the relevant tests aren't run there, so no harm done. Show quoted text
> >
> > What about builds with, say, $Config{dlext} = 'xs.dll' > > like you suggested? Wouldn't they look for a > > different file in t/inc/DepTest?
> > They will but if ModName.xs.dll (using $Config{dlext}) is not found it > will > fall back to ModName.dll (using $Config{so}) and succeed > > Please note that the latest strawberry perl 5.20.0 was already > released with > $Config{dlext} = 'xs.dll' so it might be worth to apply at least > ExtUtils-Depends-part1-dlext.diff in the near future >
I can't contribute much to the windows discussion, but I'm wondering if that might need extra fixes; how does gcc on Windows handle -lPL_foo.dll? Does Windows+d_libname_unique+gcc also need the -l:PL_foo.dll hack? In any case, apologies again, took forever to get back to this. Turns out that this is mostly already tested for in t/04_extra_libs.t; all that's needed is to enable testing on android, and adding that empty file (t/inc/DepTest/PL_DepTest.so).
Subject: 0001-use-DynaLoader-mod2fname-if-available.patch
From 26e3c3ec712aa277269c40cde4f013241a948d9a Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Fri, 25 Jul 2014 17:22:54 +0200 Subject: [PATCH 1/2] use DynaLoader::mod2fname if available. mod2fname isn't exactly well documented, but basically, some platforms have some unusual requirements for their library names, so instead of, say, Utils.so for List::Utils, you might end up with PL_List__Utils.so; what mod2fname does is get you that library name. There's currently two systems with mod2fname defined, VMS and Android. OS/2 uses it as well, but the OS/2 port isn't functional at the moment. Additionally, Windows may start using it in the near future. --- lib/ExtUtils/Depends.pm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index 05ef316..7a98741 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -322,6 +322,10 @@ sub find_extra_libs { my @found_libs = (); foreach my $name (keys %{ $self->{deps} }) { (my $stem = $name) =~ s/^.*:://; + if ( defined &DynaLoader::mod2fname ) { + my @parts = split /::/, $name; + $stem = DynaLoader::mod2fname([@parts]); + } my $lib = $mapper->($stem); my $pattern = qr/$lib$/; -- 1.7.12.4 (Apple Git-37)
Subject: 0002-Android-support.patch
From f6a8385b99025981dd4998bb93b21bd523e3d6e1 Mon Sep 17 00:00:00 2001 From: Brian Fraser <fraserbn@gmail.com> Date: Fri, 25 Jul 2014 17:28:55 +0200 Subject: [PATCH 2/2] Android support. --- lib/ExtUtils/Depends.pm | 16 +++++++++++++++- t/04_extra_libs.t | 9 +++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/lib/ExtUtils/Depends.pm b/lib/ExtUtils/Depends.pm index 7a98741..badd3ea 100644 --- a/lib/ExtUtils/Depends.pm +++ b/lib/ExtUtils/Depends.pm @@ -7,6 +7,7 @@ package ExtUtils::Depends; use strict; use warnings; use Carp; +use Config; use File::Find; use File::Spec; use Data::Dumper; @@ -303,7 +304,7 @@ sub build_dll_lib { my ($self, $vars) = @_; $vars->{macro} ||= {}; $vars->{macro}{'INST_DYNAMIC_LIB'} = - '$(INST_ARCHAUTODIR)/$(BASEEXT)$(LIB_EXT)'; + '$(INST_ARCHAUTODIR)/$(DLBASE)$(LIB_EXT)'; } # Search for extra library files to link against on Windows (either native @@ -315,6 +316,7 @@ sub find_extra_libs { my %mappers = ( MSWin32 => sub { $_[0] . '\.(?:lib|a)' }, cygwin => sub { $_[0] . '\.dll'}, + android => sub { $_[0] . '\.' . $Config{dlext} }, ); my $mapper = $mappers{$^O}; return () unless defined $mapper; @@ -340,6 +342,18 @@ sub find_extra_libs { if ($matching_file && -f $matching_file) { push @found_libs, ('-L' . $matching_dir, '-l' . $stem); + # Android's linker ignores the RTLD_GLOBAL flag + # and loads everything as if under RTLD_LOCAL. + # What this means in practice is that modules need + # to explicitly link to their dependencies, + # because otherwise they won't be able to locate any + # functions they define. + # We use the -l:foo.so flag to indicate that the + # actual library name to look for is foo.so, not + # libfoo.so + if ( $^O eq 'android' ) { + $found_libs[-1] = "-l:$stem.$Config{dlext}"; + } next; } } diff --git a/t/04_extra_libs.t b/t/04_extra_libs.t index dbf70f4..9f303ea 100644 --- a/t/04_extra_libs.t +++ b/t/04_extra_libs.t @@ -12,7 +12,7 @@ use ExtUtils::Depends; my $tmp_inc = temp_inc; -plan (($^O eq 'MSWin32' || $^O eq 'cygwin') ? +plan (($^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'android') ? (tests => 1) : (skip_all => 'test only applicable to MSWin32 and cygwin')); @@ -24,6 +24,11 @@ $dep_info->save_config (catfile $tmp_inc, qw(DepTest Install Files.pm)); my $use_info = ExtUtils::Depends->new ('UseTest', 'DepTest'); my %vars = $use_info->get_makefile_vars; -like ($vars{LIBS}, qr/DepTest/); +my $libname = 'DepTest'; + +require DynaLoader; +$libname = DynaLoader::mod2fname([$libname]) if defined &DynaLoader::mod2fname; + +like ($vars{LIBS}, qr/$libname/); # --------------------------------------------------------------------------- # -- 1.7.12.4 (Apple Git-37)
Would it be possible to prepare a dev version with proposed changes? I can test such a release on MS Windows platform.
RT-Send-CC: kmx [...] volny.cz, kaffeetisch [...] gmx.de
Hi all, I *think* I have collected all of the various changes discussed in this ticket, and added them to my personal EU::D repo on Github. Can you please pull my changes and verify? https://github.com/cpanxaoc/perl-ExtUtils-Depends/commits/android_windows_changes Brian Frasier, your patches had extra whitespace at the end of the line, git complained when I ran 'git am' to apply them to my tree. I removed the whitespace in a new commit, then rebased my commits down on top of your commits. FWIW, I downloaded your patches directly from RT using wget. After applying patches, make/make test in EU::D worked for me, Perl 5.20.0 on OS X 10.9.x. Can you please test on your respective platforms and give me feedback. If everybody is happy, I can cut a release in the next few days. There's a quasi-deadline here, I'm unavailable to cut a new release on August 3rd and 4th, and again from August 7th through the 20th.
CC: kmx [...] cpan.org
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Thu, 31 Jul 2014 22:57:55 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Brian Fraser <fraserbn [...] gmail.com>
On Thu, Jul 31, 2014 at 9:55 AM, Brian Manning via RT <bug-ExtUtils-Depends@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=92699 > > > Hi all, > > I *think* I have collected all of the various changes discussed in this ticket, and added them to my personal EU::D repo on Github. Can you please pull my changes and verify? > > https://github.com/cpanxaoc/perl-ExtUtils-Depends/commits/android_windows_changes > > Brian Frasier, your patches had extra whitespace at the end of the line, git complained when I ran 'git am' to apply them to my tree. I removed the whitespace in a new commit, then rebased my commits down on top of your commits. FWIW, I downloaded your patches directly from RT using wget.
Whoops, sorry about that. I see that there's a git repo for the module -- hadn't spotted that before, would've made things easier to follow. Show quoted text
> > After applying patches, make/make test in EU::D worked for me, Perl 5.20.0 on OS X 10.9.x. Can you please test on your respective platforms and give me feedback. If everybody is happy, I can cut a release in the next few days.
All tests pass on Android. Additionally, with the changes I just merged to ExtUtils::MakeMaker, modules using ExtUtils::Depends now work as expected! It all look clear on this end; Thanks! Show quoted text
> > There's a quasi-deadline here, I'm unavailable to cut a new release on August 3rd and 4th, and again from August 7th through the 20th.
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Fri, 01 Aug 2014 08:16:59 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Karel Miko <kmx [...] cpan.org>
I have tested https://github.com/cpanxaoc/perl-ExtUtils-Depends/commits/android_windows_changes on MS Windows: 1/ standard build - $Config{dlext} == 'dll' (default) 2/ modified - $Config{dlext} == 'xs.dll' (used by the latest strawberry perl) Both pass all tests. I currently do not have a MS Window perl built with d_libname_unique -- kmx
Subject: Re: [rt.cpan.org #92699] [PATCH] Work around Android's linker ignoring RTLD_GLOBAL
Date: Sat, 02 Aug 2014 17:08:28 +0200
To: bug-ExtUtils-Depends [...] rt.cpan.org
From: Torsten Schoenfeld <kaffeetisch [...] gmx.de>
On 31.07.2014 09:55, Brian Manning via RT wrote: Show quoted text
> I *think* I have collected all of the various changes discussed in > this ticket, and added them to my personal EU::D repo on Github. Can > you please pull my changes and verify? > > https://github.com/cpanxaoc/perl-ExtUtils-Depends/commits/android_windows_changes
Thanks for taking care of this, Brian! The skip message in t/04_extra_libs.t could mention android, but other than that, the changes look fine to me. All tests pass on my Ubuntu box too.
Looks like everything has been committed and released. Closing accordingly. Thanks everyone for your effort!