'Fatal error in avr-gcc, specifies incorrect MCU

I am learning to program my ATtiny85 without a bootloader using a MiniPro, and I want to generate a hex file. First I try to compile my file using the avr-gcc command, but I get an error that states:

Fatal error: unknown MCU: gcc-isr

This is the command I use to compile my file

avr-gcc -Wall -mmcu=avr25 -Os -DF_CPU=8000000 -c main.c -o main.o

And this is the code I'm trying to compile

#define __AVR_ATtiny85__
#include <avr/io.h>
#include <util/delay.h>

int main(void)
{
    DDRB = 0b00001000;
    while (1)
    {
        PORTB = 0b00001000;
        _delay_ms(20);
        PORTB = 0b00000000;
        _delay_ms(20);

        PORTB = 0b00001000;
        _delay_ms(200);
        PORTB = 0b00000000;
        _delay_ms(200);
    }

    return 1;
}

I am not entirely sure what the error means and why it appears in the first place, since my mcu is explicitly specified as avr25 category, which the attiny85 falls into. The same error is produced if I set the mmcu variable to attiny85 explicitly

Output of avr-gcc --version

% avr-gcc --version
avr-gcc (GCC) 11.2.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I also installed the latest binutils-avr and avr-libc packages from AUR (2.20 and 2.1.0 respectively)



Solution 1:[1]

Fatal error: unknown MCU: gcc-isr

This indicates that you are using an outdated Binutils (as) and that the compiler was configured against a Binutils version that is newer than the Binutils you are actually using.

Since v8, avr-gcc supports option -mgas-isr-prologues, and it will activate the respective part of the assembler by calling it with option -mgcc-isr. The feature was introduced with Binutils v2.29.

You can

  • Re-configure and build avr-gcc against the Binutils version you are preferring to use. The configure script does check whether Binutils support -mgcc-isr; and if that is not the case, the respective GCC feature will be disabled.

  • Use avr-gcc with disabled optimization feature PR20296 / PR21683, i.e. compile with -mno-gas-isr-prologues.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1