Skip to content

Handle -ffast-math #329

Open
Open
@certik

Description

@certik

#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 of fast-math (such as myself) will ensure that their package works with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions