Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Question on porting perl 5.16 to Android (no /bin/sh)

54 views
Skip to first unread message

Ben Greear

unread,
Sep 4, 2013, 12:50:06 PM9/4/13
to perl5-...@perl.org
I used the perldroid project to cross-compile perl 5.16 for android (ARM) using
the latest Android NDK stand-alone toolchain. After hacking on perldroid to
fix a few things I got a mostly-working perl binary & libraries.

One problem remains however. If I have perl code that does something like this,
it will not work:

my @foo = `ls run_*.PID 2>/dev/null`;

I think this might be because Android has no /bin/sh. Instead, it puts the shell
at /system/bin/sh.

Maybe lacking /bin/sh perl uses some interal minimal fake shell and thus fails to handle
more advanced system calls?

Anyone know if perl can be configured to use a different shell by default, or where
the code is that could be changed to use /system/bin/sh?

Thanks,
Ben

--
Ben Greear <gre...@candelatech.com>
Candela Technologies Inc http://www.candelatech.com

Brian Fraser

unread,
Sep 4, 2013, 1:21:49 PM9/4/13
to Ben Greear, Perl5 Porters Mailing List
On Wed, Sep 4, 2013 at 1:50 PM, Ben Greear <gre...@candelatech.com> wrote:
I used the perldroid project to cross-compile perl 5.16 for android (ARM) using
the latest Android NDK stand-alone toolchain.  After hacking on perldroid to
fix a few things I got a mostly-working perl binary & libraries.

One problem remains however.  If I have perl code that does something like this,
it will not work:

my @foo =  `ls run_*.PID 2>/dev/null`;

I think this might be because Android has no /bin/sh.  Instead, it puts the shell
at /system/bin/sh.

Maybe lacking /bin/sh perl uses some interal minimal fake shell and thus fails to handle
more advanced system calls?

Anyone know if perl can be configured to use a different shell by default, or where
the code is that could be changed to use /system/bin/sh?

Thanks,
Ben

Rather than using perldroid, try using castaway's branch here:
https://github.com/castaway/perl/tree/jrobinson/configure-for-cross

Which solves that and several other issues with perl on android, such as making 'system "echo", "foo"' work, even though "echo" is a shell builtin in Android, or being able to use both List::Util and Hash::Util in the same program, which fails on perldroid due to some limitations in the android linker.
Also, for the time being, perhaps considering using https://github.com/Hugmeir/utf8mess/tree/configure-for-cross instead, at least until that's merged into the main branch, if you want to run a successful 'make test' after building, to ensure that your perl is working properly.

With that branch, building perl on android is pretty simple:

# Change these two accordingly
$ export ANDROID_NDK=$HOME/Downloads/android-ndk-r8e
$ export ANDROID_SDK=`echo $HOME/Downloads/adt-bundle-*`

$ export PATH="$ANDROID_SDK/sdk/platform-tools:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/`uname | tr '[A-Z]' '[a-z]'`-x86_64/bin:$PATH"
$ $ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-9 --install-dir=/tmp/my-toolchain --system=`uname | tr '[A-Z]' '[a-z]'`-x86_64 --toolchain=arm-linux-androideabi-4.4.3

# Turn on the emulator, obviously optional:
$ $ANDROID_SDK/sdk/tools/android avd &

$ adb devices
# Grab the device name, then
$ export DEVICE=emulator-5554

# if you have a rooted device/emulator:

    $ export TARGETDIR=/mnt/asec/perl
    $ adb -s $DEVICE shell "echo sh -c '\"mkdir $TARGETDIR\"' | su --"

# else
    # You might have a /data that is writeable by the 'shell' user,
    # which is what adb logs in as. if you do, you could
    # put all of perl and the test files there, but for most phones
    # you'll run out of space first.
    # WARNING! You'll have to remove the test files from
    # the target dir once you are done! Unlike /mnt/asec,
    # /data/local/tmp may not get automatically garbage
    # collected once you shut off the phone

    $ export TARGETDIR=/data/local/tmp/perl
    $ adb -s $DEVICE shell "mkdir $TARGETDIR"

$ adb -s $DEVICE pull /system/lib /tmp/tmpandroidlib

$ ./Configure -des -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc -Dtargethost=$DEVICE -Dsysroot=/tmp/my-toolchain/sysroot -Dtargetdir=$TARGETDIR
$ perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh
$ make -j30
$ make test
$ make DESTDIR=/tmp/android-perl install

Then copy the perl installed into /tmp/android-perl to your device

Ben Greear

unread,
Sep 4, 2013, 2:17:05 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 10:21 AM, Brian Fraser wrote:
> On Wed, Sep 4, 2013 at 1:50 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:
>
> I used the perldroid project to cross-compile perl 5.16 for android (ARM) using
> the latest Android NDK stand-alone toolchain. After hacking on perldroid to
> fix a few things I got a mostly-working perl binary & libraries.
>
> One problem remains however. If I have perl code that does something like this,
> it will not work:
>
> my @foo = `ls run_*.PID 2>/dev/null`;
>
> I think this might be because Android has no /bin/sh. Instead, it puts the shell
> at /system/bin/sh.
>
> Maybe lacking /bin/sh perl uses some interal minimal fake shell and thus fails to handle
> more advanced system calls?
>
> Anyone know if perl can be configured to use a different shell by default, or where
> the code is that could be changed to use /system/bin/sh?
>
> Thanks,
> Ben
>
>
> Rather than using perldroid, try using castaway's branch here:
> https://github.com/castaway/perl/tree/jrobinson/configure-for-cross
>
> Which solves that and several other issues with perl on android, such as making 'system "echo", "foo"' work, even though "echo" is a shell builtin in Android,
> or being able to use both List::Util and Hash::Util in the same program, which fails on perldroid due to some limitations in the android linker.
> Also, for the time being, perhaps considering using https://github.com/Hugmeir/utf8mess/tree/configure-for-cross instead, at least until that's merged into the
> main branch, if you want to run a successful 'make test' after building, to ensure that your perl is working properly.
>
> With that branch, building perl on android is pretty simple:

