Description
#315 removed -ffast-math
from default flags because it can cause problems. However, I still want to use it in my projects that work with it and makes them a lot faster. I opened this issue to brainstorm some ways to fix this.
One proposal is this: there will be a flag fast-math
in fpm.toml
that is false
by default (if you omit it). If you set it to true
, then you signal to fpm
that your package works both with and without the -ffast-math
flag.
When you run fpm build --release
on a package, fpm
will examine the fast-math
flag in the current package as well as all the dependencies. If they are all true
, then it builds everything with -ffast-math
. If one of them is false
, then it will not use the flag.
This proposal should get me what I would like, without breaking things for others. As an example, until we fix stdlib
, we would not set its fast-math
flag to true
which will cause all programs that use it to be compiled without -ffast-math
. Package maintainers and end users who do not want to be worried about this simply omit the fast-math
flag in their fpm.toml
which makes fpm
never to compile with -ffast-math
.
Possible issues:
- It is not well defined what exactly
fast-math
means for each compiler. We can overcome this by being practical: for each compiler that we support, we identify these so-called "unsafe" optimizations, and package maintainers that want to take advantage offast-math
(such as myself) will ensure that their package works with it.