--enable-libgcc-rebuild

NOTA BENE: If using the --enable-libstdcxx-v3 approach to configuring, the std namespace will be turned on for you, without going this route. Only use this flag if you'd like to experiment with yet more binary incompatibilities, as discussed below.


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.

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.

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 was required for a few busy months of development, but was always acknowledged a kludge. After the library sources were merged into the compiler sources, this was commented out. If you must re-enable it, you amy do so by uncommenting the GLIBCPP_ENABLE_RELIBGCC line in configure.in and regenerating.


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.4 2000/07/07 21:13:27 pme Exp $