HOWTO: Upgrade GCC

From Sabayon Wiki
Jump to: navigation, search
Stop.png
Portage (emerge) is not the primary package manager for Sabayon, this article is for advanced users only. In other words if this fails for you, its your fault. You have been warned.

Every once in a while a new version of GCC will come out. What is GCC you ask? Well, it's your compiler to build your packages so you can install packages. Feel free to google it for more information.

So let's get start shall we?

    # emerge --sync && layman -S
    # emerge -uav gcc

Pretty simple so far, so that is done, lets do

      # gcc-config -l
      [1] i586-pc-linux-gnu-4.1.2 *
      [2] i586-pc-linux-gnu-4.2.0

You should see some thing like the above hopefully. Now we need to tell our computer to use the new one and update our profile :

    # gcc-config i586-pc-linux-gnu-4.2.0
    # env-update && source /etc/profile

Once again to make sure our changes took

       # gcc-config -l
      [1] i586-pc-linux-gnu-4.1.2
      [2] i586-pc-linux-gnu-4.2.0 *

NOTE: GCC 4.2.0 has a new feature where you can set, in your CFLAGS in /etc/make.conf, "-march=native". This will tell GCC to compile with optimizations for your current CPU type. If you have not already customized your CFLAGS for your CPU as suggested in the Gentoo Safe CFLAGS **Guide you may want to do this now before proceeding. Do not change your CHOST though, as that is an entirely different and dangerous process.

Now comes the fun part. You must rebuild your entire system and world. For this I will do:

    # emerge -e system || until emerge --resume --skipfirst; do emerge --resume --skipfirst; done

and than:

    # emerge -e world || until emerge --resume --skipfirst; do emerge --resume --skipfirst; done

or if want the whole thing at once:

    # emerge -e system || until emerge --resume --skipfirst; do emerge --resume --skipfirst; done && emerge -e world || until emerge --resume --skipfirst; do emerge --resume --skipfirst; done

Yes, that may take a day or two depending on your hardware. Worry about the failed packages afterwards and just work them out as you see fit. Make sure when you are done to run:

    #revdep-rebuild -X

That will fix any broken stuff on your machine, very vital to run.

So the next question will be, do I keep the old version of GCC? That is up to you, but beware that when you run revdep-rebuild it will more than like run through both versions. So if you don't want the long revdep-rebuild times, than uninstall it. If you run into a problem, you can always reinstall it. So you can if you want:

    # emerge -C =sys-devel/gcc-4.1.2

Woot! All done and you should be world updated now with your new GCC. Piece of Cake!

    • Do note that you will want to recompile your kernel with the new gcc also** You don't have to change any thing in the kernel, just recompile it.