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:
- Compile binutils using gcc - this succeeds producing new as, ar, and the like files
- This breaks gcc. gcc is now trying to use the new /usr/bin/as - but it can't work with them
- 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:
- back up as, ar, etc
- Compile binutils, rendering gcc inoperabe
- link ar, as, etc to the old versions I backed up
- 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:
- for gcc to compile it has a dependency on the new version glibc
- 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:
- compile binutils under new architecture,
- relink as, ar, etc to old executables
- compile new glibc with old-gcc and old-binutils
- compile new-gcc with old-gcc and old-binutils but new-glibc
- relink as, ars, etc to new-binutils
- 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?