I took a look at the jrobinson stuff yesterday, but I'd rather not use
an emulator, and I want the end result to be a foo/perl/lib and foo/perl/bin
(or similar) directory structure that I can copy over to my phone via
sftp or some other external means.

I also have a stand-alone toolchain set up already, so it seems I can skip
some of these steps.

I'll try based on your instructions below and see what I can see.

For your instructions below, is there a particular place on the
droid file system at which perl is expecting to be installed? I
can fiddle with @INC if needed, but easier if I don't have to.

Thanks,
Ben

Brian Fraser

unread,
Sep 4, 2013, 2:42:49 PM9/4/13
to Ben Greear, Perl5 Porters Mailing List
On Wed, Sep 4, 2013 at 3:17 PM, Ben Greear <gre...@candelatech.com> wrote:
On 09/04/2013 10:21 AM, Brian Fraser wrote:

On Wed, Sep 4, 2013 at 1:50 PM, Ben Greear <gre...@candelatech.com <mailto:greearb@candelatech.com>> wrote:

    I used the perldroid project to cross-compile perl 5.16 for android (ARM) using
    the latest Android NDK stand-alone toolchain.  After hacking on perldroid to
    fix a few things I got a mostly-working perl binary & libraries.

    One problem remains however.  If I have perl code that does something like this,
    it will not work:

    my @foo =  `ls run_*.PID 2>/dev/null`;

    I think this might be because Android has no /bin/sh.  Instead, it puts the shell
    at /system/bin/sh.

    Maybe lacking /bin/sh perl uses some interal minimal fake shell and thus fails to handle
    more advanced system calls?

    Anyone know if perl can be configured to use a different shell by default, or where
    the code is that could be changed to use /system/bin/sh?

    Thanks,
    Ben


Rather than using perldroid, try using castaway's branch here:
https://github.com/castaway/perl/tree/jrobinson/configure-for-cross

Which solves that and several other issues with perl on android, such as making 'system "echo", "foo"' work, even though "echo" is a shell builtin in Android,
or being able to use both List::Util and Hash::Util in the same program, which fails on perldroid due to some limitations in the android linker.
Also, for the time being, perhaps considering using https://github.com/Hugmeir/utf8mess/tree/configure-for-cross instead, at least until that's merged into the
main branch, if you want to run a successful 'make test' after building, to ensure that your perl is working properly.

With that branch, building perl on android is pretty simple:

I took a look at the jrobinson stuff yesterday, but I'd rather not use
an emulator

You don't have to -- I build on my phone regularly. Just replace the 'emulator-5554' above with whatever adb devices says your phone's device name is; everything else should be the same.
 
, and I want the end result to be a foo/perl/lib and foo/perl/bin
(or similar) directory structure that I can copy over to my phone via
sftp or some other external means.

That's what the 'make DESTDIR=... install' bit does. You'll have a bin/ and lib/ in the specified directory, and you can then copy that over. I recommend using adb push to copy files over.
 

I also have a stand-alone toolchain set up already, so it seems I can skip
some of these steps.

I'll try based on your instructions below and see what I can see.

For your instructions below, is there a particular place on the
droid file system at which perl is expecting to be installed?

None; it's up for you to decide where your perl goes. /data/data/my.perl, maybe? Just make sure *not* to install it on the sdcard, because android disallows executables there.

 
 I
can fiddle with @INC if needed, but easier if I don't have to.


On castaway's branch, perl on android is built with -Duserelocatableinc by default, so hopefully @INC munging will not be needed.
 

Ben Greear

unread,
Sep 4, 2013, 3:56:27 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
I tried to condense your original email instructions down to specifics for my machine,
but I'm having no luck. I'm using ugmeir's perl repo as you suggested...I did not choose
any particular branch, I just cloned it from github.

Any idea what I'm doing wrong? I'm suspicious that perl's Configure would have
no idea what to do with my $DEVICE?


export ANDROID_NDK=$HOME/android/android-ndk-r9
export ANDROID_SDK=$HOME/android/android-sdk-linux
export ANDROID_TOOLCHAIN=$HOME/my-android-toolchain-8
export PATH="$ANDROID_SDK/platform-tools:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH"

# Turn on USB debugging in developer-options on phone, then:
adb devices
export DEVICE=04dba74c5cde4be7

export TARGETDIR=/data/data/candela.lanforge/local/
adb -s $DEVICE shell "echo sh -c '\"mkdir -p $TARGETDIR\"' | su --"
adb -s $DEVICE pull /system/lib /tmp/tmpandroidlib
./Configure -des -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc -Dtargethost=$DEVICE -Dsysroot=$ANDROID_TOOLCHAIN/sysroot
-Dtargetdir=$TARGETDIR


