Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc
Wikipedia has an article on:
GNU Compiler Collection
This page is a candidate for deletion 
Reason given: Obsolete. Migration is covered by official documentation.
If you disagree with its deletion, please explain why on its discussion page.
If you intend to fix it, please remove this notice, but do not remove this notice from articles that you have created yourself.
Make sure no other pages link here and check the page's history before deleting.


Obsolete Howto?

GCC4 has just been unmasked. Probably most of this guide is obsolete. Now the normal GCC upgrade instructions apply, these can be found at also a quick reference can be found at

New Gentoo (2006.1) installations will use GCC 4.1.1 by default.


GCC is a key development tool, and on a distribution such as gentoo, which compiles everything natively, a key part of user's systems. For this reason, gcc-4, while reaching the esteemed status of "default compiler" on many other distributions, is still left behind on gentoo. This is about to change.

Thanks to the work of multiple gentoo developers, along with the recent release of glibc 2.3.6, gcc4 is just about ready to be unmasked. This howto details the process of upgrading to it.

GCC4 is hoped to hit ~x86, ~amd64, and ~ppc within the next few weeks, so upgrading is going to become easier, for now we need to use a few hoops.


Warning: You must be using an up to date ~ARCH system, gcc4 related fixes have not made it to stable

First, if necessary, create the /etc/portage directory, where profile overrides can be placed.

# mkdir /etc/portage

Now, some nasty style hacks to get ebuilds no one wants you to use.:

You can choose between gcc-4.1.0 or 4.0.3. This example is for gcc-4.1.0


# echo "~sys-devel/gcc-4.1.0 -*" >> /etc/portage/package.keywords

Recent versions of glibc are now in ~arch. You can choose betweend 2.4 or 2.3.6. This examaple uses glibc-2-3.6


# echo "~sys-libs/glibc-2.3.6-r3 ~x86" >> /etc/portage/package.keywords
Warning: If you were using a snapshot of glibc, see gentoo bug 112082
Warning: Updating to GLIB-2.4 can corrupt your gentoo installation, see gentoo bug 125909

To not run into any of those problems

  1. update to glibc-2.3.6
  2. emerge gcc-4.1.0
  3. emerge -e system # until glibc is installed
  4. qlist -o $(qlist -ICv) | scanelf -Bs__guard -qf - -F%F#s | xargs qfile
  5. fix any problems
  6. continue

qlist is part of portage-utils

Alrighty, now we are ready for the real fun..

# emerge sys-devel/binutils sys-libs/glibc sys-devel/gcc -av

Make sure the correct versions are showing.. Now take a nap. When you awake, set your gcc-config profile

# gcc-config -l

find the right one

# gcc-config blah


# gcc-config i686-pc-linux-gnu-4.1.0

Huzzah! now lets rebuild the rest of the system!

# emerge -e system && emerge -e world

Good luck, and happy compiling!

Note that emerging the entire system can take days. Remember emerge --resume will pick up where it left off if you need to fix something.

[Update: 01 Jan 2006] Packages still not ~x86 so above still necessary. Will report back status when system rebuilt (there are over 800 packages on this laptop).

[Update: 11 Jan 2006] Took me around 3 days (and several emerge --resume --skipfirst) to rebuild system. Still fixing some broken packages. If you are not familiar with revdep-rebuild and fixing things then don't do this. Overall my system is running fine (KDE 3.5 and OO 2 are OK apart from anything else). As per next comment, broken things are mainly media stuff, so if that is really important to you then I suggest you wait.

[Comment ( 08 Jan 2006] I just finished updating my system according to this howto. It took me nearly 3 days to compile my >850 packages with GCC-4.02. Now the system is running stable again.

After the first shot, a couple of packages were broken. Most of them were media based packages. After some research in the forums, I could fix most of the errors and merge those packages to my system. At last only 3 packages remained, which could only be merged by falling back to GCC-3.4.5. These packages are:

All of the rest compiled with GCC-4. I consider this as success.

nowinter added -------------

My own expirience of "must-fall-back" packages, all of media-sound" category:

rezound, spiralmodular, dino, ggseq, linuxsampler, ethercap, djplay.

As of July 2006, no available version of those would compile with gcc-4.1, no matter how safe the compilation flags are.

20.03.2006 I had problems with gcc 4.1 gcc did not compiled from livecd installer 2006.0 install giving me an error on fixincludes. I switched back to the gcc 4.0.2-r3 Now I am waiting for compile to finish succesfully. I have AMD AthlonXP 1700 box (nforce2) with onboard graphics. Also gcc 3.4.5 does not compile with 3.4.4 which comes with livecd installer.

04.06.2006 (Comment by spmsrh _AT_ gmail ) Do not add -fPIC to your CFLAGS as this ensures that glibc does not compile at all for any other comibation of CFLAGs compiler etc.

20.08.2006 I had compile errors for a few kde packages (e.g. kmail) after upgrading to GCC 4.1.1 (undefined reference to __cxa_get_exception_ptr@CXXABI_1.3.1) To fix this issue, execute <oldversion_of_gcc>

13.08.2007 Several compile errors (jade: /usr/lib/gcc/i686-pc-linux-gnu/3.4.6/ version `CXXABI_1.3.1' not found (required by /usr/lib/ ) where solved by emerging eselect-compiler, eselect compiler list and eselect compiler set [number for the current gcc] to switch the compiler. Obviously gcc-config didn't do all the work needed.

External Links

Retrieved from ""

Last modified: Fri, 08 Aug 2008 02:51:00 +0000 Hits: 28,312