Skip to content

BLD: add -std=c99 flag to scipy.special extensions using cosine.c #13841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 12, 2021

Conversation

rgommers
Copy link
Member

This fixes the manylinux1 builds. Closes gh-13840

Also clean up an outdated try-catch.

This fixes the manylinux1 builds. Closes scipygh-13840

Also clean up an outdated try-catch.
@rgommers rgommers added scipy.special Build issues Issues with building from source, including different choices of architecture, compilers and OS labels Apr 11, 2021
@rgommers rgommers requested a review from person142 as a code owner April 11, 2021 18:49
@rgommers rgommers changed the title BLD: add -std=c99 flag to scipy.special extension using cosine.c BLD: add -std=c99 flag to scipy.special extensions using cosine.c Apr 11, 2021
`M_PI` is not defined in C, but available by default in GCC.
However, compiling with `-std=c99` makes the symbol unavailable.
@rgommers
Copy link
Member Author

rgommers commented Apr 11, 2021

Still a 32-bit Windows failure. This code is quite fishy:

    // M_PI is not exactly π.  In fact, float64(π - M_PI) is
    // 1.2246467991473532e-16.  h is supposed to be x + π, so to compute
    // h accurately, we write the calculation as:
    h = (x + M_PI) + 1.2246467991473532e-16;

Not only should you not rely on M_PI being available, but if it is available, the exact numerical value is going to be a compiler-dependent approximation to \pi. It's very hard to believe that all implementations are going to be off by about np.finfo(np.float64).eps - 1e-16.

I'd prefer to mark this as a knownfail and open an issue to follow up (if desired, it's quite a niche failure). @WarrenWeckesser can you have a look at this?

Co-authored-by: Warren Weckesser <[email protected]>
@rgommers
Copy link
Member Author

That hexadecimal representation fixed it, merging. Thanks @WarrenWeckesser

@rgommers rgommers merged commit eb0bd84 into scipy:master Apr 12, 2021
@rgommers rgommers deleted the c99-special branch April 12, 2021 09:26
@rgommers rgommers added this to the 1.7.0 milestone Apr 12, 2021
@ev-br
Copy link
Member

ev-br commented Apr 12, 2021

Maybe upstream it to npy_math.h's definition of NPY_PI ?

@rgommers
Copy link
Member Author

That could make sense. Would you want to do that @WarrenWeckesser?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Build issues Issues with building from source, including different choices of architecture, compilers and OS scipy.special
Projects
None yet
Development

Successfully merging this pull request may close these issues.

manylinux1 builds are failing because of C99 usage in special/_cosine.c
3 participants