Gentoo Wiki


This Document explains a handy trick for those experimenting with Alpha releases of GCC, or people whom have legacy code which for whatever reason, they wish to run with the latest GCC but it fails on 1 or 2 files.

This document is admittedly of poor quality, but I'd rather provide the information to give others a starting point and fix the wiki where needed ( its a wiki, that's what its for )

This trick comes without any warranty, but I've used it myself a lot with no ill effects.

Gentoo Standard recommendation is to seemingly rebuild your whole system with the latest GCC whenever it comes out, but I myself have found this un-necessary, and have found it quite easy to have mixed GCC3.4 and GCC4.3 systems with no problem.

In fact, in my experience, one does not even need to compile an entirety of a single binary with a single version of GCC, and you can mix them where needed as needed to get around some occasional shortcomings, and this is what this TIP covers how to do.

The Problem

Say you were compiling your system, all fine and dandy, and you've found a package thats massive, and failed epically near the end of it. Option 1 says you could always revert your systems GCC to an older version, and then re-run.

However, in my experience, doing this often results in the compile not working at all, and there being sporadic problems with CXXABI dependent libraries as part of the run phase ( GCC is really unfriendly about downgrading once you've upgraded. ), and/or programs complaining about not being able to find certain symbols that exist in the new libraries, but not in the current libraries ( because switching GCC version switches the runtime libraries too )

When you FAIL

So, chit chat aside, you've got a failure to compile. ie: sys-apps/somepackage.

And you can see the compile command that failed ( ie: gcc somefile.c )

1. CD into the build Directory

cd /var/tmp/portage/sys-apps/somepackage-1.0/work/somepackage-1.0

2. Import the build environment

source ../../temp/environment

3. Manually Compile Faulty File

PATH=/usr/i686-pc-linux-gnu/gcc-bin/4.2.3:$PATH  gcc somefile.c 

( sometimes you can run make, sometimes you cant, its generally best to compile as little as possible to just jump over one bug )

4. In an alternative shell ( because the one you are now in is tainted with environment variables )

ebuild /usr/portage/sys-apps/somepackage/somepackage-1.0.ebuild compile

and with a bit of luck, the hand compiling of the fault will avoid ebuild attempting to build it again, and it will just keep on trucking. Sometimes multiple iterations of manual compilation of a single file are necessary, to get ebuild to the last phase.

5. When you compilation succeeeds:

ebuild /usr/portage/sys-apps/somepackage/somepackage-1.0.ebuild merge 

to do the rest of the things portage normally does to install/bundle/add to package database/file system etc.

Retrieved from ""

Last modified: Wed, 07 May 2008 23:01:00 +0000 Hits: 59