[greearb@ben-dt2 perl-cross-ugmeir]$ ./Configure -des -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc -Dtargethost=$DEVICE
-Dsysroot=$ANDROID_TOOLCHAIN/sysroot -Dtargetdir=$TARGETDIR
First let's make sure your kit is complete. Checking...
Would you like to see the instructions? [n]
Locating common programs...
Checking compatibility between /usr/bin/echo and builtin echo (if any)...
Symbolic links are supported.
Checking how to test for symbolic links...
You can test for symbolic links with 'test -h'.
Guessing incpth
'/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include
/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed'.
Guessing libpth
'/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed'.
Using targetarch arm-linux-androideabi.
Using incpth '/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include
/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed'.
Using libpth
'/home/greearb/android/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/include-fixed'.
Usrinc not defined.
Using targethost 04dba74c5cde4be7.
Cannot continue, aborting.


Thanks,
Ben

Brian Fraser

unread,
Sep 4, 2013, 4:00:24 PM9/4/13
to Ben Greear, Perl5 Porters Mailing List
On Wed, Sep 4, 2013 at 4:56 PM, Ben Greear <gre...@candelatech.com> wrote:
I tried to condense your original email instructions down to specifics for my machine,
but I'm having no luck.  I'm using ugmeir's perl repo as you suggested...I did not choose
any particular branch, I just cloned it from github.


I'm Hugmeir, so :)
You want the configure-for-cross branch, not the main one. I think that might be the issue.

Ben Greear

unread,
Sep 4, 2013, 4:49:27 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 01:00 PM, Brian Fraser wrote:
> On Wed, Sep 4, 2013 at 4:56 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:
>
> I tried to condense your original email instructions down to specifics for my machine,
> but I'm having no luck. I'm using ugmeir's perl repo as you suggested...I did not choose
> any particular branch, I just cloned it from github.
>
>
> I'm Hugmeir, so :)
> You want the configure-for-cross branch, not the main one. I think that might be the issue.

Ahh, good to know. And I fixed the spelling in my directory name :)

It does a lot more now, but still has some issues. I'll go poke
at the run-adb-shell, I suspect it may be mis-behaving on my system...


/usr/bin/cat: output.stdout: No such file or directory
/usr/bin/cat: output.stderr: No such file or directory
/usr/bin/cat: output.status: No such file or directory
rm: cannot remove `output.stdout': No such file or directory
rm: cannot remove `output.stderr': No such file or directory
rm: cannot remove `output.status': No such file or directory
I've tried to compile and run the following simple program:

#include <stdio.h>
int main() { printf("Ok\n"); return(0); }

I used the command:

arm-linux-androideabi-gcc -o try -O -g --sysroot=/home/greearb/my-android-toolchain-8/sysroot -DDEBUGGING -I/usr/local/include
--sysroot=/home/greearb/my-android-toolchain-8/sysroot try.c -ldl -lm -lc
/home/greearb/android/perl-cross-hugmeir/Cross/run-adb-shell ./try

and I got the following output:

/usr/bin/cat: output.stdout: No such file or directory
/usr/bin/cat: output.stderr: No such file or directory
/usr/bin/cat: output.status: No such file or directory
rm: cannot remove `output.stdout': No such file or directory
rm: cannot remove `output.stderr': No such file or directory
rm: cannot remove `output.status': No such file or directory

The program compiled OK, but produced no output.
Any additional ld flags (NOT including libraries)? [y]
Ok. Stopping Configure.
[greearb@ben-dt2 perl-cross-hugmeir]$

Ben Greear

unread,
Sep 4, 2013, 4:58:53 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 01:49 PM, Ben Greear wrote:
> On 09/04/2013 01:00 PM, Brian Fraser wrote:
>> On Wed, Sep 4, 2013 at 4:56 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:
>>
>> I tried to condense your original email instructions down to specifics for my machine,
>> but I'm having no luck. I'm using ugmeir's perl repo as you suggested...I did not choose
>> any particular branch, I just cloned it from github.
>>
>>
>> I'm Hugmeir, so :)
>> You want the configure-for-cross branch, not the main one. I think that might be the issue.
>
> Ahh, good to know. And I fixed the spelling in my directory name :)
>
> It does a lot more now, but still has some issues. I'll go poke
> at the run-adb-shell, I suspect it may be mis-behaving on my system...

Ok, problem was that my /data/data/candela.lanforge/local dir was owned
by root user and not writable by the 'shell' user.

chmod 777 /data/data/candela.lanforge/local

fixed the problem.

Continuing on....

Ben Greear

unread,
Sep 4, 2013, 6:04:55 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
Ok, now I see this error in the command:

(I skiped 'make test', first try of it seemed to hang,
or maybe it was just going to take a really long time).

make DESTDIR=/tmp/android-perl install

....

make[2]: Leaving directory `/home/greearb/android/perl-cross-hugmeir/x2p'

Everything is up to date. Type 'make test' to run test suite.
host/miniperl installperl --destdir=/tmp/android-perl
WARNING: You've never run 'make test' or some tests failed! (Installing anyway.)
...//perl5.18.0
Use of uninitialized value $dev1 in numeric eq (==) at ./install_lib.pl line 123.
Use of uninitialized value $dev1 in numeric eq (==) at ./install_lib.pl line 123.
...//../lib/perl5/5.18.0/linux-androideabi/encoding.pm
...//../lib/perl5/5.18.0/subs.pm
...//../lib/perl5/5.18.0/vars.pm


...

...//../lib/perl5/5.18.0/pod/perltooc.pod
...//../lib/perl5/5.18.0/pod/perltoot.pod
...//../lib/perl5/5.18.0/pod/a2p.pod
host/miniperl installman --destdir=/tmp/android-perl
Can't load module Encode, dynamic loading not available in this perl.
(You may need to build a new perl executable which either supports
dynamic loading or has the Encode module statically linked into it.)
at lib/Pod/Man.pm line 34.
Compilation failed in require at lib/Pod/Man.pm line 34.
BEGIN failed--compilation aborted at lib/Pod/Man.pm line 34.
Compilation failed in require at installman line 13.
BEGIN failed--compilation aborted at installman line 13.
make[1]: *** [install.man] Error 255
make[1]: Leaving directory `/home/greearb/android/perl-cross-hugmeir'
make: *** [install] Error 2


