如何为ARM交叉编译Git?

Nat*_*man 13 git autoconf cross-compiling

不幸的是,我很难为ARMv6架构交叉编译Git.

但在我开始描述我已经采取的步骤和我输入的命令之前,我应该简要描述一下构建环境:

  • 我在Ubuntu 12.10 64位上进行交叉编译.
  • 交叉编译器安装到/home/my_name/cctoolchain(该目录包含了bin/,lib/等).

我从这里开始抓住Git 1.8.2 .解压缩后运行的目录:

export PATH=$PATH:/home/my_name/cctoolchain/bin

我也跑去autoconf确保它./configure是最新的.然后我调用./configure如下:

./configure --prefix=/home/my_name/git-arm --build=x86_64-linux-gnu
  --host=arm-linux-androideabi

这运行了几秒钟然后中止了:

checking whether system succeeds to read fopen'ed directory...
configure: error: in `/home/my_name/git-1.8.2':
configure: error: cannot run test program while cross compiling

我打开configure.ac并删除了806-825行,禁用了测试.在这之后,我还必须删除806-839行,原因类似.

此时,./configure脚本能够完成.然后我兴奋地跑去make构建Git,经过几分钟后,遇到了这个错误:

fetch-pack.c: In function 'fetch_pack':
fetch-pack.c:928:16: error: 'struct stat' has no member named 'st_mtim'
make: *** [fetch-pack.o] Error 1

不知何故,我感觉自己"做错了".这听起来比手动删除测试要简单得多configure.ac.我错过了什么?

hob*_*bbs 11

失败的宏是ST_MTIME_NSECgit-compat-util.h.此宏由宏控制USE_NSEC,NO_NSEC并且USE_ST_TIMESPEC在构建命令行上提供,或者config.mak.uname由configure 提供,而不是由configure提供.

应该是,如果没有提供选项,Git并不试图利用纳秒时间戳(或st_mtim全部),但它看起来像一个bug溜通过.

试试看make NO_NSEC=1是否可以解决您的问题.