This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: building unpatched glibc from scratch


On 21 Mar 2009, Arnd-Hendrik Mathias told this:

> I am trying to build the GNU toolchain from scratch and (once again)
> facing a common problem: There seems to be a cyclic dependency between
> glibc and gcc in the following way:

Yes, but it's not a terribly annoying or irresolvable one.

> Without glibc (especially the start files crti.o etc.), gcc can only
> be built static, which is done as the first step to build glibc. A
> static gcc is built without the libgcc_eh which again is needed to
> build the glibc. To build the libgcc_eh it is necessary to build a
> dynamic gcc which requires at least the crti.o files etc. from the
> glibc.....

You can work around this by adding a Makeconfig file containing the lines

libgcc_eh :=
gnulib := -lgcc
static-gnulib := -lgcc $(libunwind)

(glibc contains its own copy of the unwinder that it will build in if it
can't pull in the compiler's version.)

You may also need to build without NPTL (which means without threading,
with recent glibcs) because NPTL requires working
__attribute__((cleanup)) support in the compiler, and *that* relies on
_Unwind_Resume, which is in libgcc_eh. However, you can convince GCC to
build a libgcc_eh which contains this function (but not other functions
which do depend on glibc) by defining inhibit_libc when building GCC.
(This automatically gets defined if you don't have any cross C library
headers when doing a cross bootstrap.)

With that, you should have a (smaller) libgcc_eh, with which you can
build glibc.

(At least, this worked for me six months ago, so it probably still works
now. You should be able to get everything working by building GCC,
then glibc, then GCC again against that glibc.)


(I think. Anyone who knows better, please feel free to contradict me.
I am only an egg.)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]