浙林龙哥

   :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

HOWTO gcc4

From Gentoo Linux Wiki

This article is part of the HOWTO series.
Installation Methods LiveCDs Kernel & Hardware Portage System-related Networks & Services X Server Software Gaming Other

Reasoning

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.

Preparation

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

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

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 sytem utill 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 binutils glibc 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

eg:

#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 gerdesj@blueloop.net] 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 gerdesj@blueloop.net] 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 (sschober@web.de): 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:

  • media-video/qdvdauthor-0.0.10
  • media-tv/nuppelvideo-0.52a
  • net-mail/cyrus-imap-admin-2.2.12

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

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.

posted on 2006-04-06 22:12  浙林龙哥  阅读(524)  评论(0编辑  收藏  举报