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

Bug 618300

Summary: kde-frameworks/kjs fails to compile due to using "-Ofast" in CXXFLAGS/CFLAGS
Product: Gentoo Linux Reporter: Matt <matt.palermo>
Component: Current packagesAssignee: Gentoo KDE team <kde>
Status: RESOLVED WONTFIX    
Severity: normal CC: jstein, mjo
Priority: Normal    
Version: unspecified   
Hardware: x86   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Failing Buildlog
proposed ebuild patch

Description Matt 2017-05-12 16:08:14 UTC
Created attachment 472408 [details]
Failing Buildlog

kde-frameworks/kjs fails to compile due to using "-Ofast" in CXXFLAGS/CFLAGS

"KJS does not work correctly with -ffast-math"

The ebuild is very short and basic, so it probably only needs a

src_configure() {
        replace-flags -Ofast -O2
}

stuck at the bottom.  I've only edited a few ebuilds, so I could very well be wrong that it's "that simple".  I'll attach a "patch" for the ebuild anyway, though.


THANK YOU!

M.
Comment 1 Matt 2017-05-12 16:08:50 UTC
Created attachment 472410 [details, diff]
proposed ebuild patch
Comment 2 Michael Orlitzky gentoo-dev 2017-05-13 22:48:52 UTC
I can't speak for the maintainer of this, but a *lot* of stuff is broken with -ffast-math, and therefore with -Ofast. Its description is...

  -Ofast

    Disregard strict standards compliance. -Ofast enables all -O3
    optimizations. It also enables optimizations that are not valid for all
    standard-compliant programs. It turns on -ffast-math and the Fortran-
    specific -fno-protect-parens and -fstack-arrays.

In other words, it generates invalid code sometimes. It would be a huge waste of time to put CFLAGS guard in every ebuild for every unsafe flag that you could come up with. It's easier to just say "don't do that." So I'll go ahead and say it =)

Don't use -ffast-math.

This is its description from the GCC wiki:

  In addition GCC offers the -ffast-math flag which is a shortcut for several 
  options, presenting the least conforming but fastest math mode. It enables 
  -fno-trapping-math, -funsafe-math-optimizations, -ffinite-math-only, 
  -fno-errno-math, -fno-signaling-nans, -fno-rounding-math, -fcx-limited-range
  and -fno-signed-zeros. Each of these flags violates IEEE in a different way. 
  -ffast-math also may disable some features of the hardware IEEE 
  implementation such as the support for denormals or flush-to-zero behavior.
Comment 3 Matt 2017-05-14 21:15:20 UTC
Hey!

I just thought I'd add that while I understand -Ofast isn't "usual" or "safe", I ran into this because I installed a totally-from-scratch Gentoo x86_64.  After redoing @system with -Ofast, I did emerge -q plasma-workspace - which is a hell of a lot of packages - and it was only this little one that didn't like -Ofast - and specifically said so.  Everything else complies fine, and (so far...) works fine.  This is why I filed the "bug".

I totally get that adding a "replace-flags" to every single package in the entire portage tree for every single "bad" flag is impossible.  I am not suggesting that.  That would be crazy.  I ran into this one small package that seemingly needs only one little tweak.


M.
Comment 4 Andreas Sturmlechner gentoo-dev 2017-07-09 16:05:27 UTC
I agree with Michael. If you want to go that way, you are free to maintain a package.env to make packages build fine with sane flags.