0

I cleaned up my system 3 weeks ago and made a fatal mistake.
Well, i don't really know why, but i uninstalled sys-devel/binutils.

After i recognized the mistake i tried re-emerge, but it doesn't work.
Next step was, downloading stage3 from Gentoo and copying sys-devel/binutils from there to local tree.
Doesn't work.

After that i went to holidays and came back today, so i'll need to fix this issue, primarily without re-installing whole system.

When i try to emerge something like x11-apps/xinput, i receive the following:

output from emerge:

checking whether the C compiler works... no
configure: error: in `/var/tmp/portage/x11-apps/xinput-1.6.2/work/xinput-1.6.2_build':
configure: error: C compiler cannot create executables

config.log from emerge:

configure:3372: checking whether the C compiler works
configure:3394: x86_64-pc-linux-gnu-gcc -m32 -march=core-avx-i -mtune=core-avx-i -O2 -pipe -Wl,-O1 -Wl,--as-needed conftest.c >&5
x86_64-pc-linux-gnu-gcc: internal compiler error: Illegal instruction (program as)

ldd from /usr/bin/as:

linux-vdso.so.1 (0x00007ffee41b9000)
libopcodes-2.25.1.so => /usr/lib64/binutils/x86_64-pc-linux-gnu/2.25.1/libopcodes-2.25.1.so (0x00007f2045ff8000)
libbfd-2.25.1.so => /usr/lib64/binutils/x86_64-pc-linux-gnu/2.25.1/libbfd-2.25.1.so (0x00007f2045cd3000)
libz.so.1 => /lib64/libz.so.1 (0x00007f2045abd000)
libc.so.6 => /lib64/libc.so.6 (0x00007f2045722000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007f204551e000)
/lib64/ld-linux-x86-64.so.2 (0x00007f204637f000)

using:

  • sys-devel/binutils-2.25.1-r1
  • sys-devel/gcc-4.9.3

Any suggestions to do? Any hints? Any ideas to fix? Let me know!

Colonel Thirty Two
  • 23,953
  • 8
  • 45
  • 85
am1
  • 345
  • 1
  • 2
  • 13
  • 1
    This Q is not about programming as defined for StackOverflow. It may be more appropriate on the related site http://unix.stackexchange.com (Unix-Linux). Consider using the flag link at the bottom of your Q and ask the moderator to move it. Good luck. – shellter Dec 14 '15 at 21:50
  • Caveat: I use fedora not gentoo. But, I found a page in the gentoo wiki that seems to give options for [disaster] recovery: https://wiki.gentoo.org/wiki/Portage It says you boot your livecd to repair portage on your hard drive. Also, a tarball option. Another option is to install binutils and gcc as binary packages from debian. Then, emerge should work and you can then do emerge --sync? – Craig Estey Dec 14 '15 at 21:52
  • Did you try `emerge --pretend -uDN @world`? Update USE flag and remove `--pretend `, execute it again. Be careful with the package.use, if there is, you should update it as well. `emerge --depclean` if unable to execute it. – Tao Wang Dec 15 '15 at 05:04
  • Never try to modify stage tree, get it back to what you originally installed your OS. – Tao Wang Dec 15 '15 at 05:12
  • http://forums.gentoo.org dude. – n. m. could be an AI Dec 17 '15 at 14:37
  • 1
    Solution received at [unix.stackexchange.com](http://unix.stackexchange.com/a/249411/147482) Thanks @shellter – am1 Dec 17 '15 at 18:29

1 Answers1

1

I've been there before and though daunting, this is manageable. Before going any further, your toolchain has to be sane. Going out to other distros for files, going to a Gentoo ISO with outdated toolchain binaries, or doing system updates will put you in an even more unsure state. To correct, you will need:

  1. binutils installed properly.
  2. Gentoo to recognize gcc and its associated libraries properly
  3. Run a test to make sure the compiler works

I'll assume when you downloaded the binutils package you installed it properly. If not, the commands should have been (for version 2.25.1-r1):

cp binutils-2.25.1-r1.tbz2 /usr/portage/distfiles  # assuming you use default location 
chown portage.portage /usr/portage/distfiles/binutils-2.25.1-r1.tbz2
emerge -1 --usepkgonly =binutils-2.25.1-r1    # this will install binutils properly

If this does not work, you could try untarring binutils to the root directory, but that is dangerous and not recommended. If you have to do it, make sure you put the "p" option (save permissions) on the tar command, or you will be worse off then before.

Now that this is installed, it's very likely your GCC profile will no longer be valid, which is usually what "C compiler cannot create executables" means. This all needs to be done in the same terminal for now:

gcc-config -l    # Get a list of available gcc profiles
gcc-config 1     # Replace 1 with whichever gcc version is correct (for 4.9.3)
source /etc/profile

Now, run a test emerge (in the same terminal you sourced the profile):

emerge -1 xinput  # Using your example package

When that works, you should either close all other terminals or source the profile in all of them to make sure you don't have an environment issue in an open session.

gravy21
  • 151
  • 1
  • 3