Skip to content

Commit 25ebbe3

Browse files
authored
[flang][doc] Added information about REAL(16) math intrinsics support. (#87710)
1 parent 9f07584 commit 25ebbe3

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

flang/docs/GettingStarted.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,16 @@ Clang-like device linking pipeline.
304304

305305
The same set of CMake variables works for Flang in-tree build.
306306

307+
### Build options
308+
309+
One may provide optional CMake variables to customize the build. Available options:
310+
311+
* `-DFLANG_RUNTIME_F128_MATH_LIB=libquadmath`: enables build of
312+
`FortranFloat128Math` library that provides `REAL(16)` math APIs
313+
for intrinsics such as `SIN`, `COS`, etc. GCC `libquadmath`'s header file
314+
`quadmath.h` must be available to the build compiler.
315+
[More details](Real16MathSupport.md).
316+
307317
## Supported C++ compilers
308318

309319
Flang is written in C++17.

flang/docs/Real16MathSupport.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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.

flang/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ on how to get in touch with us and to learn more about the current status.
8585
Semantics
8686
f2018-grammar.md
8787
fstack-arrays
88+
Real16MathSupport
8889
```
8990

9091
# Indices and tables

0 commit comments

Comments
 (0)