sqlite穿插编写翻译Python-3.6.0到aarch64/aarch32 —— 支持sqlite3

参考

https://datko.net/2013/05/10/cross-compiling-python-3-3-1-for-beaglebone-arm-angstrom/

 

平台

主机: ubuntu14.04
64bit

开发板: qemu +
aarch64
(参考: http://www.cnblogs.com/pengdonglin137/p/6442583.html

工具链: 

    aarch64-linux-gnu-gcc  (gcc version 4.9.1 二零一六0529)
 用于编写翻译aarch64上边运维的主次

    arm-none-linux-gnueabi-gcc  (gcc version
4.8.3 二〇一五0320) 用于编写翻译aarch32上面运转的顺序

Python版本: Python-3.6.0

 

概述

前方几篇博文介绍了Python2.7.13的接力编写翻译,在编写翻译前供给给Python源码打上用于交叉编写翻译的patch,从Python-3.3.1伊始,就不必要再打什么patch了,只须求在configure的时候钦定–build和–host参数即可。

上面大家以aarch64和aarch32为例表达。

 

正文

壹 、编写翻译PC上边用的Python

因为在陆续编写翻译的时候须求在PC上边运转对应版本的Python程序,所以大家供给先编译和装置PC上边用的Python,下边是命令:

1 #!/bin/bash
2 
3 ../Python-3.6.0/configure
4 
5 make -j8
6 sudo make install 

默许,Python3.6.0会被装置到/usr/local下边。

② 、交叉编写翻译

1、配置 mk1_conf.sh

  • aarch32

    1 #!/bin/bash
    2
    3 export PATH=/home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin:$PATH
    4
    5 ../Python-3.6.0/configure \
    6 –host=arm-none-linux-gnueabi \
    7 –build=armv7 \
    8 –prefix=pwd \
    9 –enable-ipv6 \
    10 –enable-shared \
    11 ac_cv_filedev_ptmx=”yes” \
    12 ac_cv_file
    dev_ptc=”no” \
    13 LDFLAGS=”-L/home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/lib” \
    14 CPPFLAGS=”-I/home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/include”

里头–build表示编写翻译出来的程序运营的CPU架构,–host是穿插编写翻译工具链。那里我早已吧sqlite3的lib和include添加上了,所以生成的python3是永葆sqlite3的。

  • aarch64

    1 #!/bin/bash
    2
    3 export PATH=/home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin:$PATH
    4
    5 ../Python-3.6.0/configure \
    6 –host=aarch64-linux-gnu \
    7 –build=aarch64 \
    8 –prefix=pwd \
    9 –enable-ipv6 \
    10 –enable-shared \
    11 ac_cv_filedev_ptmx=”yes” \
    12 ac_cv_file
    dev_ptc=”no” \
    13 LDFLAGS=”-L/home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch64/lib” \
    14 CPPFLAGS=”-I/home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch64/include”

只供给替换运转的CPU架构为aarch64,然后设置相应的工具链即可,别忘了还有sqlite3的连带路线的修改。

贰 、编写翻译和装置 mk2_make.sh

此间没有怎么好说的,上面是本子内容:

  • aarch32

    1 #!/bin/bash
    2
    3 export PATH=/home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin:$PATH
    4
    5 make -j4
    6 make install

  • aarch64

    1 #!/bin/bash
    2
    3 export PATH=/home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin:$PATH
    4
    5 make -j4
    6 make install

3、制作ramdisk

为了便利在python2和python3里头的切换,适当修改mk_ramdisk.sh如下:

  • aarch32

    1 #!/bin/bash
    2
    3 sudo rm -rf rootfs
    4 sudo rm -rf tmpfs
    5 sudo rm -rf ramdisk
    6
    7 sudo mkdir rootfs
    8 sudo cp ../busybox-1.24.2/_install/
    rootfs/ -raf
    9
    10 sudo mkdir -p rootfs/proc/
    11 sudo mkdir -p rootfs/sys/
    12 sudo mkdir -p rootfs/tmp/
    13 sudo mkdir -p rootfs/root/
    14 sudo mkdir -p rootfs/var/
    15 sudo mkdir -p rootfs/mnt/
    16
    17 sudo cp etc rootfs/ -arf
    18
    19 sudo cp -arf ../arm-2014.05/arm-none-linux-gnueabi/libc/lib rootfs/
    20
    21 ver=3
    22 sudo mkdir -p rootfs/usr
    23 pushd rootfs/usr
    24 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/lib .
    25 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/include .
    26 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/bin .
    27 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${ver}/aarch32/share .
    28 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip lib/python
    29 popd
    30
    31 #sqlite
    32 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/bin/
    rootfs/bin/
    33 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/include/ rootfs/include/
    34 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch32/lib/
    rootfs/lib/
    35 sudo strip rootfs/bin/sqlite3
    36
    37 sudo mkdir -p rootfs/dev/
    38 sudo mknod rootfs/dev/tty1 c 4 1
    39 sudo mknod rootfs/dev/tty2 c 4 2
    40 sudo mknod rootfs/dev/tty3 c 4 3
    41 sudo mknod rootfs/dev/tty4 c 4 4
    42 sudo mknod rootfs/dev/console c 5 1
    43 sudo mknod rootfs/dev/null c 1 3
    44
    45 sudo rm -rf rootfs/lib/.a
    46 sudo rm -rf rootfs/lib/
    .la
    47 sudo /home/pengdonglin/src/qemu/aarch32/arm-2014.05/bin/arm-none-linux-gnueabi-strip rootfs/lib/
    48
    49 sudo mkdir -p rootfs/tools
    50 sudo cp ./other_tools/
    rootfs/tools
    51
    52 sudo mkdir -p rootfs/lib/modules/4.10.0+
    53
    54 sudo dd if=/dev/zero of=ramdisk bs=1M count=150
    55 sudo mkfs.ext4 -F ramdisk
    56
    57 sudo mkdir -p tmpfs
    58 sudo mount -t ext4 ramdisk ./tmpfs/ -o loop
    59 sudo cp -raf rootfs/* tmpfs/
    60 sudo umount tmpfs
    61
    62 sudo gzip –best -c ramdisk > ramdisk.gz
    63 sudo mkimage -n “ramdisk” -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img

只要提醒空间不足的话,能够将dd命令的count参数扩张,同时不要忘了将kernel配置里的ramdisk的深浅也壮大:

1 Device Drivers  --->
2 
3     [*] Block devices  --->
4 
5         (153600) Default RAM disk size (kbytes)

那边将ramdisk的大小修改为了150MB,然后重新编译kernel

  • aarch64

    1 #!/bin/bash
    2
    3 sudo rm -rf rootfs
    4 sudo rm -rf tmpfs
    5 sudo rm -rf ramdisk
    6
    7 sudo mkdir rootfs
    8 sudo cp ../busybox-1.24.2/_install/
    rootfs/ -raf
    9
    10 sudo mkdir -p rootfs/proc/
    11 sudo mkdir -p rootfs/sys/
    12 sudo mkdir -p rootfs/tmp/
    13 sudo mkdir -p rootfs/root/
    14 sudo mkdir -p rootfs/var/
    15 sudo mkdir -p rootfs/mnt/
    16
    17 sudo cp etc rootfs/ -arf
    18 sudo mkdir -p rootfs/lib
    19
    20 sudo cp -arf ../gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/aarch64-linux-gnu/libc/lib/aarch64-linux-gnu/ rootfs/lib/
    21
    22 sudo rm rootfs/lib/
    .a
    23 sudo ../gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin/aarch64-linux-gnu-strip rootfs/lib/
    24
    25 version=3
    26 sudo mkdir -p rootfs/usr
    27 pushd rootfs/usr
    28 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${version}/aarch64/lib .
    29 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${version}/aarch64/include .
    30 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${version}/aarch64/bin .
    31 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/Python${version}/aarch64/share .
    32 sudo /home/pengdonglin/src/qemu/aarch64/gcc-linaro-aarch64-linux-gnu-4.9-2014.07_linux/bin/aarch64-linux-gnu-strip lib/python

    33 popd
    34
    35 #sqlite
    36 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch64/bin/ rootfs/bin/
    37 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch64/include/
    rootfs/include/
    38 sudo cp -raf /home/pengdonglin/src/qemu/python_cross_compile/SQlite/aarch64/lib/ rootfs/lib/
    39 sudo strip rootfs/bin/sqlite3
    40
    41 sudo mkdir -p rootfs/dev/
    42 sudo mknod rootfs/dev/tty1 c 4 1
    43 sudo mknod rootfs/dev/tty2 c 4 2
    44 sudo mknod rootfs/dev/tty3 c 4 3
    45 sudo mknod rootfs/dev/tty4 c 4 4
    46 sudo mknod rootfs/dev/console c 5 1
    47 sudo mknod rootfs/dev/null c 1 3
    48
    49 sudo mkdir -p rootfs/lib/modules/4.10.0+
    50
    51 pushd rootfs/lib
    52 sudo ln -sf ld-2.19-2014.07.so ld-linux-aarch64.so.1
    53 popd
    54
    55 sudo mkdir -p rootfs/tools
    56 sudo cp ./other_tools/
    rootfs/tools
    57
    58 sudo dd if=/dev/zero of=ramdisk bs=1M count=200
    59 sudo mkfs.ext4 -F ramdisk
    60
    61 sudo mkdir -p tmpfs
    62 sudo mount -t ext4 ramdisk ./tmpfs/ -o loop
    63 sudo cp -raf rootfs/* tmpfs/
    64 sudo umount tmpfs
    65
    66 sudo gzip –best -c ramdisk > ramdisk.gz
    67 sudo mkimage -n “ramdisk” -A arm -O linux -T ramdisk -C gzip -d ramdisk.gz ramdisk.img

此处将ramdisk的分寸设置为了200MB,同时修改kernel配置:

1 Device Drivers  --->
2     
3     [*] Block devices  --->
4         
5         (204800) Default RAM disk size (kbytes)

接下来再度编写翻译kernel。

4、测试

在板子起来后,运营:

 python3 /usr/lib/python3.6/test/test___all__.py 

  • aarch32

    1 [root@vexpress ]# python3 /usr/lib/python3.6/test/test_all.py
    2 phello.foo
    3 _bootlocale
    4 _collections_abc
    5 _compat_pickle
    6 _compression
    7 _dummy_thread
    8 … …
    9 .
    10 ———————————————————————-
    11 Ran 1 test in 15.731s
    12 OK

  • aarch64

    1 [root@aarch64 ]# python3 /usr/lib/python3.6/test/test_all.py
    2 [ 20.347974] random: python3: uninitialized urandom read (24 bytes read)
    3 [ 21.049645] random: fast init done
    4 phello.foo
    5 _bootlocale
    6 _collections_abc
    7 _compat_pickle
    8 _compression
    9 _dummy_thread
    10 _markupbase
    11 … …
    12 .
    13 ———————————————————————-
    14 Ran 1 test in 10.745s
    15 OK

 

网站地图xml地图