50% of packets lost only on local interfaces

Jon Noack noackjr at alumni.rice.edu
Mon Feb 7 15:05:44 PST 2005


José M. Fandiño wrote:
> Jon Noack wrote:
> >>>> Finally, I found the culprit:
>>>>> 
>>>>> CFLAGS=""     \  100% of the transmited traffic is received
>>>>> COPTFLAGS=""  /
>>>>> 
>>>>> CFLAGS= -pipe     \  50% of the transmited traffic is received
>>>>> COPTFLAGS= -pipe  /
>>>> 
> >>> That would be exceedingly strange, because the above two options
>>>> are supposed to produce *no differences at all* with the code 
>>>> generation.
>>>> 
> >>> I'd believe that -O and no -O could behave differently, although
>>>> I don't know why you'd want to compile without -O.
>>> 
> >> because by the time I was compiling the system I was no interested
>>> in compiler optimizations. Now I prefer a lightly optimized
>>> kernel than a system with 50% of packet lost in local interfaces
>>> ;-)
>> 
> > -O is the default for -STABLE; anything else might very well cause
>> problems. In fact, check out the CFLAGS section of 
>> /usr/share/examples/etc/make.conf:
> > "Note that optimization settings other than -O and -O2 are not
>> recommended or supported for compiling the world or the kernel -
>> please revert any nonstandard optimization settings to "-O" before
>> submitting bug reports without patches to the developers."
> 
> I think this comment was referring to higher optimizations levels 
> than -O2, anyway removing "-O" shouldn't be so harmful.

The explanation I've heard (I have no actual knowledge here, I'm just 
good at repeating others) is that gcc doesn't compile any ASM with -O0 
(which is what you get with CFLAGS="-pipe").  This Breaks Things(tm):
http://docs.freebsd.org/cgi/mid.cgi?20020623214947.J84322

kern/52764 is another example:
http://www.freebsd.org/cgi/query-pr.cgi?pr=kern/52764

More generically it makes sense that gcc treat code differently with -O0 
than with -O.  With the vast majority of users using -O and different 
code paths being taken with -O0, it doesn't surprise me at all that 
there are issues.

It should be assumed that nonstandard means exactly what it says: 
something other than -O (or more recently -O2).  If it breaks, try -O. 
If it's still broken with -O, report away.

Regards,
Jon

P.S. Historically, the reason to use -O0 was for easier debugging.  It 
appears that steps have been taken to ease debugging with -O to the 
point that it is no longer necessary to use -O0 (with the FreeBSD kernel 
and world, at least); I don't recall a FreeBSD developer ever asking 
someone to recompile with -O0 to help solve a problem...


More information about the freebsd-stable mailing list