Boring background details:
I was trying to update GCC 4.8.3 -> 4.8.4 on one machine using `cave resolve -1x gcc`.
It gets all the way to the end, then fails halfway through unmerging the old version (as it has been doing for weeks now - who's supposed to be QA'ing this?)
Usually I clean up the wreckage by doing `gcc-config -l 2; source /etc/profile; cave resolve -1x gcc` and waiting for it all over again, but today I tried to be clever. So I ran `cave resolve -1x gcc --skip-until-phase src_install`.
Oh wait, that was wrong, let's try again with `--skip-until-phase merge`... Whoops, too late.
The first command dutifully cleaned up the build dir and exited, and the second one did exactly as it was instructed and skipped the compile, merged all 0 files it found, and removed the old gcc entirely.

======

So, I have a borked machine with no GCC and no libstdc++.so.6.

I do have another machine and plenty of options, so I did this:

Code:

mkdir /mnt/remote
sshfs root@$remote_machine:/ /mnt/remote
# I tried NFS first here but mount.nfs kept hanging; sshfs will work just as well though.

DISTDIR=$local_distdir emerge --fetchonly gcc
# I'm not sure what's going on here, but portage gets horribly confused when $ROOT is used and it tries to download files.
# Making sure both sides have all the distfiles beforehand fixed it.

DISTDIR=$local_distdir ROOT=/mnt/remote CFLAGS="-O2 -pipe -march=$remote_cpu" emerge -av gcc
# I used -march=btver1 from a -march=amdfam10 host here without problems, it should be safe as long as $(uname -m) is the same.

I should've been more specific: once things seem to work, rebuild the affected packages properly!

I didn't do that, and went off to update @world, then started getting a few "weird" segfaults in C++ binaries. An emerge -e on their owning packages straightened that all out, but it burned a few hours of CPU time.

Well in any case this could've gone worse; I got to test my backup plans if nothing else

interestingly i had the same problem with unmerge of gcc, i thought it was power failure.

in my case i just switched gcc with gcc-config and assumed that old version was uninstalled already. That was enough to restore libstdc++ and get things running._________________~amd64
shrink your /usr/portage with squashfs+aufs