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

Rob Landley rob at landley.net
Sun Oct 4 18:22:08 PDT 2015


On 10/04/2015 02:39 PM, sashank reddy wrote:
> Hi Rob,
> 
> There is an issue with the cc part. I installed stock ubuntu desktop
> 14.04 and the arm tool chains with the apt-get install.
> However, the tools don't have anything that ends with cc and when that
> is combined with the arm-none-gnueabi- cc gives an error.
> That's the reason I updated the README. I don't mind adding more
> sections on installing the toolchains.

So you want me to add a warning to the README about a bug workaround for
a problems with the ubuntu cross toolchains?

> Usually ARCH is used for platform specific config to be pulled out.

Not by toybox.

There is no platform specific config in toybox. There are some
compile-time probes during configuration and some menuconfig entries
(the most significant is a musl bug workaround on nommu systems), but
powerpc vs sparc vs superh is not something you should need to specify
in the build environment.

> I like the idea of compiling the sources for all platforms without worrying
> about specific platform codes. However CROSS_COMPILE and CC are not
> going to be always intuitive.

Which is why the README said, and I cut and paste:

  The CROSS_COMPILE argument is optional, and without it builds a
  version of toybox to run on the current machine. Cross compiling
  requires an appropriately prefixed cross compiler toolchain, several
  example toolchains are available at:

    http;//landley.net/aboriginal/bin

  For the "CROSS_COMPILE=armv5l-" example above, download
  cross-compiler-armv5l.tar.bz2, extract it, and add its "bin"
  subdirectory to your $PATH. (And yes, the trailing - is significant,
  because the prefix includes a dash.)

  For more about cross compiling, see:

    http://landley.net/writing/docs/cross-compiling.html
    http://landley.net/aboriginal/architectures.html

That was there before you sent your patch. There's also a "building
toybox" section in http://landley.net/toybox/code.html#building which
once again tells you to type "make help" which ends with the line:

  example: CFLAGS="--static" CROSS_COMPILE=armv5l- make defconfig toybox
install

Now what I should probably add to the README is mention of the
"configure" file, which defines default values for environment variables
you can override. (And in doing so, lists interesting variables you
might want to override.)

> They need to be explicitly specified.

CC is a make variable described in the make manual and in the posix spec
for make. What you're saying is toybox should document how to use
"make". (I can link people to the posix page for it if you'd like?)

CROSS_COMPILE works the same as the linux kernel, the same as busybox,
the same as uClibc, and many other packages. I DID give an example of
how to use it in the existing README.

You proposed adding an ubuntu-specific description describing how to use
(but not install) ubuntu packages and work around a bug in ubuntu's
packages. While I see the point of fixing that, documenting a bug
workaround isn't getting ubuntu to fix their bug.

> I would also like to point to you that in my experience as an embedded
> developer,

Indeed.

  http://landley.net/writing/docs/cross-compiling.html
  http://landley.net/ols/ols2007/tutorial.txt

http://free-electrons.com/pub/video/2008/ols/ols2008-rob-landley-linux-compiler.ogg
  http://landley.net/aboriginal/about.html
  https://speakerdeck.com/landley/developing-for-non-x86-targets-using-qemu

Personally, I have no _idea_ what I'm doing.

By the way, the prebuilt binary cross (and native) compilers I
distribute have the $PREFIX-cc names, see cross-compiler-*.tar.gz at:

  http://landley.net/aboriginal/bin

> I had to hand hold new developers as many dint know the
> trivial stuff of exporting variables or searching through the
> environment.

Indeed. The courses I taught at the local community college were all
introductory stuff (intro to unix, intro to operating systems, intro to
java). Back when I was the Linux kernel Documentation directory
maintainer (and put together http://kernel.org/doc) I focused on
introductory material. I'm aware of the concept of "people not knowing
stuff yet".

(I had somebody quote https://www.kernel.org/doc/local/inline.html at me
last week to disagree with something I said, without knowing I wrote it.)

> Nonetheless they were good coders of algorithms. So even though
> some things are taken as granted by those already in this field,

I'm not saying "this shouldn't be documented", I'm saying the toybox
README does not seem like the appropriate place for what amounts to a
distribution-specific bug workaround.

> one must add sufficient documentation to make sure that anyone reading it
> should be able to make full compilation and understand the basic
> structure quickly.

Back when I maintained my own compiler fork, the README I wrote had a
section on cross compiling that started by explaining what a compiler _was_:

http://landley.net/hg/tinycc/file/2365d90138f5/README#l80

(That tinycc fork I maintained also wasn't gcc, and provided a "cc"
symlink to itself. Despite posix, nobody seems to "c99". Ubuntu provides
one in /usr/bin though...)

> Please let me know if you would like me to update the README further
> with a few more sections and I would be glad to post a patch.

I'm happy to see the patches. I don't guarantee I'll merge them.

I'd rather link to a definitive reference on a topic instead of trying
to incorporate an entire introductory textbook into every project's
readme. (That's why I kept the old http://nommu.org/memory-faq.txt I
wrote years ago separate rather than trying to integrate it into
http://nommu.org I wrote that earlier this year.)

I would like to get this properly documented. That doesn't mean the
README is necessarily the right place for it.

> I look
> forward to using toybox in the next version of our product. As a starter
> I intend to roll out an arm distribution for beaglebone based on toybox
> instead of the existing distribution from TI based on busybox. But my
> immediate priority is to get the latest kernel to work with the board.

I sympathize. My dayjob work on http://nommu.org/jcore has been taking
up so much of my time it's delayed my toybox work (although it was as
much the travel to Japan and getting sick afterwards that ate last
month). In that context, I've been forward-porting our kernel patch to
work with 4.2
(http://lists.nommu.org/pipermail/0pf/2015-September/000036.html) and
need to tackle 4.3 soon.

In Aboriginal Linux I've also fallen a few kernel versions behind,
although I have 4.1 and 4.2 locally tested here, I'm just trying to get
nommu support into the next release, and since I'm not skipping any
kernel versions (somebody might need to test 4.1 on mips and that means
they need my breakage reversion patch even though it was fixed properly
upstream in 4.2) that means I need to get them out _faster_ than the
kernel cycles in order to catch up.

Working on it...

(Here on the toybox side I'm trying to finish out ps and catch up on the
mailing lists submissions. Yes I saw enh's two pings about stuff I've
ignored for too long...)

> Thank you,
> Preetam

Rob

> On 4 October 2015 at 06:45, Rob Landley <rob at landley.net
> <mailto:rob at landley.net>> wrote:
> 
>     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
>     <mailto:toybox-owner at lists.landley.net> wrote:
>     > Subject: [PATCH] Add cross compile info to README
>     > From: Preetam S Reddy <preetamsashankreddy at gmail.com
>     <mailto:preetamsashankreddy at gmail.com>>
>     > Date: 10/03/2015 02:40 PM
>     >
>     > To: toybox at lists.landley.net <mailto:toybox at lists.landley.net>
>     > CC: Preetam S Reddy <preetamsashankreddy at gmail.com
>     <mailto: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 <mailto: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
> 
> 

 1444008128.0


More information about the Toybox mailing list