Bug 59396 - [avr] Wrong warning with ISR() and -flto
Summary: [avr] Wrong warning with ISR() and -flto
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.8.2
: P5 minor
Target Milestone: 4.8.3
Assignee: Georg-Johann Lay
URL:
Keywords: diagnostic, patch
Depends on:
Blocks:
 
Reported: 2013-12-05 14:32 UTC by Georg-Johann Lay
Modified: 2021-07-05 08:39 UTC (History)
1 user (show)

See Also:
Host:
Target: avr
Build:
Known to work: 4.8.1, 4.8.3
Known to fail: 4.8.2
Last reconfirmed: 2013-12-05 00:00:00


Attachments
isr.c: The C source (180 bytes, text/plain)
2013-12-05 14:32 UTC, Georg-Johann Lay
Details
pr59396.diff: Tentative patch for avr.c (303 bytes, patch)
2014-01-20 11:45 UTC, Georg-Johann Lay
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Georg-Johann Lay 2013-12-05 14:32:47 UTC
Created attachment 31387 [details]
isr.c: The C source

Following source will throw a warning if compiled, e.g., 

$ avr-gcc isr.c -mmcu=atmega8 -flto


#define __INTR_ATTRS used, externally_visible

#define ISR(vector,...)                                                 \
    void vector (void) __attribute__ ((signal,__INTR_ATTRS)) __VA_ARGS__; \
    void vector (void)

#define ADC_vect __vector_14


ISR (ADC_vect)
{
}

int main()
{
    return 0;
}


The defines are copy-pased from AVR-Libc and are the most common way to define interrupt service routines: Use ISR() with a isr vector name.

The warning is:

In function '__vector_14':
isr.c:10:1: warning: '_vector_14' appears to be a misspelled signal handler [enabled by default]
 ISR (ADC_vect)
 ^
Comment 1 Georg-Johann Lay 2014-01-20 11:45:38 UTC
Created attachment 31898 [details]
pr59396.diff: Tentative patch for avr.c

	PR target/59396
	* config/avr/avr.c (avr_set_current_function): If the first char
	of the function name is skipped, make sure it is actually '*'.
Comment 2 Georg-Johann Lay 2014-01-20 11:49:45 UTC
http://gcc.gnu.org/ml/gcc-patches/2013-12/msg00529.html

Issue will occur since r200901 (trunk), r200902 (4.8.2) , r200903 (4.7.4).
Comment 3 Martin Nowak 2014-01-20 13:08:30 UTC
Is there a simple workaround until this is fixed?
Comment 4 Georg-Johann Lay 2014-01-20 16:07:26 UTC
(In reply to Martin Nowak from comment #3)
> Is there a simple workaround until this is fixed?

None that I know of, at least if you don't want to change the sources.

As the patch above has not been approved, it's unlikely this will ever get fixed...
Comment 5 Martin Nowak 2014-01-20 17:45:02 UTC
(In reply to Georg-Johann Lay from comment #4)
> As the patch above has not been approved, it's unlikely this will ever get
> fixed...

This should have a high priority, it makes LTO completely unusable on AVR.
Comment 6 Pieter Agten 2014-01-20 18:42:39 UTC
(In reply to Martin Nowak from comment #5)
> (In reply to Georg-Johann Lay from comment #4)
> > As the patch above has not been approved, it's unlikely this will ever get
> > fixed...
> 
> This should have a high priority, it makes LTO completely unusable on AVR.

Isn't it just a warning?
Comment 7 Ian Thompson 2014-01-20 18:55:02 UTC
(In reply to Martin Nowak from comment #5)
> This should have a high priority, it makes LTO completely unusable on AVR.

I've been building with LTO for AVR without issue. The warning is purely cosmetic.

If you're worried about not being able to build with -Werror (since this can't be suppressed), you could split your compile and link steps into separate commands:
$ avr-gcc -Wall -Werror -mmcu=atmega8 -flto -c isr.c -o isr.o                                  
$ avr-gcc -mmcu=atmega8 -flto isr.o -o isr   
In function '__vector_14':
isr.c:10:1: warning: '_vector_14' appears to be a misspelled signal handler [enabled by default]
 ISR (ADC_vect)
 ^

You could even do something fancy by piping the linker output to sed/grep/awk to filter out the bogus warning.

Not sure if this is relevant, but the warning only comes up during linking, while any actually misspelled handlers will come up during compile. To show this even better, misspell ADC_vect in the initial example. You actually get the warning twice:
isr.c: In function 'AD_vect':
isr.c:10:6: warning: 'AD_vect' appears to be a misspelled signal handler [enabled by default]
 ISR (AD_vect)
      ^
isr.c:5:10: note: in definition of macro 'ISR'
     void vector (void)
          ^
In function 'AD_vect':
isr.c:10:1: warning: 'D_vect' appears to be a misspelled signal handler [enabled by default]
 ISR (AD_vect)
 ^
Comment 8 Georg-Johann Lay 2014-01-21 10:26:00 UTC
(In reply to Martin Nowak from comment #5)
> (In reply to Georg-Johann Lay from comment #4)
> > As the patch above has not been approved, it's unlikely this will ever get
> > fixed...
> 
> This should have a high priority, it makes LTO completely unusable on AVR.

avr itself is an architecture that hat not a high priority in the GCC project, thus all avr issues are P4 or P5.

And this is just a warning that occurs during the LTO run.  Try to add -w to the lto1 run, i.e. to your link step.
Comment 9 Georg-Johann Lay 2014-03-14 09:27:51 UTC
Author: gjl
Date: Fri Mar 14 09:27:19 2014
New Revision: 208562

URL: http://gcc.gnu.org/viewcvs?rev=208562&root=gcc&view=rev
Log:
	PR target/59396
	* config/avr/avr.c (avr_set_current_function): Pass function name
	through default_strip_name_encoding before sanity checking instead
	of skipping the first char of the assembler name.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/avr/avr.c
Comment 10 Georg-Johann Lay 2014-03-14 09:42:22 UTC
Author: gjl
Date: Fri Mar 14 09:41:51 2014
New Revision: 208564

URL: http://gcc.gnu.org/viewcvs?rev=208564&root=gcc&view=rev
Log:
	Backport from 2014-03-14 trunk r208562.
	PR target/59396
	* config/avr/avr.c (avr_set_current_function): Pass function name
	through default_strip_name_encoding before sanity checking instead
	of skipping the first char of the assembler name.


Modified:
    branches/gcc-4_8-branch/gcc/ChangeLog
    branches/gcc-4_8-branch/gcc/config/avr/avr.c
Comment 11 Georg-Johann Lay 2014-03-14 09:52:39 UTC
Author: gjl
Date: Fri Mar 14 09:52:07 2014
New Revision: 208565

URL: http://gcc.gnu.org/viewcvs?rev=208565&root=gcc&view=rev
Log:
	Backport from 2014-03-14 trunk r208562.
	PR target/59396
	* config/avr/avr.c (avr_set_current_function): Pass function name
	through default_strip_name_encoding before sanity checking instead
	of skipping the first char of the assembler name.


Modified:
    branches/gcc-4_7-branch/gcc/ChangeLog
    branches/gcc-4_7-branch/gcc/config/avr/avr.c
Comment 12 Georg-Johann Lay 2014-03-14 10:07:27 UTC
Fixed in 4.8.3.