shibatch / sleef

SIMD Library for Evaluating Elementary Functions, vectorized libm and DFT
https://sleef.org
Boost Software License 1.0
637 stars 129 forks source link

Compilation fails (conflicting types) if mpfr-devel 4.2.0 is provided #458

Closed fpesari closed 10 months ago

fpesari commented 1 year ago

Hello,

I tried compiling sleef 3.5.1 with mpfr 4.2.0 support on openSUSE but it failed with a bunch of conflicting type errors:

[   97s] /home/abuild/rpmbuild/BUILD/sleef-3.5.1/src/libm-tester/testerutil.h:93:6: error: conflicting types for 'mpfr_sinpi'; have 'void(__mpfr_struct *, __mpfr_struct *, mpfr_rnd_t)'
[   97s]    93 | void mpfr_sinpi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd);
[   97s]       |      ^~~~~~~~~~
[   97s] In file included from /home/abuild/rpmbuild/BUILD/sleef-3.5.1/src/libm-tester/tester2simddp.c:9:
[   97s] /usr/include/mpfr.h:752:21: note: previous declaration of 'mpfr_sinpi' with type 'int(__mpfr_struct *, const __mpfr_struct *, mpfr_rnd_t)'
[   97s]   752 | __MPFR_DECLSPEC int mpfr_sinpi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);
[   97s]       |                     ^~~~~~~~~~
[   97s] /home/abuild/rpmbuild/BUILD/sleef-3.5.1/src/libm-tester/testerutil.h:94:6: error: conflicting types for 'mpfr_cospi'; have 'void(__mpfr_struct *, __mpfr_struct *, mpfr_rnd_t)'
[   97s]    94 | void mpfr_cospi(mpfr_t ret, mpfr_t arg, mpfr_rnd_t rnd);
[   97s]       |      ^~~~~~~~~~
[   97s] /usr/include/mpfr.h:753:21: note: previous declaration of 'mpfr_cospi' with type 'int(__mpfr_struct *, const __mpfr_struct *, mpfr_rnd_t)'
[   97s]   753 | __MPFR_DECLSPEC int mpfr_cospi (mpfr_ptr, mpfr_srcptr, mpfr_rnd_t);

If mpfr is not provided, however, sleef will be compiled successfully. Can I safely package sleef without mpfr support? Thank you.

adamjstewart commented 10 months ago

Using -DBUILD_TESTS=OFF allowed me to avoid CMake finding my system-installed MPFR 4.2.0 and compiling successfully.

blapie commented 7 months ago

@adamjstewart Is this still an issue? Detection of mpfr often requires tweaking depending on the OS, we will try to improve it in the future. @fpesari sorry we did not answer the question, sleef can be packaged without MPFR, as it is only required for testing as suggested by @adamjstewart.

adamjstewart commented 7 months ago

It looks like it was fixed by #471. Will backport this if I need to build older versions for PyTorch.