Why should you upgrade? Well, GCC is quite similar to any other package on your system, just a bit more critical. You should upgrade GCC whenever a new version fixes some bug that annoys you, new functionality you need is introduced, or if you want to keep your system up-to-date. If none of the previous cases apply to you, you can safely postpone upgrade as long as your GCC version is supported by Gentoo developers.
If you install a newer version of GCC, the system will not switch over to use it automatically. You'll have to explicitly request the change because the migration process might require some additional steps. If you decide not to switch, Portage will continue to use older version of your compiler until you change your mind, or remove the old compiler from the system.
This guide will document the necessary steps required to perform a seamless
upgrade of the compiler used by your Gentoo box. A specific section is
dedicated to the
Generally speaking, upgrades to
When we spoke about the need to switch your compiler to the newer version by hand, we said it won't happen automatically. However, there is one exception -- upgrades to bug fix releases, like from 3.3.5 to 3.3.6 in case you don't use the "multislot" feature allowing them to coexist on one system. Multislot is disabled by default as the majority of users won't benefit from it.
# emerge -uav gcc(Please substitute "i686-pc-linux-gnu-4.1.1" with the GCC version and CHOST settings you've upgraded to:) # gcc-config i686-pc-linux-gnu-4.1.1 # source /etc/profileIf you upgraded from gcc 3 to 4 (e.g. from 3.4.6 to 4.1.1 in this example) you will have to run fix_libtool_files.sh manually # fix_libtool_files.sh 3.4.6(Rebuilding libtool) # emerge --oneshot -av libtool
To be completely safe that the system is in a sane state, it is necessary to rebuild toolchain and then world to make use of the new compiler.
# emerge -eav system # emerge -eav world
It is safe to remove the older GCC version at this time. If you feel the need,
please issue the following command (as usual, substitute
# emerge -aC =sys-devel/gcc-3.4*
The upgrade from GCC-3.3 to 3.4 or greater is not seamless as the C++ ABI
changed between these two versions. There is an issue with the
If you upgrade from gcc 3.3 to 3.4, you have two possibilities on how to
upgrade your system. The
If you upgrade from gcc 3.3 to 4.1, do not use the method based on
revdep-rebuild, but do a
This method requires that you first install
# emerge -an gentoolkit # emerge -uav gcc(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC version and CHOST settings you've upgraded to:) # gcc-config i686-pc-linux-gnu-3.4.5 # source /etc/profile(Rebuilding libtool) # emerge --oneshot -av libtool
Now, we want to see which packages that revdep-rebuild will want to rebuild. Then we will tell revdep-rebuild to actually rebuild the packages. This may take some time, so have some patience.
# revdep-rebuild --library libstdc++.so.5 -- -p -v # revdep-rebuild --library libstdc++.so.5
To provide compatibility with older binary C++ applications and any packages
that revdep-rebuild might have missed,
# emerge --oneshot sys-libs/libstdc++-v3 # emerge -aC =sys-devel/gcc-3.3*
This method, while much slower, will rebuild your whole system to ensure that everything has been rebuilt with your new compiler, and therefore safer. At first, you will upgrade GCC and libtool and switch to your new compiler.
# emerge -uav gcc(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC version and CHOST settings you've upgraded to:) # gcc-config i686-pc-linux-gnu-3.4.5 # source /etc/profileIf you upgraded from gcc 3 to 4 (e.g. from 3.3.6 to 4.1.1 in this example) you will have to run fix_libtool_files.sh manually # fix_libtool_files.sh 3.3.6(Rebuilding libtool) # emerge --oneshot -av libtool
To provide compatibility with older binary C++ applications,
# emerge --oneshot sys-libs/libstdc++-v3
Now we will go about first rebuilding the system target, then the world target. This will take a very long time, depending on the number of packages that you have installed, as it will rebuild your entire toolchain and supporting system files, followed by every package on your system, including the toolchain. This is necessary to ensure that all packages have been compiled with the new toolchain, including the toolchain itself.
# emerge -e system # emerge -e world
It is also safe to remove older GCC versions at this time:
# emerge -aC =sys-devel/gcc-3.3*
A GCC upgrade on a system after installation from a stage3 tarball is a simple
affair. One advantage users of new installations have is they do not have a
plethora of software installed that links against the older version of GCC.
The following example is for a GCC-3.3 to 3.4 or greater upgrade. Certain parts
will be different if upgrading from other versions of GCC. For example, the
library names used for
If a user has not made any customizations to their system yet, then there are
very few steps to get their system upgraded to a new GCC version. As with the
GCC-3.3 to 3.4 upgrade, the user has a couple options. However, unlike the
GCC-3.3 to 3.4 upgrade, this one is less complicated as there are fewer
differences between the methods. The
These first steps are common between both methods, and should be completed by everyone.
# emerge -uav gcc(Please substitute "i686-pc-linux-gnu-3.4.5" with the GCC version and CHOST settings you've upgraded to:) # gcc-config i686-pc-linux-gnu-3.4.5 # source /etc/profile(Rebuilding libtool) # emerge --oneshot -av libtool
To provide compatibility with older binary C++ applications,
# emerge --oneshot sys-libs/libstdc++-v3
This method requires that you first install
# emerge -an gentoolkit # revdep-rebuild --library libstdc++.so.5 -- -p -v # revdep-rebuild --library libstdc++.so.5
This method, while much slower, will rebuild the system target to ensure that everything has been rebuilt with your new compiler. This is not necessary, but is valid if you are also making changes to CFLAGS or other make.conf variables that will affect the system compile.
Since we are performing these actions after an initial installation, we do not
need to recompile the
# emerge -e system
It is also safe to remove older GCC versions at this time. Please substitute
# emerge -aC "<sys-devel/gcc-YOUR-NEW-GCC-VERSION"
It's important to disable
Always use same GCC version for your kernel and additional kernel modules. Once
you rebuild your world with new GCC, external modules (like
If you're upgrading on a SPARC machine, make sure to rerun
If your system complains about something like
If you see the
If a package fails during
If you get an error message
# gcc-config 1 # source /etc/profile # unset GCC_SPECS # emerge -uav gcc