bluescarni / mppp

Multiprecision for modern C++
Mozilla Public License 2.0
305 stars 25 forks source link

Use of GCC extension: The 'MPPP_WITH_QUADMATH' option was enabled but the '__float128' type does #186

Closed yurivict closed 5 years ago

yurivict commented 5 years ago

It fails in clang-8.

Please use the standard type long double instead.

bluescarni commented 5 years ago

__float128 is different from long double, on x86 at least. And __float128 has been supported by clang since version 3.9, if I recall correctly.

Could you tell me in detail what steps lead to that error message?

yurivict commented 5 years ago

In the FreeBSD port math/mppp that I maintain make test fails:

-- Check size of __float128
-- Check size of __float128 - failed
CMake Error at CMakeLists.txt:143 (message):
  The 'MPPP_WITH_QUADMATH' option was enabled but the '__float128' type does
  not exist.

The build of the test target fails.

$ clang --version
FreeBSD clang version 8.0.0 (tags/RELEASE_800/final 356365) (based on LLVM 8.0.0)
Target: x86_64-unknown-freebsd12.0
Thread model: posix
InstalledDir: /usr/bin
bluescarni commented 5 years ago

@yurivict This is strange, as I am regularly running tests with clang on the CI, albeit admittedly not clang 8, e.g.:

https://circleci.com/gh/bluescarni/mppp/496

This is a build using clang 7 in linux ubuntu. So this may be a FreeBSD-specific problem.

Could you try to compile the following:

int main()
{
        __float128 x = 0;
}

You can disable altogether the use of __float128 in mp++ by setting the CMake option MPPP_WITH_QUADMATH to NO (it should be disabled by default).

yurivict commented 5 years ago
$ cc -c x.c
x.c:3:9: error: __float128 is not supported on this target
        __float128 x = 0;
        ^
1 error generated.

They might have removed the __float128 support because it isn't a standard type.

yurivict commented 5 years ago

You can disable altogether the use of __float128 in mp++ by setting the CMake option MPPP_WITH_QUADMATH to NO (it should be disabled by default).

Yes, but I was trying to see if it tests with MPPP_WITH_QUADMATH.

bluescarni commented 5 years ago

Is this architecture x86_64 or something else?

yurivict commented 5 years ago

This is x86_64, called amd64 on BSD.

bluescarni commented 5 years ago

Not sure what to do, apart from disabling quadmath support altogether in FreeBSD?

bluescarni commented 5 years ago

@yurivict perhaps it's a matter of invoking clang with some special flag/define? If that's the case, I could add the necessary bits in mp++.

yurivict commented 5 years ago

long double is 12 bytes on i386 and 16 bytes on amd64. I'm not sure what is the portable quad-precision floating point type is.

bluescarni commented 5 years ago

long double on x86 GCC/clang is the old 387 80-bit extended precision type. It's 12 bytes on x86_32 and 16 bytes on x86_64 due to alignment. long double on ppc64 is actually a double-double type similar (but not identical) to quadruple precision. __float128 is a software implementation of "true" quadruple precision arithmetics.

On Windows, long double is the same as double.

yurivict commented 5 years ago

FYI: Here's the answer I received from the hackers@FreeBSD.org mailing list: https://lists.freebsd.org/pipermail/freebsd-hackers/2019-May/054657.html

He seems to mean that there is no true quad-precision type on either x86_64 and i386.

bluescarni commented 5 years ago

Would be interesting to know the rationale behind removing support for quadruple-precision floats in FreeBSD.

yurivict commented 5 years ago

As it turned out, clang supports __float128 even though it isn't a C/C++ standard type, but FreeBSD disabled its support for some unknown reason. I've requested its reinstantiation.

Thanks for your help!

bluescarni commented 4 years ago

@yurivict sorry for pinging you here, but it seems the easiest way to contact you :)

I just wanted to tell you that with the release of the latest version, 0.20, mp++ now optionally depends on the GNU MPC library for the implementation of complex multiprecision numbers. Since I noticed that MPC is available in the FreeBSD ports collection, perhaps you can add it as a dependency for mp++ and build the library with the MPPP_WITH_MPC option on?

yurivict commented 4 years ago

I've enabled the MPC option, thank you for your suggestion!

bluescarni commented 4 years ago

I've enabled the MPC option, thank you for your suggestion!

Great, thank you very much!

yurivict commented 4 years ago

Great, thank you very much!

No problem!