| 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 | |
| 11 | To support most `REAL(16)` (i.e. 128-bit float) math intrinsics Flang relies |
| 12 | on third-party libraries providing the implementation. |
| 13 | |
| 14 | `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath` CMake option can be used |
| 15 | to build `FortranFloat128Math` library that has unresolved references |
| 16 | to GCC `libquadmath` library. A Flang driver built with this option |
| 17 | will automatically link `FortranFloat128Math` and `libquadmath` libraries |
| 18 | to any Fortran program. This implies that `libquadmath` library |
| 19 | has to be available in the standard library paths, so that linker |
| 20 | can find it. The `libquadmath` library installation into Flang project |
| 21 | distribution is not automatic in CMake currently. |
| 22 | |
| 23 | Testing shows that `libquadmath` versions before GCC-9.3.0 have |
| 24 | accuracy issues, so it is recommended to distribute the Flang |
| 25 | package with later versions of `libquadmath`. |
| 26 | |
| 27 | Care must be taken by the distributors of a Flang package built |
| 28 | with `REAL(16)` support via `libquadmath` because of its licensing |
| 29 | under the GNU Library General Public License. Moreover, static linking |
| 30 | of `libquadmath` to the Flang users' programs may imply some |
| 31 | restrictions/requirements. This document is not intended to give |
| 32 | any legal advice on distributing such a Flang compiler. |
| 33 | |
| 34 | Flang compiler targeting systems with `LDBL_MANT_DIG == 113` |
| 35 | may provide `REAL(16)` math support without a `libquadmath` |
| 36 | dependency, using standard `libc` APIs for the `long double` |
| 37 | data type. It is not recommended to use the above CMake option |
| 38 | for building Flang compilers for such targets. |