Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 29 Jul 2012 00:42:21 +1000
From: James Bond <>
Subject: Re: bootstrap-linux patches for cross compilation to arm

On Sat, Jul 28, 2012 at 10:54 PM, Rich Felker <> wrote:

> On Sat, Jul 28, 2012 at 10:18:43PM +1000, James Bond wrote:
> > - add host_configargs="LIBS=-lc" and --with-stage1-libs=-lc for native
> > gcc/binutils compile so that they don't pull in *printf from libiberty
> > (which segfaults).
> Do you have any idea why this is needed? Are they always pulled in
> (and just don't segfault on other archs), or is pulling them in
> arm-specific?

This seems to be a problem in arm only. Unpatched bootstrap will build
cross x86-64 --> x86 rootfs and native toolchain fine, no problem.

The problem so far looks like this: some of the helper functions in libgcc
raises exceptions; and the code for these exceptions in libc (also musl).
But when using static libc, libc is linked in first before libgcc, thus
libgcc's dependencies on libc can't be resolved unless we add "-lc" at the

One can easily exhibit the same problem using musl-cross too - just make
sure that musl-cross build a toolchain with static musl libc (instead of
the default dynamic libc). Then compile "#include <stdio.h> void main() {
printf("hello %d\n"); }" with "arm-linux-musleabi -o hello hello.c" --- you
will get a host of unsatisfied dependency errors for raise, abort, etc
basically the stack unwinding stuff. The problem is down the chain printf
uses division, and division is done in libgcc and can raise exception, thus
the need for the stack unwinding code. To get it to compile, I found that I
need to do "arm-linux-musleabi -o hello hello.c -lc" instead.

Note the dependency complains is about raise/abort - not about printf, so
it indicates (to me at least) that libc did get pull in earlier, but
somehow gcc missed that it also needs to bring in the stack unwinding code.

The end result is without adding those parameters, libiberty configure will
fail to detect that musl has *printf (because compilation fails), and thus
pulls in its own version (which crash but that's totally out of topic

Those host_configargs and --with-stage1-libs is a hack to get gcc/binutils
configure test programs to compile so that libibery doesn't pull in more
than what is needed.

> > - add linux-arm.config
> >
> > Some known issues:
> > a) musl version as configured is at 0.9.2 but with arm it won't boot with
> > 0.9.2 (busybox segfaults), you need to get the latest git master, make a
> > tarball out of it and rename it to musl-0.9.2.tar.gz in the "src"
> > directory.
> Do you know which bugfix solved this? It would be nice to mention in
> the 0.9.3 release notes/announcement (hopefully in the next few days).

Thanks. I tested with commit  06650b968461b72d5eb44063dd68c176be330372
which is rather ancient in musl reckoning, it's the one with all John's
patches merged in. I'd do a test with a more recent commit and get back to

> > This is my first post to the mailing list, so you feel this kind of stuff
> > is out of topic, my apology and lesson learnt.
> Welcome to the list. This type of contribution to the list is
> perfectly acceptable.

Thank you.


Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.