I'm attempting to cross compile the perl interpreter for an ARM architecture (FriendlyARM Micro2440). I'm using the ARM-Linux GCC 4.4.3 cross-compiler provided by the manufacturer. The board is running Linux 2.6.
I was able to cross-compile a basic "Hello World" application successfully, and it ran on the target machine.
I've downloaded the perl v5.12.3 source. I was able to do a normal compilation of perl for Ubuntu. I'm now attempting to do a cross-compilation for the ARM board. I'm working out of the perl-5.12.3/Cross folder in the source download.
make patch
succeeded, but when I run make perl
it fails with this
LD_LIBRARY_PATH=/home/reed022/.local/share/Trash/files/perl-5.2.12.3 arm-linux-gcc -o miniperl \
gv.o toke.o perly.o pad.o regcomp.o dump.o util.o mg.o reentr.o mro.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o pp_sys.o doop.o doio.o regexec.o utf8.o taint.o deb.o universal.o globals.o perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o \
miniperlmain.o opmini.o perlmini.o -lnsl -ldl -lm -lcrypt -lutil -lc
LD_LIBRARY_PATH=/home/reed022/.local/share/Trash/files/perl-5.2.12.3 ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest
./miniperl: 1: Syntax error: word unexpected (expecting ")")
I think the relevant part of the output is the ./miniperl -w -Ilib -MExporter -e '<?>' || make minitest
part. Though I'm not sure. It seems confusing to me that the cross-compilation environment would try to run tests, since it's targeting a different system than the one it's being built on.
I'm completely lost as where to go from here. The people I've talked to haven't had much experience with cross-compiling programs.
UPDATE
I decided to delete the perl source folder and re-extract it, thinking that the previous compilation of perl for the Ubuntu host machine might have been messing with the current cross-compilation. I'm now getting a different but similar error.
`sh cflags "optimize='-O2'" generate_uudmap.o` -fexpensive-optimizations -fomit-frame-pointer -O2 -march=armv4 -mtune=strongarm1100 generate_uudmap.c
CCCMD = arm-linux-gcc -DPERL_CORE -c -fexpensive-optimizations -fomit-frame-pointer -O2 -march=armv4 -mtune=strongarm1100 -O2 -Wall
arm-linux-gcc -o generate_uudmap generate_uudmap.o -lnsl -ldl -lm -lcrypt -lutil -lc
./generate_uudmap uudmap.h bitcount.h
./generate_uudmap: 1: Syntax error: word unexpected (expecting ")")
make[1]: *** [bitcount.h] Error 2
make[1]: Leaving directory `/home/reed022/Downloads/perl-5.12.3'
make[1]: Entering directory `/home/reed022/Downloads/perl-5.12.3'
make[1]: *** No rule to make target `more'. Stop.
make[1]: Leaving directory `/home/reed022/Downloads/perl-5.12.3'
make: *** [perl] Error 2
Apparently the way to cross compile perl is not to do it under the Cross directory. I needed to pass flags to Configure to set it up. I also needed to setup the ARM computer with an SSH server (I used dropbear). The flags I used are
sh ./Configure
-Dusecrosscompile
-Dtargethost=<IP of ARM computer>
-Dtargetuser=<user name>
-Dtargetarch=arm-linux
-Dcc=arm-linux-gcc
-Dusrinc=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include/
-Dincpth=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi/include/
-Dlibpth=/opt/FriendlyARM/toolschain/4.4.3/lib
-Dtargetdir=/sdcard/perl
The easiest way to cross-compile perl for arm is to use perl-cross.
Alex Suykov developed a set of patches for perl that works around the requirement to have a target machine available. Part of the solution is avoiding make test since the host can't run cross-compiled code anyway.
I used arm-unknown-linux-uclibcgnueabi as my target (to match my buildroot toolchain), but otherwise the directions for perl 5.18.0 worked just fine.
Alex last updated the github repository on April 23, 2014, so this project is still relatively active.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With