error cross-compiling to ARM

Rob Landley rob at landley.net
Sun Aug 29 18:30:41 UTC 2010


On Saturday 28 August 2010 08:12:20 Denys Vlasenko wrote:
> On Saturday 28 August 2010 12:47, Salim Tyrewala wrote:
> > Hi,
> >
> > I'm new to busybox. I'm having trouble cross-compiling busybox to ARM
> > using arm-elf-gcc. It doesn't find some include files byteswap.h for
> > instance.

Building with a --target=arm-elf-gcc tuple means you're building a compiler 
targeting the bare metal, with no Linux support.  This means it can build 
things that boot on the bare metal, like the u-boot binary, vmlinux, or stuff 
where you supply your own OS support as part of the C library 
(newlib/libgloss).  But it's not set up to build userspace Linux programs.  
(It won't automatically link them against crt1.o or libc.so, hasn't got a C 
library's header files in its default #include search path, etc.)

> > I can compile natively just fine using native gcc.
> >
> > I'm not sure what is happening differently when I cross-compile. Why
> > isn't the include path include /usr/include where it should find all
> > the headers?
>
> Whom do you ask? Are people who built your toolchain on this list?

Cross compiling is a giant evil pile of suck that takes a _long_ time to 
explain properly.

It's a bit like c++: you can get a very shallow understanding in about 5 
minutes, but everything you know is a polite fiction which doesn't match what 
actually happens when you move out of the shallow end of the pool.  Actually 
understanding what _is_ going on under the covers takes weeks to explain and 
months if not years to learn.  (Meaning having learned lots of it I could sit 
down and write up a course on it in a few weeks, but it would take you months 
to absorb all the information.)

> > I think I'm doing something stupid. Please help!
>
> I tried to cross-compiling to arm using Rob's toolchain
> from Aboriginal Linux and it worked. Here's the script:
>
>
>
> #!/bin/sh
>
> set -e
>
> test -f cross-compiler-armv5l.tar.bz2 \
>
> || wget
> || http://impactlinux.com/aboriginal/downloads/binaries/cross-compiler-armv
> ||5l.tar.bz2
>
> rm -rf cross-compiler-armv5l
> tar xf cross-compiler-armv5l.tar.bz2
>
> test -f busybox-1.17.2.tar.bz2 \
>
> || wget http://busybox.net/downloads/busybox-1.17.2.tar.bz2
>
> rm -rf busybox-1.17.2
> tar xf busybox-1.17.2.tar.bz2
>
> CROSS_COMPILE="$PWD/cross-compiler-armv5l/bin/armv5l-"
>
> cd busybox-1.17.2
> make CROSS_COMPILE="$CROSS_COMPILE" defconfig
> sed
> "s:^CONFIG_CROSS_COMPILER_PREFIX.*:CONFIG_CROSS_COMPILER_PREFIX=\"$CROSS_CO
>MPILE\":" -i .config make


Just specify CROSS_COMPILE= on the actual make command line.  The configure 
stage doesn't need to know where it is.  (Busybox configure is just doing 
feature selection, it should be target-agnostic.)

  # Extract the cross compiler and add it to the $PATH.
  tar xvjf cross-compiler-armv5l.tar.bz2
  export PATH=$(pwd)/bin:$PATH

  # Extract busybox and cd into it.
  tar xvjf busybox-1.17.2.tar.bz2
  cd busybox-1.17.2

  # Build the sucker, letting busybox know it needs to use the "armv5l-"
  # prefix on tool names like armv5l-cc and armv5l-strip.
  make defconfig
  make CROSS_COMPILE=armv5l-

Rob
-- 
GPLv3: as worthy a successor as The Phantom Menace, as timely as Duke Nukem 
Forever, and as welcome as New Coke.


More information about the busybox mailing list