Skip to content
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

Revert "Export fenv functions on all platforms (#213)" #219

Merged
merged 1 commit into from
Nov 16, 2020

Conversation

maleadt
Copy link
Member

@maleadt maleadt commented Nov 16, 2020

The implementation of fesetenv cannot be portable, as the value of
FE_DFL_ENV differs between platforms. On FreeBSD, it is a actual
environment. With glibc however, it's a sentinel -1 handled in the
implementation of its floating point functions.

https://github.com/freebsd/freebsd/blob/a41d904f70e8e9e3c3062952b52f0845af0af738/lib/msun/x86/fenv.h#L97-L99

https://github.com/bminor/glibc/blob/acdcca72940e060270e4e54d9c0457398110f409/sysdeps/x86/fpu/bits/fenv.h#L96-L97

With openlibm based on FreeBSD's libm, it assumes FE_DFL_ENV to be an
actual environment. That assumption breaks using code that was compiled
against glibc, e.g., libcuda:

Thread 1 "julia-debug" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b855d0 in fesetenv () from /home/tim/Julia/julia/build/release/usr/bin/../lib/libopenlibm.so
(gdb) bt

This reverts commit 5a27b4c.

Fixes JuliaLang/julia#38427.

The implementation of `fesetenv` cannot be portable, as the value of
`FE_DFL_ENV` differs between platforms. On FreeBSD, it is a actual
environment. With glibc however, it's a sentinel -1 handled in the
implementation of its floating point functions.

With openlibm based on FreeBSD's libm, it assumes `FE_DFL_ENV` to be an
actual environment. That assumption breaks using code that was compiled
against glibc, e.g., `libcuda`:

```
Thread 1 "julia-debug" received signal SIGSEGV, Segmentation fault.
0x00007ffff7b855d0 in fesetenv () from /home/tim/Julia/julia/build/release/usr/bin/../lib/libopenlibm.so
(gdb) bt
```

This reverts commit 5a27b4c.

Fixes JuliaLang/julia#38427.
@staticfloat staticfloat merged commit c856101 into JuliaMath:master Nov 16, 2020
@staticfloat
Copy link
Contributor

If I can't remember why I did this, it can't be that important. Go ahead and do a run on the buildbots with this and let's see if it all compiles properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

openlibm fenv changes broke CUDA
2 participants