Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExtUtils::CBuilder support for Android #13529

Open
p5pRT opened this issue Jan 15, 2014 · 4 comments
Open

ExtUtils::CBuilder support for Android #13529

p5pRT opened this issue Jan 15, 2014 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Jan 15, 2014

Migrated from rt.perl.org#121011 (status was 'open')

Searchable as RT121011$

@p5pRT
Copy link
Author

p5pRT commented Jan 15, 2014

From dexter@cpan.org

Please add support for $Config{d_libname_unique} and Android's dynamic linker
by ExtUtils​::CBuilder.

Thank you.

Patch​:

From 4011a62 Mon Sep 17 00​:00​:00 2001
From​: Piotr Roszatycki <piotr.roszatycki@​gmail.com>
Date​: Wed, 15 Jan 2014 23​:34​:52 +0100
Subject​: [PATCH 1/2] Resolve lib_name via DynaLoader


.../lib/ExtUtils/CBuilder/Platform/Unix.pm | 17 +++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
index 523e9b4..c72b7d0 100644
--- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
+++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
@​@​ -37,4 +37,21 @​@​ sub link {
  return $self->SUPER​::link(@​_);
}

+sub lib_file {
+ my ($self, $dl_file) = @​_;
+
+ $dl_file =~ s/\.[^.]+$//;
+ $dl_file =~ tr/"//d;
+
+ if (defined &DynaLoader​::mod2fname) {
+ # DynaLoader​::mod2fname() is a builtin func
+ my $lib = defined $self->{module_name} ?
DynaLoader​::mod2fname([split /​::/, $self->{module_name}]) : '';
+
+ # Now know the basename, find directory parts via lib_file
+ my $lib_dir = ($dl_file =~ m,(.*)[/\\],s ? "$1/" : '' );
+
+ return "$lib_dir$lib.$self->{config}{dlext}";
+ }
+}
+
1;
--
1.8.3.2

From db87317 Mon Sep 17 00​:00​:00 2001
From​: Piotr Roszatycki <piotr.roszatycki@​gmail.com>
Date​: Wed, 15 Jan 2014 23​:34​:57 +0100
Subject​: [PATCH 2/2] Android needs -lperl


.../lib/ExtUtils/CBuilder/Platform/android.pm | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm

diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
new file mode 100644
index 0000000..5e3e29b
--- /dev/null
+++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
@​@​ -0,0 +1,27 @​@​
+package ExtUtils​::CBuilder​::Platform​::android;
+
+use strict;
+use File​::Spec;
+use ExtUtils​::CBuilder​::Platform​::Unix;
+
+use vars qw($VERSION @​ISA);
+$VERSION = '0.280212';
+@​ISA = qw(ExtUtils​::CBuilder​::Platform​::Unix);
+
+# The Android linker will not recognize symbols from
+# libperl unless the module explicitly depends on it.
+sub link {
+ my ($self, %args) = @​_;
+
+ if ($self->{config}{useshrplib}) {
+ $args{extra_linker_flags} = [
+ $self->split_like_shell($args{extra_linker_flags}),
+ '-L' . $self->perl_inc(),
+ '-lperl',
+ ];
+ }
+
+ return $self->SUPER​::link(%args);
+}
+
+1;
--
1.8.3.2

@p5pRT
Copy link
Author

p5pRT commented Jan 15, 2014

From @Hugmeir

On Wed, Jan 15, 2014 at 7​:44 PM, Piotr Roszatycki <perlbug-followup@​perl.org

wrote​:

# New Ticket Created by Piotr Roszatycki
# Please include the string​: [perl #121011]
# in the subject line of all future correspondence about this issue.
# <URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121011 >

Please add support for $Config{d_libname_unique} and Android's dynamic
linker
by ExtUtils​::CBuilder.

Thank you.

Patch​:

From 4011a62 Mon Sep 17 00​:00​:00 2001
From​: Piotr Roszatycki <piotr.roszatycki@​gmail.com>
Date​: Wed, 15 Jan 2014 23​:34​:52 +0100
Subject​: [PATCH 1/2] Resolve lib_name via DynaLoader