I imagine I can get by with out this particular feature...is there any
way to selectively disable this so the install can complete?

Ben Greear

unread,
Sep 4, 2013, 6:13:32 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 03:04 PM, Ben Greear wrote:

> ...//../lib/perl5/5.18.0/pod/perltooc.pod
> ...//../lib/perl5/5.18.0/pod/perltoot.pod
> ...//../lib/perl5/5.18.0/pod/a2p.pod
> host/miniperl installman --destdir=/tmp/android-perl
> Can't load module Encode, dynamic loading not available in this perl.
> (You may need to build a new perl executable which either supports
> dynamic loading or has the Encode module statically linked into it.)
> at lib/Pod/Man.pm line 34.
> Compilation failed in require at lib/Pod/Man.pm line 34.
> BEGIN failed--compilation aborted at lib/Pod/Man.pm line 34.
> Compilation failed in require at installman line 13.
> BEGIN failed--compilation aborted at installman line 13.
> make[1]: *** [install.man] Error 255
> make[1]: Leaving directory `/home/greearb/android/perl-cross-hugmeir'
> make: *** [install] Error 2
>
>
> I imagine I can get by with out this particular feature...is there any
> way to selectively disable this so the install can complete?

For what did manage to install, is there a way to get rid of the 5.18.0 suffix?

And why is the directory name weird? I'm not sure where those extra "..." came from.

[greearb@ben-dt2 perl-cross-ugmeir]$ ls /tmp/android-perl.../
a2p5.18.0 enc2xs5.18.0 perlbug5.18.0 pod2man5.18.0 ptar5.18.0
c2ph5.18.0 find2perl5.18.0 perldoc5.18.0 pod2text5.18.0 ptardiff5.18.0
config_data5.18.0 h2ph5.18.0 perlivp5.18.0 pod2usage5.18.0 ptargrep5.18.0
corelist5.18.0 h2xs5.18.0 perlthanks5.18.0 podchecker5.18.0 s2p5.18.0
cpan2dist5.18.0 instmodsh5.18.0 piconv5.18.0 podselect5.18.0 shasum5.18.0
cpan5.18.0 json_pp5.18.0 pl2pm5.18.0 prove5.18.0 splain5.18.0
cpanp5.18.0 libnetcfg5.18.0 pod2html5.18.0 psed5.18.0 xsubpp5.18.0
cpanp-run-perl5.18.0 perl5.18.0 pod2latex5.18.0 pstruct5.18.0 zipdetails5.18.0
[greearb@ben-dt2 perl-cross-ugmeir]$

Tony Cook

unread,
Sep 4, 2013, 6:30:34 PM9/4/13
to Ben Greear, Brian Fraser, Perl5 Porters Mailing List
On Wed, Sep 04, 2013 at 03:13:32PM -0700, Ben Greear wrote:
> For what did manage to install, is there a way to get rid of the 5.18.0 suffix?

Configure with -Uversiononly

> And why is the directory name weird? I'm not sure where those extra "..." came from.
>
> [greearb@ben-dt2 perl-cross-ugmeir]$ ls /tmp/android-perl.../

That I don't know.

Tony

Brian Fraser

unread,
Sep 4, 2013, 6:38:29 PM9/4/13
to Ben Greear, Perl5 Porters Mailing List
On Wed, Sep 4, 2013 at 7:04 PM, Ben Greear <gre...@candelatech.com> wrote:
On 09/04/2013 01:58 PM, Ben Greear wrote:
On 09/04/2013 01:49 PM, Ben Greear wrote:
On 09/04/2013 01:00 PM, Brian Fraser wrote:
On Wed, Sep 4, 2013 at 4:56 PM, Ben Greear <gre...@candelatech.com <mailto:greearb@candelatech.com>> wrote:

    I tried to condense your original email instructions down to specifics for my machine,
    but I'm having no luck.  I'm using ugmeir's perl repo as you suggested...I did not choose
    any particular branch, I just cloned it from github.


I'm Hugmeir, so :)
You want the configure-for-cross branch, not the main one. I think that might be the issue.

Ahh, good to know.  And I fixed the spelling in my directory name :)

It does a lot more now, but still has some issues.  I'll go poke
at the run-adb-shell, I suspect it may be mis-behaving on my system...

Ok, problem was that my /data/data/candela.lanforge/local dir was owned
by root user and not writable by the 'shell' user.

chmod 777 /data/data/candela.lanforge/local

fixed the problem.

Continuing on....

Ok, now I see this error in the command:

(I skiped 'make test', first try of it seemed to hang,
or maybe it was just going to take a really long time).

It just takes a long time. You can check the progress by using 'adb shell', then cd'ing to the target directory and using cat on output.stdout
I just ran this locally and got the same error, but by that point everything but a handful of docs should be installed; my DESTDIR has everything in it (there's some configure option or another to get rid of the usr/local bit):

$ ls /tmp/androidperl
usr
$ ls /tmp/androidperl/usr
local
$ ls /tmp/androidperl/usr/local
bin  lib


Ben Greear

unread,
Sep 4, 2013, 6:46:20 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 03:38 PM, Brian Fraser wrote:
> On Wed, Sep 4, 2013 at 7:04 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:

> ...//../lib/perl5/5.18.0/pod/__perltooc.pod
> ...//../lib/perl5/5.18.0/pod/__perltoot.pod
> ...//../lib/perl5/5.18.0/pod/__a2p.pod
> host/miniperl installman --destdir=/tmp/android-perl
> Can't load module Encode, dynamic loading not available in this perl.
> (You may need to build a new perl executable which either supports
> dynamic loading or has the Encode module statically linked into it.)
> at lib/Pod/Man.pm line 34.
> Compilation failed in require at lib/Pod/Man.pm line 34.
> BEGIN failed--compilation aborted at lib/Pod/Man.pm line 34.
> Compilation failed in require at installman line 13.
> BEGIN failed--compilation aborted at installman line 13.
> make[1]: *** [install.man] Error 255
> make[1]: Leaving directory `/home/greearb/android/perl-__cross-hugmeir'
> make: *** [install] Error 2
>
>
> I imagine I can get by with out this particular feature...is there any
> way to selectively disable this so the install can complete?
>
>
> I just ran this locally and got the same error, but by that point everything but a handful of docs should be installed; my DESTDIR has everything in it (there's
> some configure option or another to get rid of the usr/local bit):
>
> $ ls /tmp/androidperl
> usr
> $ ls /tmp/androidperl/usr
> local
> $ ls /tmp/androidperl/usr/local
> bin lib

