xref: /llvm-project/flang/docs/Real16MathSupport.md (revision 25ebbe3851c54f035875fd3d7d2569d79cacf803)
1<!--===- docs/Real16MathSupport.md
2
3   Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4   See https://llvm.org/LICENSE.txt for license information.
5   SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
7-->
8
9# Flang support for REAL(16) math intrinsics
10
11To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies
12on third-party libraries providing the implementation.
13
14`-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used
15to build `FortranFloat128Math` library that has unresolved references
16to GCC `libquadmath` library. A Flang driver built with this option
17will automatically link `FortranFloat128Math` and `libquadmath` libraries
18to any Fortran program. This implies that `libquadmath` library
19has to be available in the standard library paths, so that linker
20can find it. The `libquadmath` library installation into Flang project
21distribution is not automatic in CMake currently.
22
23Testing shows that `libquadmath` versions before GCC-9.3.0 have
24accuracy issues, so it is recommended to distribute the Flang
25package with later versions of `libquadmath`.
26
27Care must be taken by the distributors of a Flang package built
28with `REAL(16)` support via `libquadmath` because of its licensing
29under the GNU Library General Public License. Moreover, static linking
30of `libquadmath` to the Flang users' programs may imply some
31restrictions/requirements. This document is not intended to give
32any legal advice on distributing such a Flang compiler.
33
34Flang compiler targeting systems with `LDBL_MANT_DIG == 113`
35may provide `REAL(16)` math support without a `libquadmath`
36dependency, using standard `libc` APIs for the `long double`
37data type. It is not recommended to use the above CMake option
38for building Flang compilers for such targets.
39