avr-gcc-list
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Link Time Optimization vs __builtin_unreachable() and


From: Weddington, Eric
Subject: Re: [avr-gcc-list] Link Time Optimization vs __builtin_unreachable() and .signature?
Date: Mon, 18 Jun 2012 14:34:44 +0000

Hi Bob,

Thanks for trying out the bleeding edge! :-)

It sounds like you need to file a GCC bug report for the __noreturn__ 
attribute. It shouldn't be giving you a warning.

Can you confirm that it is GCC that is getting rid of .signature? If so, it's a 
GCC bug and another bug report should be filed. If it is not GCC that is 
getting rid of it, but it is the linker that is doing that then it should be a 
GNU Binutils bug report. I don't know if we need to do something with the 
default linker script to tell ld to keep it, or if it is something else that is 
blowing it away.

Eric Weddington

> -----Original Message-----
> From: address@hidden [mailto:avr-
> address@hidden On Behalf Of Bob
> Paddock
> Sent: Monday, June 18, 2012 8:26 AM
> To: AVR-GCC
> Subject: [avr-gcc-list] Link Time Optimization vs __builtin_unreachable() and
> .signature?
> 
> With the release of GCC 4.7.1 I wanted to give Link Time Optimization
> a try.  I'm using this version:
> http://sourceforge.net/projects/mobilechessboar/files/avr-
> gcc%20snapshots%20(Win32)
> 
> Part is Xmega128A1.
> 
> Adding -flto and -flto-report:
> 
> CFLAGS += -flto
> CFLAGS += -flto-report
> 
> LDFLAGS += -flto
> LDFLAGS += -flto-report
> 
> Reduced the project code size by a mind boggling ~52K.  Would be nice,
> alas it is not, traced the problem to this:
> 
> void reset_hardware( void )  __attribute__ ((__noreturn__)); /* Force
> a system reset.  We only return from this function by a hardware reset
> */
> 
> /* Force a Hardware Reset: */
> void reset_hardware( void )
> {
>   CCPWrite( &RST.CTRL, RST_SWRST_bm );
>   __builtin_unreachable();
> }
> 
> With LTO all the code after __builtin_unreachable(); is gone, breaking
> the project.
> 
> Replacing  __builtin_unreachable():
> 
> void reset_hardware( void )
> {
>   CCPWrite( &RST.CTRL, RST_SWRST_bm );
> 
>   for(;;)
>     ;
> }
> 
> then LTO reduces the code by a more realistic 775 bytes.
> 
> A question I have is why do I have to add either
> __builtin_unreachable(); or the empty for(;;) to suppress the
> 'noreturn function does return' warning message, when the function is declare
> __noreturn__?  Seems GCC and I don't agree on the usage of 'noreturn'
> as marking the function that it will indeed never return.
> 
> Also LTO is incompatible with:
> 
> #include <avr/signature.h> /* Place the chip's signature into the .elf
> output file.  Simply including this file does the work.  Must only
> appear in the project *once* */
> 
> %.elf: $(OBJ)
>       $(OBJDUMP) -s -j .signature $(OBJDIR)/$@
> 
> LTO has removed .signature, resulting in avr-objdump giving an error
> about .signature not being found.
> 
> Is there a way to mark .signature as precious at the source level?
> Adding -flto to all source files but one complicates the Makefile.
> 
> _______________________________________________
> AVR-GCC-list mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/avr-gcc-list



reply via email to

[Prev in Thread] Current Thread [Next in Thread]