All I have are binaries, and all in the single funny-named directory.

I can edit the Makefile to comment out the thing that fails to build manpages,
and then the install completes w/out errors. Have to figure out where the libraries
are at though...

Ben Greear

unread,
Sep 4, 2013, 6:55:55 PM9/4/13
to Tony Cook, Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 03:30 PM, Tony Cook wrote:
> On Wed, Sep 04, 2013 at 03:13:32PM -0700, Ben Greear wrote:
>> For what did manage to install, is there a way to get rid of the 5.18.0 suffix?
>
> Configure with -Uversiononly

For whatever reason that didn't work, but adding this did:

-A undef:versiononly -U versiononly

That at least removes the suffixes, but still the funny install
dir name and no libraries...will go poking some more....

Brian Fraser

unread,
Sep 4, 2013, 6:57:22 PM9/4/13
to Ben Greear, Perl5 Porters Mailing List
On Wed, Sep 4, 2013 at 7:13 PM, Ben Greear <gre...@candelatech.com> wrote:
On 09/04/2013 03:04 PM, Ben Greear wrote:

   ...//../lib/perl5/5.18.0/pod/perltooc.pod
   ...//../lib/perl5/5.18.0/pod/perltoot.pod
   ...//../lib/perl5/5.18.0/pod/a2p.pod

This bit is suspicious. For me, it looks like:

[...]
  /usr/local/lib/perl5/5.18.0/pod/perltooc.pod
  /usr/local/lib/perl5/5.18.0/pod/perltoot.pod
  /usr/local/lib/perl5/5.18.0/pod/a2p.pod
host/miniperl installman --destdir=/tmp/androidperl
Can't load module Encode, dynamic loading not available in this perl.
[...]

Looks like it's trying to use installprefixexp instead of installprefix. But I'm way out of my depth here -- hopefully someone more versed in this area of the code can chime in.


Ben Greear

unread,
Sep 4, 2013, 7:28:42 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/04/2013 03:57 PM, Brian Fraser wrote:
> On Wed, Sep 4, 2013 at 7:13 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:
>
> On 09/04/2013 03:04 PM, Ben Greear wrote:
>
> ...//../lib/perl5/5.18.0/pod/__perltooc.pod
> ...//../lib/perl5/5.18.0/pod/__perltoot.pod
> ...//../lib/perl5/5.18.0/pod/__a2p.pod
>
>
> This bit is suspicious. For me, it looks like:
>
> [...]
> /usr/local/lib/perl5/5.18.0/pod/perltooc.pod
> /usr/local/lib/perl5/5.18.0/pod/perltoot.pod
> /usr/local/lib/perl5/5.18.0/pod/a2p.pod
> host/miniperl installman --destdir=/tmp/androidperl
> Can't load module Encode, dynamic loading not available in this perl.
> [...]
>
> Looks like it's trying to use installprefixexp instead of installprefix. But I'm way out of my depth here -- hopefully someone more versed in this area of the
> code can chime in.
>
>

I have things like this in my config.sh:

archlib='.../../lib/perl5/5.18.0/linux-androideabi'
archlibexp='.../../lib/perl5/5.18.0/linux-androideabi'
archname64=''
archname='linux-androideabi'
archobjs=''
asctime_r_proto='0'
awk='awk'
baserev='5.0'
bash=''
bin='.../'
bin_ELF='define'
binexp='.../'

I suspect they are to blame, but I'm not sure how Configure came up with them...


Maybe this relocatable-inc thing?

initialinstalllocation="$binexp"
: Default prefix is now "up one level from where the binaries are"
case "$userelocatableinc" in
$define|true|[yY]*)
bin=".../"
binexp=".../"
prefix=".../.."
prefixexp=".../.."
installprefixexp=".../.."
;;
esac

Ben Greear

