2023年12月31日发(作者:)
PERL 移植到ARM(miniperl)过程
本移植过程使用的环境:
Host: Fedora Core 9, IBM thinkpad T61, 安装i386 perl 5.10.0
Target: Tiny 6410(S3C6410),交叉编译使用 源码。
GCC: gcc-4.5.1 (交叉编译环境由友善之臂提供的toolchain工具)
按照README的说明:
The main target is arm-linux but I have also managed to successfully cross-compile
Perl for Solaris x86 using the same buildsystem.
We are currently dependent on an existing working local copy of
Perl ** of the same version and revision ** which is available
as /usr/bin/perl.
1)
You should be reading me (README) /Cross
2) Make sure you are in the Cross directory.
3) Edit the file 'config' to contain your target platform information.
4) make patch ## This will patch the existing source-tree.
5) make perl ## Will make perl
具体操作步骤:
1) 进入perl源码中Cross文件夹
cd /home/darren/perl-5.10.0/Cross
1) 配置Cross文件夹中的配置文件config:
[root@localhost Cross]# cat config
#####################################################################
#
# This is the configuration file used to specify the target platform and
# required level of debug or optimisation.
#
#####################################################################
### Target Arch
ARCH = arm
#ARCH = i386-pc
#ARCH = sh4
#ARCH = mips
#ARCH = mipsel
#ARCH = ppc
## Specific arm
#CONFIG_TARGET_ARM_SA11X0 = 1
#CONFIG_TARGET_ARM_XSCALE = 1
### Target OS
OS = linux
#OS = solaris2.8
2)修改Cross下面的Makefile文件
export CROSS=/opt/FriendlyARM/toolschain/4.5.1/bin/$(ARCH)-$(OS)-
增加环境变量LD_LIBRARY_PATH
export
LD_LIBRARY=/opt/FriendlyARM/toolschain/4.5.1/lib:$(LD_LIBRARY_PATH)
3)make patch
[root@localhost Cross]# make patch
cd .. ; if [ ! -e ./CROSS_PATCHED ] ; then
patch -p1 < Cross/;
patch -p1 < Cross/ ; mv installperl
installperl-patched;
sed -e 's/XXSTRIPXX/arm-linux/' installperl-patched > installperl;
touch CROSS_PATCHED ; fi
patching file
Hunk #2 succeeded at 430 with fuzz 2 (offset 52 lines).
Hunk #3 succeeded at 396 with fuzz 2 (offset -6 lines).
Hunk #4 FAILED at 574.
Hunk #5 FAILED at 582.
Hunk #6 succeeded at 841 with fuzz 1 (offset 86 lines).
Hunk #7 FAILED at 850.
Hunk #8 FAILED at 924.
Hunk #9 FAILED at 1026.
Hunk #10 succeeded at 1098 (offset 7 lines).
Hunk #11 succeeded at 1291 with fuzz 2 (offset 87 lines).
5 out of 11 hunks FAILED -- saving rejects to file
missing header for unified diff at line 3 of patch
patching file installperl
4)make perl
Make perl 过程中会遇到下列的错误:
universal.c: At top level:
op_reg_common.h:59:1: warning: 'set_regex_charset' defined but not used
`sh cflags "optimize='-O2'" generate_uudmap.o` -fexpensive-optimizations
-fomit-frame-pointer -O2 generate_uudmap.c
CCCMD = arm-linux-gcc -DPERL_CORE -c -fexpensive-optimizations
-fomit-frame-pointer -O2 -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: ./generate_uudmap: cannot execute binary file
make[1]: *** [bitcount.h] 错误 126
make[1]: Leaving directory `/home/darren/perl-5.14.1'
make[1]: Entering directory `/home/darren/perl-5.14.1'
make[1]: *** 没有规则可以创建目标“more”。 停止。
make[1]: Leaving directory `/home/darren/perl-5.14.1'
make: *** [perl] 错误 2
上面几行的意思是生成generate_uudmap程序,然后产生uudmap.h头文件,由于generate_uudmap是arm架构的,在此处执行不了,因此可以换种方式实现:把perl-5.10.0根目录下的Makefile中这几行屏蔽掉:
#globals$(OBJ_EXT): uudmap.h
#uudmap.h: generate_uudmap$(EXE_EXT)
# $(RUN) ./generate_uudmap$(EXE_EXT) >uudmap.h
#generate_uudmap$(EXE_EXT): generate_uudmap$(OBJ_EXT)
# $(CC) -o generate_uudmap $(LDFLAGS) generate_uudmap$(OBJ_EXT)
$(libs)
再把 i386架构下生成的uudmap.h文件拷贝过来使用:
/usr/lib/perl5/5.10.0/i386-linux-thread-multi/CORE/uudmap.h
重新执行make perl命令会遇到下面的错误:
mv miniperl miniperl-arm
ln -s /usr/bin/perl miniperl
make[1]: Leaving directory `/home/darren/perl-5.10.0'
make[1]: Entering directory `/home/darren/perl-5.10.0'
LD_LIBRARY_PATH=/home/darren/perl-5.10.0
/opt/FriendlyARM/toolschain/4.5.1/bin/arm-linux-gcc -o miniperl
`echo gv.o toke.o perly.o op.o pad.o regcomp.o dump.o util.o mg.o
reentr.o mro.o hv.o av.o perl.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 xsutils.o globals.o
perlio.o perlapi.o numeric.o mathoms.o locale.o pp_pack.o pp_sort.o | sed 's/ op.o
/ /'`
miniperlmain.o opmini.o -lnsl -ldl -lm -lcrypt -lutil -lc
LD_LIBRARY_PATH=/home/darren/perl-5.10.0 ./miniperl -w -Ilib -MExporter -e '>'
|| make minitest
/bin/sh: ./miniperl: cannot execute binary file
make[2]: Entering directory `/home/darren/perl-5.10.0'
make[3]: Entering directory `/home/darren/perl-5.10.0'
LD_LIBRARY_PATH=/home/darren/perl-5.10.0 ./miniperl -Ilib configpm
/bin/sh: ./miniperl: cannot execute binary file
make[3]: *** [lib/] 错误 126
make[3]: Leaving directory `/home/darren/perl-5.10.0'
make[2]: [] 错误 2 (忽略)
You may see some irrelevant test failures if you have been unable
to build lib/, lib/ or the Unicode data files.
cd t && (rm -f perl; /bin/ln -s ../miniperl perl)
&& LD_LIBRARY_PATH=/home/darren/perl-5.10.0 ./perl TEST
-minitest base/*.t comp/*.t cmd/*.t run/*.t io/*.t op/*.t uni/*.t mro/*.t
/bin/sh: line 1: ./perl: cannot execute binary file
make[2]: [minitest] 错误 126 (忽略)
make[2]: Leaving directory `/home/darren/perl-5.10.0'
LD_LIBRARY_PATH=/home/darren/perl-5.10.0 ./miniperl -Ilib configpm
/bin/sh: ./miniperl: cannot execute binary file
make[1]: *** [lib/] 错误 126
make[1]: Leaving directory `/home/darren/perl-5.10.0'
make: *** [perl] 错误 2
4) 尽管遇到上面的错误,从输出中,我们可以看出,miniperl-arm已经编译成功,之所以出现上面的错误,是因为在miniperl-arm是arm上的可执行文件,在i386上无法执行。
5)将miniperl-arm复制到目标板上的/bin目录下,并建立下面的链接:
ln –sf miniperl-arm perl
6) 运行perl –v检查 perl的版本信息
[root@FriendlyARM /bin]# perl -v
This is perl, v5.10.0 built for arm-linux
Copyright 1987-2007, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at /, the Perl Home Page.
7) 编写perl测试脚本,测试arm板上的perl的基本功能。
8) 其它perl的pm模块需要自行添加到arm板上的@INC制定的路径下。(这些pm package
木块是否需要针对arm进行编译,这点没有验证过)。
[root@FriendlyARM /bin]# ./
Can't locate in @INC (@INC contains: /usr/lib/perl5/5.10.0/arm-linux
/usr/lib/perl5/5.10.0 /usr/lib/perl5/site_perl/5.10.0/arm-linux /usr/lib/perl5/site_perl/5.10.0
/usr/lib/perl5/site_perl .) at ./ line 2.
BEGIN failed--compilation aborted at ./ line 2.


发布评论