I type gcc hello.c
and this appears:
gcc: internal compiler error: Illegal instruction (program as)
Please submit a full bug report,
with preproc
Try updating the compiler and try
sudo apt-get install build-essential
That might solve the problem.
Found on raspberryPi forums:
Grabbed the sources and tried a cross-compile on an x86-64 box for a generic arm target. Something inside filter/hq2x.cpp is causing GCC to go nuts and consume memory & swap, so I wouldn't be at all surprised if it triggers a fatal error on a Pi. Some sources suggest that it is the compiler's (cc1plus) internal stack overflowing.
One possible fix is to run the configure script with --enable-debug - This should reduce optimization to a minimum and avoid stack overflows at the expense of increased binary size.
So you can try to set compiler flags to
-O0 -g
and check whether it helps.
Got it! I uninstalled gcc, installed gcc-4.7, and ... nothing.
I cleared out the end of gcc-4.6 and re-ran sudo apt-get install gcc-4.7
and ... nothing.
I updated binutils and ... it worked!
So, as
didn't appear to be affected by updating GCC, but updating it more directly did it for me.
(It was from 2.22-7.1 to 2.22-8, if that helps anyone.)
I can only shed some light on the error message:
gcc: internal compiler error: Illegal instruction (program as)
gcc does several things when compiling. It first translates your C program into assembler and then converts the assembler into machine code.
The name of the assembler program with gcc is just as
. So the error message tells you, that running the assembler fails, because the assembler executable contains an illegal instruction.
This might really be an hardware error, meaning that the executable of the assembler is broken.
To check:
gcc -S hello.c
work ? That should create a "hello.s" containing the C code compiled to assemblergcc -v -c hello.c
to find out what happens exactly. Got similar problem.
But it happened after move of VirtualBox image (with Xubuntu 16.04/gcc-5) from Haswell based machine to Sandy Bridge. Problem was somewhere in build-essential / gcc / binutils packages. I reinstalled all of them (with apt remove and apt install - no oneshot reinstall) - it helped.