unread,
Sep 4, 2013, 8:06:31 PM9/4/13
to Brian Fraser, Perl5 Porters Mailing List
I disabled relocatableinc, re-ran Configure, and problem remained. BUT: If
I clone a new tree and run Configure with relocateableinc disabled, then I get
something that looks right. Will test it out later.

I guess Configure remembers old stuff and is not easily persuaded to start
fresh.

./Configure -des -Duserelocatableinc -A undef:versiononly -U versiononly -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc
-Dtargethost=$DEVICE -Dsysroot=$ANDROID_TOOLCHAIN/sysroot -Dtargetdir=$TARGETDIR


Thanks,
Ben

Ben Greear

unread,
Sep 5, 2013, 1:23:51 AM9/5/13
to Brian Fraser, Perl5 Porters Mailing List
A simple test to make sure it handles `complex shell comman` works, but in a more advanced
script, I'm getting this error:

Can't load '/data/data/candela.lanforge//local/lib/perl5/5.18.0/linux-androideabi/auto/Fcntl/Perl_Fcntl.so' for module Fcntl: dlopen failed: cannot locate
symbol "Perl_stack_grow" referenced by "Perl_Fcntl.so"... at /data/data/candela.lanforge//local/lib/perl5/5.18.0/XSLoader.pm line 69.
at /data/data/candela.lanforge//local/lib/perl5/5.18.0/linux-androideabi/Fcntl.pm line 66.
Compilation failed in require at /data/data/candela.lanforge//local/lib/perl5/5.18.0/linux-androideabi/POSIX.pm line 11.
BEGIN failed--compilation aborted at /data/data/candela.lanforge//local/lib/perl5/5.18.0/linux-androideabi/POSIX.pm line 17.

I noticed that there is a ...../CORE/libperl.a file, but there is no libperl.so anywhere to be found
in the install directory.

On the older perl I tried from the perldroid project there was a libperl.so in the CORE directory.

Do I actually need the libperl.so to be created somehow or is that symbol supposed
to be located elsewhere?

Nicholas Clark

unread,
Sep 5, 2013, 3:31:25 AM9/5/13
to Ben Greear, perl5-...@perl.org
On Wed, Sep 04, 2013 at 05:06:31PM -0700, Ben Greear wrote:

> I disabled relocatableinc, re-ran Configure, and problem remained. BUT: If
> I clone a new tree and run Configure with relocateableinc disabled, then I get
> something that looks right. Will test it out later.
>
> I guess Configure remembers old stuff and is not easily persuaded to start
> fresh.

Yes, it will attempt to pick default answers to its questions from config.sh
or Policy.sh in the current directory. You'll need to delete both of these to
stop it doing that.

(Somewhere early in its fairly verbose output it says that it is doing this)

Nicholas Clark

Brian Fraser

unread,
Sep 5, 2013, 11:52:21 AM9/5/13
to Ben Greear, Perl5 Porters Mailing List
Stab in the dark, did you perhaps forget to run the

perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh

Line after configure but before running make?

If not, I'm a tad stumped. You can try setting LD_LIBRARY_PATH to something relevant, like pointing at the CORE directory, or try building a shared perl (more on that in a moment)
 

I noticed that there is a ...../CORE/libperl.a file, but there is no libperl.so anywhere to be found
in the install directory.

On the older perl I tried from the perldroid project there was a libperl.so in the CORE directory.

Do I actually need the libperl.so to be created somehow or is that symbol supposed
to be located elsewhere?

By default, perl builds a static perl, so this should be fine, but you can try building a shared libperl by running Configure with

-Uuserelocatableinc -Duseshrplib
 
And checking if that works any differently? You'll have to set both LD_LIBRARY_PATH and PERL5LIB to use that, though.


Ben Greear

unread,
Sep 5, 2013, 12:23:37 PM9/5/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/05/2013 08:52 AM, Brian Fraser wrote:
> On Thu, Sep 5, 2013 at 2:23 AM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:

> A simple test to make sure it handles `complex shell comman` works, but in a more advanced
> script, I'm getting this error:
>
> Can't load '/data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/auto/Fcntl/Perl___Fcntl.so' for module Fcntl: dlopen failed: cannot
> locate symbol "Perl_stack_grow" referenced by "Perl_Fcntl.so"... at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/__XSLoader.pm line 69.
> at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/Fcntl.pm line 66.
> Compilation failed in require at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/POSIX.pm line 11.
> BEGIN failed--compilation aborted at /data/data/candela.lanforge//__local/lib/perl5/5.18.0/linux-__androideabi/POSIX.pm line 17.
>
>
> Stab in the dark, did you perhaps forget to run the
>
> perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh

That was not the problem.

>
> Line after configure but before running make?
>
> If not, I'm a tad stumped. You can try setting LD_LIBRARY_PATH to something relevant, like pointing at the CORE directory, or try building a shared perl (more
> on that in a moment)
>
>
> I noticed that there is a ...../CORE/libperl.a file, but there is no libperl.so anywhere to be found
> in the install directory.
>
> On the older perl I tried from the perldroid project there was a libperl.so in the CORE directory.
>
> Do I actually need the libperl.so to be created somehow or is that symbol supposed
> to be located elsewhere?
>
>
> By default, perl builds a static perl, so this should be fine, but you can try building a shared libperl by running Configure with
>
> -Uuserelocatableinc -Duseshrplib
> And checking if that works any differently? You'll have to set both LD_LIBRARY_PATH and PERL5LIB to use that, though.

