What is this GCC error on Linux, and how do I solve it? gcc: internal compiler error: Illegal instruction (program as)

后端 未结 5 629
春和景丽
春和景丽 2021-01-18 10:41

I type gcc hello.c and this appears:

gcc: internal compiler error: Illegal instruction (program as)
Please submit a full bug report,
with preproc         


        
相关标签:
5条回答
  • 2021-01-18 11:16

    Try updating the compiler and try

    sudo apt-get install build-essential
    

    That might solve the problem.

    0 讨论(0)
  • 2021-01-18 11:20

    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.

    0 讨论(0)
  • 2021-01-18 11:27

    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.)

    0 讨论(0)
  • 2021-01-18 11:27

    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:

    1. Does gcc -S hello.c work ? That should create a "hello.s" containing the C code compiled to assembler
    2. You might try with gcc -v -c hello.c to find out what happens exactly.
    0 讨论(0)
  • 2021-01-18 11:31

    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.

    0 讨论(0)
提交回复
热议问题