Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 863392

Summary: sys-devel/gcc: cross-avr/gcc-12.1.0 incorrectly reports illegal opcode "asr" instead of "jmp" on non-supporting architectures
Product: Gentoo Linux Reporter: Vince C. <vincent.cadet>
Component: Current packagesAssignee: Gentoo Toolchain Maintainers <toolchain>
Status: UNCONFIRMED ---    
Severity: normal CC: embedded
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Vince C. 2022-08-03 14:57:35 UTC
Running the following command line

    echo -e "#include <avr/io.h>\nvoid main() { __asm__ (\".L%=: jmp .L%=\" :: ); }" | \
    avr-gcc -x c -mmcu=attiny2313 -pipe -Os -o bugtest.elf -

fails with the following, misleading error message:

    {standard input}:17: Error: illegal opcode asr for mcu avr25

The correct error message should be:

    {standard input}:17: Error: illegal opcode jmp for mcu avr25

The compiler version in question is avr-gcc-12.1.0:

~$ avr-gcc --version
avr-gcc (GCC) 12.1.0
Copyright (C) 2022 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.

The instruction "jmp" is indeed unsupported on avr25, such as ATtiny2313, for instance. I hit that bug trying to debug my code and spent hours figuring out where I could have used the "ASR" instruction ("Arithmetic Shift Right" on the AVR platform). Turned out I didn't and it's only by tediously narrowing down the instruction using dichotomy reduction across hundreds of lines that I finally isolated the JMP instruction, which I had completely forgotten I had used...

Fixing this bug may save several hours of vain searches, IMHO.
Comment 1 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2022-08-04 02:18:39 UTC
Thanks for the report. This sounds like a bug in GCC itself. Could you report it on their Bugzilla at https://gcc.gnu.org/bugzilla and link it here?

It would be worth trying 12.1.1_p20220730 too.
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2023-02-09 01:17:29 UTC
ping. Did you have a chance to report it upstream?