Building shared did fix the problem. I've yet more testing to complete, but so far
it seems OK. In case anyone else tries this, here are my notes. I think these
are free of typos, but I'll need to do another full build from clean repository
to know for sure.



# Install latest android ndk and sdk. I put them in ~/android
# and also created a stand-alone tool-chain called ~/my-android-toolchain-8
# I am compiling on an x86-64 machine (Fedora 17).
# My specific Nexus-4 DEVICE ID is used below. You would use your own
# or possibly an emulator would also work.

export ANDROID_NDK=$HOME/android/android-ndk-r9
export ANDROID_SDK=$HOME/android/android-sdk-linux
export ANDROID_TOOLCHAIN=$HOME/my-android-toolchain-8
export PATH="$ANDROID_SDK/platform-tools:$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH"

# Turn on USB debugging in developer-options on phone, then:
adb devices
export DEVICE=04dba74c5cde4be7

export TARGETDIR=/data/data/candela.lanforge/local/
adb -s $DEVICE shell "echo sh -c '\"mkdir -p $TARGETDIR\"' | su --"
adb -s $DEVICE shell "echo sh -c '\"chmod 777 $TARGETDIR\"' | su --"
adb -s $DEVICE pull /system/lib /tmp/tmpandroidlib

rm -f config.sh
rm -f Policy.sh
LF_PREFIX=/data/data/candela.lanforge/local
./Configure -des -U userelocatableinc -A undef:versiononly -U versiononly -Dusedevel -DDEBUGGING -Dusecrosscompile -Dcc=arm-linux-androideabi-gcc -Duseshrplib
-Dprefix=${LF_PREFIX} -Dtargethost=$DEVICE -Dsysroot=$ANDROID_TOOLCHAIN/sysroot -Dtargetdir=$TARGETDIR

perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/tmpandroidlib'}" config.sh
make -j30
# This next step may take a very long time.
#make test

# Comment out the manpages install, or just ignore the error, it
# does not seem to be a problem.
LF_PERL_INST=/tmp/android-perl
rm -fr /tmp/android-perl*
make DESTDIR=${LF_PERL_INST} install

#Then copy the perl installed into /tmp/android-perl to your device

# LANforge related packaging step.

