## `--enable-libgcc-rebuild`

If you build libstdc++ using certain flags (e.g., -fnew-abi), then programs that use some of the new C++ language features (like namespace std and RTTI) will only link if the compiler's libgcc is built using the same flags. Other extralinguistic flags (like -fsquangle to change the name mangling algorithm) will have the same effect.

Since the compiler and this library are currently separate projects, you would normally have to do this yourself. Passing --enable-libgcc-rebuild to libstdc++'s configure script means that when you type 'make' next, after libstdc++ is built, then libgcc will also be rebuilt. If you've given other --enable/--with switches to libstdc++ that would require a core library rebuild, then those compiler options will be automatically used when compiling libgcc, such that both libraries will always be built with the same options.

Of course, since they are currently separate projects, the libstdc++ scripts have no idea where you've built your GCC, so you must tell it. The argument to this enable switch is the path to the GCC build directory. The GCC configuration documentation refers to this directory as objdir; here it will be called GCCobjdir.

This is a kludge, and will go away eventually. (In a sense, it has already gone away, as the library sources have been merged into the compiler sources.)

### If you kept your GCCobjdir

Easy as pi, er, pie. Just pass the pathname to the --enable switch (absolute pathnames are best), and build libstdc++ as you normally would. When it is finished, 'make' will go over to GCCobjdir and build a new libgcc.a for you.

Once that's done, skip down to "Installing the new libgcc.a."

### If you deleted your GCCobjdir, or never had one

Aaargggghhh, you had to make things difficult. Okay, note for future reference: if you plan on experimenting with weird features, you'll want to keep your build directories around. If you're having to re-unpack the GCC source for this step, the same thing applies.

We don't put a whole lot of effort into supporting this, so you might just have to go the long way 'round if you run into difficulties.

You'll have to trick the configure script into believing that libgcc.a has been previously built. You'll also have to build the libraries that libgcc.a needs. The steps are these:

1. Unpack the GCC sources. Call this directory GCCsrcdir.
2. "`mkdir GCCobjdir && cd GCCobjdir && GCCsrcdir/configure --whatever`"
   Configure GCC like you normally would. See the GCC configuration instructions for all the possible values of `--whatever`.
3. "`cd libiberty && make`"
4. "`cd ../gcc; touch libgcc2.ready`"

Now go back to "If you kept your GCCobjdir" and proceed from there.

### Installing the new libgcc.a

The reckless method is

       cd GCCobjdir/gcc
       make install-libgcc

This will copy in the new libgcc.a on top of the old one.

The wiser method is to keep the old one around under a different name, and install the new one under another different name, and then make libgcc.a be a hard or soft link to one of the two real libraries. Or copy one of them by a new name into a directory searched by the linker, and use -l (dash ell) to pick it up before finding the default other library.

If you're really interested in using a particular flag (say, -fhonor-std) under all conditions, then you can edit GCCsrcdir/gcc/cp/decl2.c and change the initialization of the appropriate `flag_` variable to 1. This will turn that flag on by default, which means that libgcc.a, libstdc++.a, libstdc++.so, and everything else you ever do will be built with that feature unless you specifically turn it off.

$Id: gccrebuild.html,v 1.1 2000/04/21 20:33:30 bkoz Exp $