Gentoo Wiki


At the moment the latest stable GCC is 3.4.x. Migrating from 3.4 to >4.0 is quite a simple matter. However, if you have 3.3 or lower you should check the official GCC upgrade guide as this is a special case. Below are instructions for upgrading from >=3.4.x
All you need to do is unmask the version you want, if those versions hasen't become stable yet.

# echo "=sys-devel/gcc-4.1.0-r1" >> /etc/portage/package.unmask
# emerge -av gcc
These are the packages that would be merged, in order:
Calculating dependencies... done!
[ebuild   NS   ] sys-devel/gcc-4.1.0-r1  USE="fortran gtk -bootstrap -build -doc -gcj -hardened -ip28 -mudflap -multislot -nls -nocxx -objc -objc++ -objc-gc -vanilla" 37,775 kB 
Total size of downloads: 37,775 kB
Would you like to merge these packages? [Yes/No]

Emerging takes quite a while, so get some coffe or a book. ;-) When the installation is complete you will now have BOTH your older 3.x gcc AND your newer 4.X version. gcc-config -l will confirm this.

shiva letharion # gcc-config -l
[1] i686-pc-linux-gnu-3.4.5 *
[2] i686-pc-linux-gnu-3.4.5-hardened
[3] i686-pc-linux-gnu-3.4.5-hardenednopie
[4] i686-pc-linux-gnu-3.4.5-hardenednopiessp
[5] i686-pc-linux-gnu-3.4.5-hardenednossp
[6] i686-pc-linux-gnu-4.1.0 

Swithching is done like this

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

Ofcourse you should substitute i686-pc-linux-gnu-4.1.0 for what's applicable to your system. i686 could be i386 and 4.1.0 could be 4.0.3 for example.

shiva letharion # gcc-config i686-pc-linux-gnu-4.1.0
* Switching native-compiler to i686-pc-linux-gnu-4.1.0 ...                      [ ok ]

If all's well, we are now using the new gcc version \o/
This however will only compile the new packages we install with the new gcc, and if we have the time to do it, we probably want to rebuild out entire system with the new compiler. This could take a few hours on a very small and fast system, but also could take weeks on a slow processor if there are a lot of packages to compile

emerge -e system && emerge -e world

First we reemrege our entire system. This will rebuild the toolchain with the new compiler, and the new compiler with itself. When that's been done, we will have a new and better toolchain, so we now rebuild everything again, with a better toolchain. If everything seems to work out well, later you can remove your old gcc version.

emerge -aC =sys-devel/gcc-3.4
Retrieved from ""

Last modified: Fri, 05 Sep 2008 10:28:00 +0000 Hits: 3,681