Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to cross-compile Git for ARM?

Unfortunately, I am having difficulty cross-compiling Git for the ARMv6 architecture.

But before I begin describing the steps I've taken and commands I've entered, I should briefly describe the build environment:

  • I am cross-compiling on Ubuntu 12.10 64-bit.
  • The cross compiler is installed to /home/my_name/cctoolchain (this directory contains bin/, lib/, etc.).

I began by grabbing Git 1.8.2 from here. After extracting the directory I ran:

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

I also ran autoconf to make sure that ./configure was up to date. Then I invoked ./configure as follows:

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

This ran for a couple of seconds and then aborted with:

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

I cracked open configure.ac and removed lines 806-825, disabling the test. After doing that, I also had to remove lines 806-839 for a similar reason.

At this point, the ./configure script was able to complete. I then excitedly ran make to build Git and after a few more moments, ran into this error:

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

Somehow I get the feeling I'm "doing it wrong". This sounds like something that should be a lot easier than manually removing tests from configure.ac. What am I missing?

like image 675
Nathan Osman Avatar asked Mar 20 '13 05:03

Nathan Osman


People also ask

Why is cross compiling so hard?

"building a cross-compiler is significantly harder than building a compiler that targets the platform it runs on." The problem exists due to the way libraries are built and accessed. In the normal situation all the libraries are located in a specific spot, and are used by all apps on that system.

What is cross compiling GCC?

To cross-compile is to build on one platform a binary that will run on another platform.


1 Answers

The macro that's failing is ST_MTIME_NSEC in git-compat-util.h. This macro is controlled by the macros USE_NSEC, NO_NSEC and USE_ST_TIMESPEC, which are provided on the build commandline or by config.mak.uname, not by configure.

It should be that if no options are provided, git doesn't attempt to use nanosecond timestamps (or st_mtim) at all, but it looks like a bug slipped through.

Try make NO_NSEC=1 and see if that resolves your problem.

like image 174
hobbs Avatar answered Sep 24 '22 09:09

hobbs