---
.../lib/ExtUtils/CBuilder/Platform/Unix.pm | 17
+++++++++++++++++
1 file changed, 17 insertions(+)

diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
index 523e9b4..c72b7d0 100644
--- a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
+++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/Unix.pm
@​@​ -37,4 +37,21 @​@​ sub link {
return $self->SUPER​::link(@​_);
}

+sub lib_file {
+ my ($self, $dl_file) = @​_;
+
+ $dl_file =~ s/\.[^.]+$//;
+ $dl_file =~ tr/"//d;
+
+ if (defined &DynaLoader​::mod2fname) {
+ # DynaLoader​::mod2fname() is a builtin func
+ my $lib = defined $self->{module_name} ?
DynaLoader​::mod2fname([split /​::/, $self->{module_name}]) : '';
+
+ # Now know the basename, find directory parts via lib_file
+ my $lib_dir = ($dl_file =~ m,(.*)[/\\],s ? "$1/" : '' );
+
+ return "$lib_dir$lib.$self->{config}{dlext}";
+ }
+}
+

Already fixed as 5e4a7f8

1;
--
1.8.3.2

From db87317 Mon Sep 17 00​:00​:00 2001
From​: Piotr Roszatycki <piotr.roszatycki@​gmail.com>
Date​: Wed, 15 Jan 2014 23​:34​:57 +0100
Subject​: [PATCH 2/2] Android needs -lperl

---
.../lib/ExtUtils/CBuilder/Platform/android.pm | 27
++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm

diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/
android.pm
b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
new file mode 100644
index 0000000..5e3e29b
--- /dev/null
+++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
@​@​ -0,0 +1,27 @​@​
+package ExtUtils​::CBuilder​::Platform​::android;
+
+use strict;
+use File​::Spec;
+use ExtUtils​::CBuilder​::Platform​::Unix;
+
+use vars qw($VERSION @​ISA);
+$VERSION = '0.280212';
+@​ISA = qw(ExtUtils​::CBuilder​::Platform​::Unix);
+
+# The Android linker will not recognize symbols from
+# libperl unless the module explicitly depends on it.
+sub link {
+ my ($self, %args) = @​_;
+
+ if ($self->{config}{useshrplib}) {
+ $args{extra_linker_flags} = [
+ $self->split_like_shell($args{extra_linker_flags}),
+ '-L' . $self->perl_inc(),
+ '-lperl',
+ ];
+ }
+
+ return $self->SUPER​::link(%args);
+}
+
+1;

I will take a look at this, though.

@p5pRT
Copy link
Author

p5pRT commented Jan 15, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jan 17, 2014

From @Leont

On Wed, Jan 15, 2014 at 11​:44 PM, Piotr Roszatycki <
perlbug-followup@​perl.org> wrote​:

.../lib/ExtUtils/CBuilder/Platform/android.pm | 27
++++++++++++++++++++++
1 file changed, 27 insertions(+)
create mode 100644
dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm

diff --git a/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/
android.pm
b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
new file mode 100644
index 0000000..5e3e29b
--- /dev/null
+++ b/dist/ExtUtils-CBuilder/lib/ExtUtils/CBuilder/Platform/android.pm
@​@​ -0,0 +1,27 @​@​
+package ExtUtils​::CBuilder​::Platform​::android;
+
+use strict;
+use File​::Spec;
+use ExtUtils​::CBuilder​::Platform​::Unix;
+
+use vars qw($VERSION @​ISA);
+$VERSION = '0.280212';
+@​ISA = qw(ExtUtils​::CBuilder​::Platform​::Unix);
+
+# The Android linker will not recognize symbols from
+# libperl unless the module explicitly depends on it.
+sub link {
+ my ($self, %args) = @​_;
+
+ if ($self->{config}{useshrplib}) {
+ $args{extra_linker_flags} = [
+ $self->split_like_shell($args{extra_linker_flags}),
+ '-L' . $self->perl_inc(),
+ '-lperl',
+ ];
+ }
+
+ return $self->SUPER​::link(%args);
+}
+
+1;

This part of the patch looks reasonable to me.

Leon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants