This is somewhat gentoo-specific, so I'll explain it in that context, then try to abstract it to a generic linux machine.

I accidently set my CHOST to "i686-pc-linux-gnu" in the beginning, not paying attention, when my machine is a Athlon64. I would like to change it to "x86_64-pc-linux-gnu". There is a guide for this. It doesn't work.

The first step is "Recompile binutils, then recompile gcc"

Here's the problem illustrated:

  1. Compile binutils using gcc - this succeeds producing new as, ar, and the like files
  2. This breaks gcc. gcc is now trying to use the new /usr/bin/as - but it can't work with them
  3. Since gcc can't compile anything, I can't compile gcc. I have to revert as, ar, etc; then revert the CHOST change, and recompile binutils.

So I tried the following:

  1. back up as, ar, etc
  2. Compile binutils, rendering gcc inoperabe
  3. link ar, as, etc to the old versions I backed up
  4. try to compile gcc

The gcc compile fails with:

/usr/x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/lib/libc.so when searching for -lc
/usr/x86_64-pc-linux-gnu/bin/ld: skipping incompatible /usr/lib/libc.a when searching for -lc
/usr/x86_64-pc-linux-gnu/bin/ld: cannot find -lc
collect2: ld returned 1 exit status

This is a glibc error (completing the chain).

So it seems:

  1. for gcc to compile it has a dependency on the new version glibc
  2. for gcc to run, binutils must be the older version

The steps I haven't tried, because it's so complicated I wanted to get opinions first, are:

  1. compile binutils under new architecture,
  2. relink as, ar, etc to old executables
  3. compile new glibc with old-gcc and old-binutils
  4. compile new-gcc with old-gcc and old-binutils but new-glibc
  5. relink as, ars, etc to new-binutils
  6. recompile everything like a boss

Is there any chance of #4 above working? Do I have any hope of accomplishing this without a complete reinstall?

  • seriously your best bet is to unpack a 64-bit tarball and start building. Doing this requires extreme knowledge of the system. I can't recall if I did this successfully or gave up. All I know is it's not worth the time even if you can. Commented Sep 2, 2010 at 22:06

3 Answers 3


As far as I know it is not possible. Please remember that toolchain does not exist in vaccum and is interlinked.

What might work is to build cross-compiler of new infrastructure but I really doubt it - the "atomicity" on update of glibc will break everything.

I would advice backup & reinstall of system.

  • IIRC it is possible... but damn near impossible to get right. I think I tried it once, I don't recall if I could. +1 for advice or 'reinstall' Commented Sep 2, 2010 at 22:04
  • @xenoterracide: IIRC the official FAQ/Handbook/something like that said it is not possible. Probably it is possible but it is not streightforward. It is much quicker to just reinstall the system. Commented Sep 3, 2010 at 18:05

Have you tried downloading the amd64 stage3 tarball and using the copy of gcc with that?

  • It would not work IMHO as it would require 64-bits glibc. But then patch wouldn't work which is required to build practically anything. And m4, make, sed, binutils and rest of system set. Commented Sep 3, 2010 at 18:01
  • Sorry, the stage3 also includes a libc. The most foolproof way would be to go the stage3 way. But keep in mind that this is expert stuff that the gentoo project does not officially support. It is way too easy to get wrong and to be left with the pieces. But technically it is possible. Commented May 27, 2011 at 15:56

If your kernel is 64-bit (and so you can run 64-bit binaries), you can start a new x86_64 Gentoo install in a chroot, following the usual instructions. I've done similar before — effectively a reinstall, but while still running the old system. If you don't have a spare block device to install to, you can use a subdirectory and either boot with init=chroot\040/new\040/bin/sinit or drop down to a minimal environment to shuffle directories around.

If your kernel is 32-bit, find a 64-bit kernel or build a cross-compiler to 64-bit to build a 64-bit kernel, boot it, then see above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .