Skip to content

Commit 91b5bef

Browse files
authored
[flang] Tighten requirements on some glibc float128 functions (#110651)
j0l, j1l, jnl, y0l, y1l and ynl are glibc extensions rather than standard POSIX functions, and so are not available in every Linux libc. This patch checks if `__GLIBC__` and `_GNU_SOURCE` are defined before using these functions. This patch allows the float128 runtime to build with musl libc on Linux.
1 parent ab2b175 commit 91b5bef

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

flang/lib/Evaluate/intrinsics-library.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ template <> struct HostRuntimeLibrary<double, LibraryVersion::LibmExtensions> {
417417
static_assert(map.Verify(), "map must be sorted");
418418
};
419419

420-
#if HAS_FLOAT80 || HAS_LDBL128
420+
#if defined(__GLIBC__) && (HAS_FLOAT80 || HAS_LDBL128)
421421
template <>
422422
struct HostRuntimeLibrary<long double, LibraryVersion::LibmExtensions> {
423423
using F = FuncPointer<long double, long double>;

flang/runtime/Float128Math/math-entries.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,6 @@ DEFINE_SIMPLE_ALIAS(Hypot, std::hypot)
187187
DEFINE_SIMPLE_ALIAS(Ilogb, std::ilogb)
188188
DEFINE_SIMPLE_ALIAS(Isinf, std::isinf)
189189
DEFINE_SIMPLE_ALIAS(Isnan, std::isnan)
190-
DEFINE_SIMPLE_ALIAS(J0, j0l)
191-
DEFINE_SIMPLE_ALIAS(J1, j1l)
192-
DEFINE_SIMPLE_ALIAS(Jn, jnl)
193190
DEFINE_SIMPLE_ALIAS(Ldexp, std::ldexp)
194191
DEFINE_SIMPLE_ALIAS(Lgamma, std::lgamma)
195192
DEFINE_SIMPLE_ALIAS(Llround, std::llround)
@@ -207,9 +204,15 @@ DEFINE_SIMPLE_ALIAS(Tan, std::tan)
207204
DEFINE_SIMPLE_ALIAS(Tanh, std::tanh)
208205
DEFINE_SIMPLE_ALIAS(Tgamma, std::tgamma)
209206
DEFINE_SIMPLE_ALIAS(Trunc, std::trunc)
207+
208+
#if defined(__GLIBC__) && defined(_GNU_SOURCE)
209+
DEFINE_SIMPLE_ALIAS(J0, j0l)
210+
DEFINE_SIMPLE_ALIAS(J1, j1l)
211+
DEFINE_SIMPLE_ALIAS(Jn, jnl)
210212
DEFINE_SIMPLE_ALIAS(Y0, y0l)
211213
DEFINE_SIMPLE_ALIAS(Y1, y1l)
212214
DEFINE_SIMPLE_ALIAS(Yn, ynl)
215+
#endif
213216

214217
// Use numeric_limits to produce infinity of the right type.
215218
#define F128_RT_INFINITY \

0 commit comments

Comments
 (0)