[Toybox] [PATCH] Add cross compile info to README

Rob Landley rob at landley.net
Sun Oct 4 06:45:00 PDT 2015


I tried to use the email interface to let this message through (you
aren't subscribed to the list so it goes to moderation) and accidentally
discarded it instead. (Oops. Sorry.)

So here's the whole message quoted:

On 10/03/2015 02:40 PM, toybox-owner at lists.landley.net wrote:
> Subject: [PATCH] Add cross compile info to README
> From: Preetam S Reddy <preetamsashankreddy at gmail.com>
> Date: 10/03/2015 02:40 PM
> 
> To: toybox at lists.landley.net
> CC: Preetam S Reddy <preetamsashankreddy at gmail.com>
> 
> 
> Add a section for cross compiling on ubuntu. It makes it easy for
> newbies to quickly get on with the compilation for arm. Also,
> add some character drawing for section headings.

We cross compile the same way the Linux kernel does, and the "building
toybox" section has a cross compile example...

> Signed-off-by: Preetam S Reddy <preetamsashankreddy at gmail.com>
> ---
>  README | 44 ++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 36 insertions(+), 8 deletions(-)
> 
> diff --git a/README b/README
> index 9ff7368..80450a6 100644
> --- a/README
> +++ b/README
...
> @@ -40,7 +43,27 @@ For more about cross compiling, see:
>    http://landley.net/writing/docs/cross-compiling.html
>    http://landley.net/aboriginal/architectures.html
>  
> ---- Using toybox
> +====================================
> +# CROSS COMPILING in UBUNTU for ARM
> +====================================
> +
> +You will need the following environment to cross compiling for arm:
> +	$ export ARCH=arm
> +	$ export CC=gcc
> +	$ export CROSS_COMPILE=arm-____-____-
> +
> +You can use the compiler of your choice which can be:
> +
> +arm-linux-androideabi-
> +arm-linux-gnueabi-
> +arm-linux-gnueabihf-
> +arm-none-eabi-
> +
> +Depending on tour installation, use one of the above for CROSS_COMPILE.
> +
> +=============
> +# Using toybox:
> +=============

That's the new section. It's specific to a single distribution, and you
didn't actually say how to install the toolchains. (Apparently ubuntu
comes with some, you can "apt-get install gcc-arm-linux-androideabi" if
you know to do that.)

1) Toybox doesn't use $ARCH.

2) $CC defaults to "cc", as in if you don't set it the "make" command
will set it to that default value:

  http://www.gnu.org/software/make/manual/make.html#Implicit-Variables

Because back in SUSv2 (I.E. posix-1997) "cc" was the posix name for the
compiler:

  http://pubs.opengroup.org/onlinepubs/7908799/xcu/cc.html

In SUSv3 (posix-2001) that switched to "c99", which is what's currently
still there (no "c11", as of yet nobody cares):

  http://pubs.opengroup.org/onlinepubs/009695399/utilities/c99.html

Which means that in _theory_ posix-2008/2013 specifies $(CC) to default
to "c99" to but it still defaults to the older "cc" anyway:

  http://pubs.opengroup.org/onlinepubs/7908799/xcu/cc.html

But "gcc" is not a name standardized by anybody. If you're using llvm
(which android does), you're not going to say "gcc". Ubuntu provides a
"cc" symlink at /usr/bin/cc.

3) The CROSS_COMPILE variable is demonstrated in the "building toybox"
section, and has been since the very first version:

https://github.com/landley/toybox/commit/09e8bde9f292e537c35387435b5bea9024cf28e8

I'm all for making the README clearer, but could you explain what part's
confusing you a bit more? (Would it be good to link to
http://landley.net/writing/docs/cross-compiling.html maybe?

Hmmm... I suppose it's confusing that:

  make CROSS_COMPILE=blah-

Doesn't work. Because I'm not exporting the make variables. Which is
easy enough to do _except_  that $(CC) has a default value "cc", meaning
if I export it from the makefile the one in configure never gets used.
(That's why I hadn't done it before, but it's probably ok...?)

Thanks,

Rob

 1443966300.0


More information about the Toybox mailing list