Crosscompile Perl for Android x86

I like crossover Perl for x86 emulator for Android. But I got a PIE (position of independent executables) error when running Configure ... Based on this and this tutorial.

Specifications:

  • NDK Version 14
  • Perl 5.22.1.
  • x86 Android emulator built with AOSP - Android 7.1.1

I have set the following variables:

export ANDROID_NDK=/home/fabian/Android/Sdk/ndk-bundle
export TARGET_ARCH=x86
export ANDROID_TOOLCHAIN=/tmp/toolchain-x86
export SYSROOT=$ANDROID_TOOLCHAIN/sysroot
export TARGETDIR=/data/local/perl
export GCC=i686-linux-android-gcc
export PATH=$PATH:$ANDROID_NDK/toolchains/x86-4.9/prebuilt/linux-x86_64/bin

      

Then I create the toolchain with the following command:

$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --platform=android-23 --install-dir=$ANDROID_TOOLCHAIN --toolchain=x86-4.9

      

and get this (correct?) output:

HOST_OS=linux
HOST_EXE=
HOST_ARCH=x86_64
HOST_TAG=linux-x86_64
HOST_NUM_CPUS=4
BUILD_NUM_CPUS=8
Auto-config: --arch=x86
Toolchain installed to /tmp/toolchain-x86.

      

Then I run the command ./Configure

:

./Configure -des -Dusedevel -Dusecrosscompile -Dtargetrun=adb -Dcc=i686-linux-android-gcc -Dsysroot=$SYSROOT -Dtargetdir=$TARGETDIR -Dtargethost=emulator-5554

      

and got this output:

    First let make sure your kit is complete. Checking ...
    Would you like to see the instructions? [n]  
    Locating common programs ...
    Checking compatibility between / 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'.
    Using targetarch i686-linux-android.
    Using targethost emulator-5554.
    Building host miniperl and generate_uudmap binaries
    Using targethost emulator-5554.
    Guessing targetuser root.
    Guessing targetport 22.
    Using '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb' for remote execution,
    and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/from-scp' and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/to-scp'
    for remote file transfer.
    Good, your tr supports [: lower:] and [: upper:] to convert case.
    Using [: upper:] and [: lower:] to convert case.
    aix_3 dragonfly irix_4 nonstopux stellar   
    aix_4 dynixptx irix_5 openbsd sunos_4_0   
    aix dynix irix_6_0 opus sunos_4_1   
    altos486 epix irix_6_1 os2 super-ux   
    amigaos esix4 irix_6 os390 svr4   
    atheos fps isc_2 os400 svr5   
    aux_3 freebsd isc posix-bc ti1500   
    bitrig freemint linux-android powerux ultrix_4   
    bsdos genix linux qnx umips   
    catamount gnukfreebsd lynxos riscos unicosmk   
    convexos gnuknetbsd midnightbsd sco_2_3_0 unicos   
    cxux gnu mips sco_2_3_1 unisysdynix   
    cygwin greenhills mirbsd sco_2_3_2 utekv   
    darwin haiku mpc sco_2_3_3 uwin   
    dcosx hpux ncr_tower sco_2_3_4 vos   
    dec_osf i386 netbsd sco   
    dos_djgpp interix newsos4 solaris_2   
    Which of these apply, if any? [linux-android]  
    "./a.out": error: only position independent executables (PIE) are supported.
    Aborted 

    You don't have an ELF gcc. I will use dld if possible. If you are
    using a version of DLD earlier than 3.2.6, or don't have it at all, you
    should probably upgrade. If you are forced to use 3.2.4, you should
    uncomment a couple of lines in hints / linux.sh and restart Configure so
    that shared libraries will be disallowed.


    Disabling ndbm. This will generate a Whoa There message in Configure.
    Read hints / linux.sh for further information.
    Operating system name? [linux-android]  
    Operating system version? [7.1.1]  
    Installation prefix to use? (~ name ok) [/ usr / local]  
    AFS does not seem to be running ...
    What installation prefix should I use for installing files? (~ name ok)
    [/ usr / local]  
    Getting the current patchlevel ...
    Build a threading Perl? [n]  
    Build Perl for multiplicity? [n]  
    Use which C compiler? [i686-linux-android-gcc]  
    Checking for GNU cc in disguise and / or its version number ...
    "./try": error: only position independent executables (PIE) are supported.
    Aborted 
    Now, how can we feed standard input to your C preprocessor ...
    Directories to use for library searches?
    [/tmp/toolchain-x86/sysroot/usr/lib/../lib / tmp / toolchain-x86 / sysroot / usr / lib]  
    What is the file extension used for shared libraries? [sa]  
    Make shared library basenames unique? [n]  
    Hmm. Based on the hints in hints / linux-android.sh,
    the recommended value for $ d_libname_unique on this machine was "define"!
        Keep the recommended value? [y]  
    Build Perl for SOCKS? [n]  
    Try to use long doubles if available? [n]  
    Checking for optional libraries ...
    What libraries to use? [-lm -lc]  
    What optimizer / debugger flag should be used? [-O2]  
    Any additional cc flags?
    [-DOVR_DBL_DIG = 14 --sysroot = / tmp / toolchain-x86 / sysroot]  
    Let me guess what the preprocessor flags are ...
    Any additional ld flags (NOT including libraries)?
    [--sysroot = / tmp / toolchain-x86 / sysroot]  
    Checking your choice of C compiler and flags for coherency ...
    I've tried to compile and run the following simple program:

    #include 
    int main () {printf ("Ok \ n"); return (0); }

    I used the command:

        i686-linux-android-gcc -o try -O2 -DOVR_DBL_DIG = 14 --sysroot = / tmp / toolchain-x86 / sysroot --sysroot = / tmp / toolchain-x86 / sysroot try.c -lm -lc
        /home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb-shell ./try
    
    and I got the following output:

    
    The program compiled OK, but exited with status 134.
    You have a problem. Shall I abort Configure [y]  
    Ok. Stopping Configure.