rm -fr ~/perl-arm-5.18-lf
mkdir -p ~/perl-arm-5.18-lf
mv ${LF_PERL_INST}/${LF_PREFIX}/* ~/perl-arm-5.18-lf

# NOTE: You have to set LD_LIBRARY_PATH and PERL5LIB appropriately before using
# perl on the Android device, for instance

LF_HOME=/data/data/candela.lanforge
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${LF_HOME}:${LF_HOME}/local/lib:${LF_HOME}/local/lib/perl5/5.18.0/linux-androideabi/CORE
PERL5LIB=${LF_HOME}/local/lib/perl5/5.18.0/linux-androideabi:${LF_HOME}/local/lib/perl5/5.18.0/

Brian Fraser

unread,
Sep 9, 2013, 2:54:17 PM9/9/13
to Ben Greear, Perl5 Porters Mailing List
On Thu, Sep 5, 2013 at 1:23 PM, Ben Greear <gre...@candelatech.com> wrote:
On 09/05/2013 08:52 AM, Brian Fraser wrote:

Awesome! Thanks for the notes and for trying things out. Congrats on your shiny new perl, too :D Tangentially related, could you check your device's android version? I want to try reproducing & fixing the error you got with static libraries, since those really ought to be working everywhere.

And if you have the time, seeing if you can reproduce the error with the android emulator would be pretty helpful in narrowing this down -- it might be that Configure is picking things "right" in my ubuntu and mac, but gets confused in Fedora somehow.
...Or maybe it's yet another android linker fun to work around.

Ben Greear

unread,
Sep 9, 2013, 3:01:41 PM9/9/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/09/2013 11:54 AM, Brian Fraser wrote:
> On Thu, Sep 5, 2013 at 1:23 PM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com>> wrote:
>
> On 09/05/2013 08:52 AM, Brian Fraser wrote:
>
> On Thu, Sep 5, 2013 at 2:23 AM, Ben Greear <gre...@candelatech.com <mailto:gre...@candelatech.com> <mailto:greearb@candelatech.__com
> <mailto:gre...@candelatech.com>>> wrote:
>
>
> A simple test to make sure it handles `complex shell comman` works, but in a more advanced
> script, I'm getting this error:
>
> Can't load '/data/data/candela.lanforge//____local/lib/perl5/5.18.0/__linux-__androideabi/auto/__Fcntl/Perl___Fcntl.so' for module Fcntl: dlopen
> failed: cannot
> locate symbol "Perl_stack_grow" referenced by "Perl_Fcntl.so"... at /data/data/candela.lanforge//____local/lib/perl5/5.18.0/____XSLoader.pm line 69.
> at /data/data/candela.lanforge//____local/lib/perl5/5.18.0/linux-____androideabi/Fcntl.pm line 66.
> Compilation failed in require at /data/data/candela.lanforge//____local/lib/perl5/5.18.0/linux-____androideabi/POSIX.pm line 11.
> BEGIN failed--compilation aborted at /data/data/candela.lanforge//____local/lib/perl5/5.18.0/linux-____androideabi/POSIX.pm line 17.
>
>
>
> Stab in the dark, did you perhaps forget to run the
>
> perl -i -wlnpe "s{^libpth=\K.+}{'/tmp/__tmpandroidlib'}" config.sh
>
>
> That was not the problem.
>
>
>
> Line after configure but before running make?
>
> If not, I'm a tad stumped. You can try setting LD_LIBRARY_PATH to something relevant, like pointing at the CORE directory, or try building a shared perl
> (more
> on that in a moment)
>
>
> I noticed that there is a ...../CORE/libperl.a file, but there is no libperl.so anywhere to be found
> in the install directory.
>
> On the older perl I tried from the perldroid project there was a libperl.so in the CORE directory.
>
> Do I actually need the libperl.so to be created somehow or is that symbol supposed
> to be located elsewhere?
>
>
> By default, perl builds a static perl, so this should be fine, but you can try building a shared libperl by running Configure with
>
> -Uuserelocatableinc -Duseshrplib
> And checking if that works any differently? You'll have to set both LD_LIBRARY_PATH and PERL5LIB to use that, though.
>
>
> Building shared did fix the problem. I've yet more testing to complete, but so far
> it seems OK. In case anyone else tries this, here are my notes. I think these
> are free of typos, but I'll need to do another full build from clean repository
> to know for sure.
>
>
> Awesome! Thanks for the notes and for trying things out. Congrats on your shiny new perl, too :D Tangentially related, could you check your device's android
> version? I want to try reproducing & fixing the error you got with static libraries, since those really ought to be working everywhere.

It's a 'Nexus 4'. It has been rooted, and I installed the update that was automatically
pushed over the air, but aside from that it was stock when I started on it..

> And if you have the time, seeing if you can reproduce the error with the android emulator would be pretty helpful in narrowing this down -- it might be that
> Configure is picking things "right" in my ubuntu and mac, but gets confused in Fedora somehow.
> ...Or maybe it's yet another android linker fun to work around.

Might be a bit before I can get back to this porting effort.

I suspect that removing the config.sh and Policy.sh before doing any testing
would be the biggest help. Nothing is reliably reproducible without that
from what I can tell, since many of the options you might give to configure
are either ignored outright or have different effects since previous defaults
were set differently.

At least in my opinion, that behaviour from Configure is a bug.

Brian Fraser

unread,
Sep 9, 2013, 3:17:23 PM9/9/13
to Ben Greear, Perl5 Porters Mailing List
On Mon, Sep 9, 2013 at 4:01 PM, Ben Greear <gre...@candelatech.com> wrote:
On 09/09/2013 11:54 AM, Brian Fraser wrote:
On Thu, Sep 5, 2013 at 1:23 PM, Ben Greear <gre...@candelatech.com <mailto:greearb@candelatech.com>> wrote:

    On 09/05/2013 08:52 AM, Brian Fraser wrote:

        On Thu, Sep 5, 2013 at 2:23 AM, Ben Greear <gre...@candelatech.com <mailto:greearb@candelatech.com> <mailto:greearb@candelatech.__com

Hm.. 4.3 maybe? Getting the specific version would still be helpful, but that's a good starting point, thanks you. In my phone, I can get the android version by going to Preferences -> About Phone, although that might be different in newer devices.
 


And if you have the time, seeing if you can reproduce the error with the android emulator would be pretty helpful in narrowing this down -- it might be that
Configure is picking things "right" in my ubuntu and mac, but gets confused in Fedora somehow.
...Or maybe it's yet another android linker fun to work around.

Might be a bit before I can get back to this porting effort.

I suspect that removing the config.sh and Policy.sh before doing any testing
would be the biggest help.  Nothing is reliably reproducible without that
from what I can tell, since many of the options you might give to configure
are either ignored outright or have different effects since previous defaults
were set differently.

At least in my opinion, that behaviour from Configure is a bug.

I don't know what the rationale for having Configure prefer previous builds by default; I've been bitten by this before more than I've made use of it, so I personally agree that for the common case it's unhelpful. One option is passing the -O flag to Configure, but generally I just git clean -dfx and go from scratch.

Ben Greear

unread,
Sep 10, 2013, 12:21:32 PM9/10/13
to Brian Fraser, Perl5 Porters Mailing List
On 09/09/2013 12:17 PM, Brian Fraser wrote:

> Hm.. 4.3 maybe? Getting the specific version would still be helpful, but that's a good starting point, thanks you. In my phone, I can get the android version by
> going to Preferences -> About Phone, although that might be different in newer devices.

It is version 4.3.

Alexandre Jousset

unread,
Oct 10, 2013, 9:40:47 AM10/10/13
to Perl5 Porters Mailing List
Hello,

Le 04/09/2013 19:21, Brian Fraser a écrit :
> Rather than using perldroid, try using castaway's branch here:
> https://github.com/castaway/perl/tree/jrobinson/configure-for-cross
>
> Which solves that and several other issues with perl on android, such as making 'system "echo", "foo"' work, even though "echo" is a shell builtin in Android, or being able to use both List::Util and Hash::Util in the same program, which fails on perldroid due to some limitations in the android linker.
> Also, for the time being, perhaps considering using https://github.com/Hugmeir/utf8mess/tree/configure-for-cross instead, at least until that's merged into the main branch, if you want to run a successful 'make test' after building, to ensure that your perl is working properly.

I'm the initiator of the PerlDroid project and, as I stated on the project page (after Ben's questions), I'm currently waiting for the new way to cross compile perl to replace my ugly^W hacks ;-)

Does anyone has some (even rough) information about when this great work will be included in the main branch? And which (if already planned) stable version of perl will include it?

Thanks,
--
-- \^/ --
-- -/ O \--------------------------------------- --
-- | |/ \| Alexandre (Midnite) Jousset | --
-- -|___|--------------------------------------- --
0 new messages