Can’t find a register in class GENERAL_REGS when reloading ‘asm’

I was getting this error when trying to build a lot of the DVD ripping and transcoding software I was trying to use.  Could not find any real resolution to the problem anywhere.  Tonight I got the same error compiling MythTV, so I figured I’d have to try and work it out — and a quick Google helped me figure it out.

This message from GCC is basically trying to tell me that it has run out of registers to use for the machine code it is trying to make.  Basically, the code is too complex for the compiler to build valid machine code using the compilation flags as set.  Adding -fomit-frame-pointer is supposed to help, as it frees up one register (I already had that set, though).  -fPIC can apparently also free a register, but a lot of code needs it to compile…  In my case, I had no optimisation flag set, so simply adding -O2 to my CFLAGS in make.conf has fixed it for me (and will give me optimised code that I never had before…  can’t believe I never had -O enabled…  maybe now is the time to rebuild X and KDE… 🙂

I read someplace that the -O options simply enable a bunch of -f and other flags that you could set individually by hand if you were anal enough.  So my problem was not necessarily solved by -O2, just by one of the hidden compile flags that -O2 turned on for me.

Oh, and GCC 3.4 is supposed to free more registers as well, so perhaps for some really complex code the only fix might be to switch up to GCC 3.4.

Leave a comment