OK I need to set flags

Modify config.sh to enable PIE support. Add "-fPIE" to ccflags and "-fPIE -pie" to ldflags. Then repeat the setup to make sure it's attached.

But there is no perl in the folder config.sh

, so I tried this command ./Configure

:

`./Configure -des -Dusedevel -Dusecrosscompile -Dtargetrun = adb -Dcc = i686-linux-android-gcc -Dsysroot = $ SYSROOT -Dtargetdir = $ TARGETDIR -Dtargethost = emulator-5554 -Dccflags = '- fPIE =' Dldflags -fPIE -pie ' '

but again the problem ...

    First let make sure your kit is complete. Checking ...
    Would you like to see the instructions? [n]  
    Locating common programs ...
    Checking compatibility between / 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'.
    Using targetarch i686-linux-android.
    Using targethost emulator-5554.
    Building host miniperl and generate_uudmap binaries
    Using targethost emulator-5554.
    Guessing targetuser root.
    Guessing targetport 22.
    Using '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb' for remote execution,
    and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/from-scp' and '/home/fabian/Desktop/Testimages/perl-5.22.1/Cross/to-scp'
    for remote file transfer.
    Good, your tr supports [: lower:] and [: upper:] to convert case.
    Using [: upper:] and [: lower:] to convert case.
    aix_3 dragonfly irix_4 nonstopux stellar   
    aix_4 dynixptx irix_5 openbsd sunos_4_0   
    aix dynix irix_6_0 opus sunos_4_1   
    altos486 epix irix_6_1 os2 super-ux   
    amigaos esix4 irix_6 os390 svr4   
    atheos fps isc_2 os400 svr5   
    aux_3 freebsd isc posix-bc ti1500   
    bitrig freemint linux-android powerux ultrix_4   
    bsdos genix linux qnx umips   
    catamount gnukfreebsd lynxos riscos unicosmk   
    convexos gnuknetbsd midnightbsd sco_2_3_0 unicos   
    cxux gnu mips sco_2_3_1 unisysdynix   
    cygwin greenhills mirbsd sco_2_3_2 utekv   
    darwin haiku mpc sco_2_3_3 uwin   
    dcosx hpux ncr_tower sco_2_3_4 vos   
    dec_osf i386 netbsd sco   
    dos_djgpp interix newsos4 solaris_2   
    Which of these apply, if any? [linux-android]  
    "./a.out": error: only position independent executables (PIE) are supported.
    Aborted 

    You don't have an ELF gcc. I will use dld if possible. If you are
    using a version of DLD earlier than 3.2.6, or don't have it at all, you
    should probably upgrade. If you are forced to use 3.2.4, you should
    uncomment a couple of lines in hints / linux.sh and restart Configure so
    that shared libraries will be disallowed.


    Disabling ndbm. This will generate a Whoa There message in Configure.
    Read hints / linux.sh for further information.
    Operating system name? [linux-android]  
    Operating system version? [7.1.1]  
    Installation prefix to use? (~ name ok) [/ usr / local]  
    AFS does not seem to be running ...
    What installation prefix should I use for installing files? (~ name ok)
    [/ usr / local]  
    Getting the current patchlevel ...
    Build a threading Perl? [n]  
    Build Perl for multiplicity? [n]  
    Use which C compiler? [i686-linux-android-gcc]  
    Checking for GNU cc in disguise and / or its version number ...
    "./try": error: only position independent executables (PIE) are supported.
    Aborted 
    Now, how can we feed standard input to your C preprocessor ...
    Directories to use for library searches?
    [/tmp/toolchain-x86/sysroot/usr/lib/../lib / tmp / toolchain-x86 / sysroot / usr / lib]  
    What is the file extension used for shared libraries? [sa]  
    Make shared library basenames unique? [n]  
    Hmm. Based on the hints in hints / linux-android.sh,
    the recommended value for $ d_libname_unique on this machine was "define"!
        Keep the recommended value? [y]  
    Build Perl for SOCKS? [n]  
    Try to use long doubles if available? [n]  
    Checking for optional libraries ...
    What libraries to use? [-lm -lc]  
    What optimizer / debugger flag should be used? [-O2]  
    Any additional cc flags?
    [-DOVR_DBL_DIG = 14 -fPIE --sysroot = / tmp / toolchain-x86 / sysroot]  
    Let me guess what the preprocessor flags are ...
    Any additional ld flags (NOT including libraries)?
    [--sysroot = / tmp / toolchain-x86 / sysroot]  
    Checking your choice of C compiler and flags for coherency ...
    I've tried to compile and run the following simple program:

    #include 
    int main () {printf ("Ok \ n"); return (0); }

    I used the command:

        i686-linux-android-gcc -o try -O2 -DOVR_DBL_DIG = 14 -fPIE --sysroot = / tmp / toolchain-x86 / sysroot --sysroot = / tmp / toolchain-x86 / sysroot try.c -lm -lc
        /home/fabian/Desktop/Testimages/perl-5.22.1/Cross/run-adb-shell ./try

    and I got the following output:

    "./try": error: only position independent executables (PIE) are supported.
    Aborted 
    The program compiled OK, but exited with status 134.
    You have a problem. Shall I abort Configure [y]  
    Ok. Stopping Configure.

But now ccflag is installed as you can see in the last lines ...

Did I miss something?

+3


source to share





All Articles