On 2019-03-27 10:51 -0500, Bruce Dubbs via blfs-dev wrote:
> On 3/27/19 4:13 AM, Pierre Labastie via blfs-dev wrote:
> 
> > Note that for mesa -Db_ndebug=true can be used to disable assertions (the
> > default is "if_release"). Then "-O2 -g" is still passed. You can also pass
> > -Db_nebug=false with -Dbuildtype=release, of course...
> > 
> > BTW, using gdb with "-O2 -g" does not work well for me (I'm not a great user
> > of gdb, so I might miss some option there): stepping gets confused if some
> > part of the code gets optimized out, or reordered for optimization.

Yes.  I usually use "-O0 -g" for debug build.  If I want to view the assembly
code I use "-O1" since it makes the generated assembly simpler.

> If a package works or is debugged with  with -O0 and fails with -O2 or 
> -O3, then it is a compiler problem and VERY difficult to find/fix.  It 
> is not really up to us to try to find a workaround for something lake 
> that.  Fortunately it does not come up very often and is an argument to 
> not try to optimize to a greater extent than the upstream developers.

That may not be a compiler problem since C/C++ has undefined behavior.  

Nowadays most upstream developers use "-O2", some of them use "-O3".  And,
increasing "-O2" to "-O3" rarely causes severe bugs but may actually _decrease_
performance in some cases.

(Most of severe bugs arises when the developer tries to use "-O" or "-O2"
instead of "-O0".)

I once tried to build all LFS packages and many BLFS packages with "-O3 -g
-march=native -pipe".  It works well on x86_64.  But for x86 I also need "-
mfpmath=sse -mstackrealign" to fix a lot math failures (x87 precision problems)
in Glibc.

Gentoo and Arch guys also believe "-Ox" (except "-Ofast") and "-march=native"
are safe (though they don't always improve performance).
-- 
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University

-- 
http://lists.linuxfromscratch.org/listinfo/blfs-dev
FAQ: http://www.linuxfromscratch.org/blfs/faq.html
Unsubscribe: See the above information page

Reply via email to