git: c9991e01149b - main - powerpc64le: switch from calling wrappers to weak references

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Wed, 01 Jul 2026 08:21:19 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c9991e01149b5cd5a6710d70921b203ef7f16fc2

commit c9991e01149b5cd5a6710d70921b203ef7f16fc2
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-06-25 17:33:42 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-07-01 08:21:06 +0000

    powerpc64le: switch from calling wrappers to weak references
    
    Fixes:  255538cd906045095d0c2113ae6c4731ce36c0cf
    Differential Revision: https://reviews.freebsd.org/D57850
    Reviewed by:    adrian
---
 lib/msun/Makefile                      |  1 +
 lib/msun/{powerpc => }/Symbol_f128.map | 31 +++++++++++++++++++++---
 lib/msun/ld128/b_tgammal.c             |  2 ++
 lib/msun/ld128/e_powl.c                |  2 ++
 lib/msun/ld128/s_erfl.c                |  3 +++
 lib/msun/ld128/s_exp2l.c               |  2 ++
 lib/msun/ld128/s_expl.c                |  3 +++
 lib/msun/ld128/s_logl.c                |  5 ++++
 lib/msun/ld128/s_nanl.c                |  2 ++
 lib/msun/powerpc/Makefile.inc          |  3 ---
 lib/msun/powerpc/ld128_compat.c        | 43 ----------------------------------
 lib/msun/src/e_acoshl.c                |  4 ++++
 lib/msun/src/e_acosl.c                 |  4 ++++
 lib/msun/src/e_asinl.c                 |  4 ++++
 lib/msun/src/e_atan2l.c                |  4 ++++
 lib/msun/src/e_atanhl.c                |  4 ++++
 lib/msun/src/e_coshl.c                 |  4 ++++
 lib/msun/src/e_fmodl.c                 |  4 ++++
 lib/msun/src/e_hypotl.c                |  4 ++++
 lib/msun/src/e_lgammal.c               |  5 ++++
 lib/msun/src/e_remainderl.c            |  5 ++++
 lib/msun/src/e_sinhl.c                 |  4 ++++
 lib/msun/src/e_sqrtl.c                 |  4 ++++
 lib/msun/src/s_asinhl.c                |  4 ++++
 lib/msun/src/s_atanl.c                 |  4 ++++
 lib/msun/src/s_cbrtl.c                 |  4 ++++
 lib/msun/src/s_ceill.c                 |  4 ++++
 lib/msun/src/s_copysignl.c             |  5 ++++
 lib/msun/src/s_cosl.c                  |  4 ++++
 lib/msun/src/s_fabsl.c                 |  5 ++++
 lib/msun/src/s_fdim.c                  |  5 ++++
 lib/msun/src/s_floorl.c                |  4 ++++
 lib/msun/src/s_fmal.c                  |  4 ++++
 lib/msun/src/s_fmaxl.c                 |  5 ++++
 lib/msun/src/s_fminl.c                 |  5 ++++
 lib/msun/src/s_frexpl.c                |  4 ++++
 lib/msun/src/s_ilogbl.c                |  4 ++++
 lib/msun/src/s_llrintl.c               |  5 ++++
 lib/msun/src/s_llroundl.c              |  5 ++++
 lib/msun/src/s_logbl.c                 |  4 ++++
 lib/msun/src/s_lrintl.c                |  5 ++++
 lib/msun/src/s_lroundl.c               |  5 ++++
 lib/msun/src/s_modfl.c                 |  4 ++++
 lib/msun/src/s_nearbyint.c             |  5 ++++
 lib/msun/src/s_nextafterl.c            |  4 ++++
 lib/msun/src/s_remquol.c               |  4 ++++
 lib/msun/src/s_rintl.c                 |  4 ++++
 lib/msun/src/s_roundl.c                |  4 ++++
 lib/msun/src/s_scalbln.c               |  5 ++++
 lib/msun/src/s_scalbnl.c               |  5 ++++
 lib/msun/src/s_sincosl.c               |  4 ++++
 lib/msun/src/s_sinl.c                  |  4 ++++
 lib/msun/src/s_tanhl.c                 |  4 ++++
 lib/msun/src/s_tanl.c                  |  4 ++++
 lib/msun/src/s_truncl.c                |  4 ++++
 55 files changed, 238 insertions(+), 49 deletions(-)

diff --git a/lib/msun/Makefile b/lib/msun/Makefile
index 865aee6df5c1..52848965ae64 100644
--- a/lib/msun/Makefile
+++ b/lib/msun/Makefile
@@ -27,6 +27,7 @@ CFLAGS+=	-I${.CURDIR}/ld80
 .elif ${LDBL_PREC} == 113
 .PATH:  ${.CURDIR}/ld128
 CFLAGS+=	-I${.CURDIR}/ld128 -I${SRCTOP}/contrib/arm-optimized-routines/math
+SYM_MAPS+=	${.CURDIR}/Symbol_f128.map
 .endif
 
 CFLAGS+=	-I${.CURDIR}/${ARCH_SUBDIR}
diff --git a/lib/msun/powerpc/Symbol_f128.map b/lib/msun/Symbol_f128.map
similarity index 55%
rename from lib/msun/powerpc/Symbol_f128.map
rename to lib/msun/Symbol_f128.map
index d520bfaa0fab..128cf1c29578 100644
--- a/lib/msun/powerpc/Symbol_f128.map
+++ b/lib/msun/Symbol_f128.map
@@ -2,35 +2,60 @@
  */
 FBSD_1.9 {
 	acosf128;
+	acoshf128;
 	asinf128;
-	atanf128;
+	asinhf128;
 	atan2f128;
+	atanf128;
+	atanhf128;
+	cbrtf128;
 	ceilf128;
+	copysignf128;
 	cosf128;
 	coshf128;
-	expf128;
+	erfcf128;
+	erff128;
 	exp2f128;
+	expf128;
+	expm1f128;
+	fabsf128;
+	fdimf128;
 	floorf128;
 	fmaf128;
 	fmaxf128;
 	fminf128;
 	fmodf128;
+	frexpf128;
+	hypotf128;
+	ilogbf128;
 	ldexpf128;
+	lgammaf128;
+	llrintf128;
 	llroundf128;
-	logf128;
 	log10f128;
+	log1pf128;
 	log2f128;
+	logbf128;
+	logf128;
+	lrintf128;
 	lroundf128;
 	modff128;
+	nanf128;
 	nearbyintf128;
+	nextafterf128;
 	powf128;
+	remainderf128;
+	remquof128;
 	rintf128;
 	roundf128;
+	scalblnf128;
+	scalbnf128;
 	sincosf128;
 	sinf128;
 	sinhf128;
 	sqrtf128;
 	tanf128;
 	tanhf128;
+	tgammaf128;
 	truncf128;
 };
diff --git a/lib/msun/ld128/b_tgammal.c b/lib/msun/ld128/b_tgammal.c
index 6df7264a4c9e..811ab559256d 100644
--- a/lib/msun/ld128/b_tgammal.c
+++ b/lib/msun/ld128/b_tgammal.c
@@ -10,3 +10,5 @@
  */
 #define tgamma128 tgammal
 #include "tgamma128.c"
+
+__weak_reference(tgammal, tgammaf128);
diff --git a/lib/msun/ld128/e_powl.c b/lib/msun/ld128/e_powl.c
index f5a993cf0054..bcfc60c42b27 100644
--- a/lib/msun/ld128/e_powl.c
+++ b/lib/msun/ld128/e_powl.c
@@ -438,3 +438,5 @@ powl(long double x, long double y)
     }
   return s * z;
 }
+
+__weak_reference(powl, powf128);
diff --git a/lib/msun/ld128/s_erfl.c b/lib/msun/ld128/s_erfl.c
index 227c31fd096b..81a60741aa4d 100644
--- a/lib/msun/ld128/s_erfl.c
+++ b/lib/msun/ld128/s_erfl.c
@@ -323,3 +323,6 @@ erfcl(long double x)
 	    if(x>0) return tiny*tiny; else return two-tiny;
 	}
 }
+
+__weak_reference(erfl, erff128);
+__weak_reference(erfcl, erfcf128);
diff --git a/lib/msun/ld128/s_exp2l.c b/lib/msun/ld128/s_exp2l.c
index 249cb4cb8bb0..d285d06ea7db 100644
--- a/lib/msun/ld128/s_exp2l.c
+++ b/lib/msun/ld128/s_exp2l.c
@@ -424,3 +424,5 @@ exp2l(long double x)
 		return (r * twopkp10000 * twom10000);
 	}
 }
+
+__weak_reference(exp2l, exp2f128);
diff --git a/lib/msun/ld128/s_expl.c b/lib/msun/ld128/s_expl.c
index e1358e2213a0..41a36e1f8d49 100644
--- a/lib/msun/ld128/s_expl.c
+++ b/lib/msun/ld128/s_expl.c
@@ -317,3 +317,6 @@ expm1l(long double x)
 		t = SUM2P(tbl[n2].hi - twomk, tbl[n2].lo + t * (q + r1));
 	RETURNI(t * twopk);
 }
+
+__weak_reference(expl, expf128);
+__weak_reference(expm1l, expm1f128);
diff --git a/lib/msun/ld128/s_logl.c b/lib/msun/ld128/s_logl.c
index e9133ec66fd2..fc7b4645b38a 100644
--- a/lib/msun/ld128/s_logl.c
+++ b/lib/msun/ld128/s_logl.c
@@ -729,3 +729,8 @@ log2l(long double x)
 }
 
 #endif /* STRUCT_RETURN */
+
+__weak_reference(logl, logf128);
+__weak_reference(log10l, log10f128);
+__weak_reference(log1pl, log1pf128);
+__weak_reference(log2l, log2f128);
diff --git a/lib/msun/ld128/s_nanl.c b/lib/msun/ld128/s_nanl.c
index b90d0243e658..ed0ec9c6c84a 100644
--- a/lib/msun/ld128/s_nanl.c
+++ b/lib/msun/ld128/s_nanl.c
@@ -44,3 +44,5 @@ nanl(const char *s)
 	u.ieee.bits.manh |= 1ULL << 47;	/* make it a quiet NaN */
 	return (u.ieee.e);
 }
+
+__weak_reference(nanl, nanf128);
diff --git a/lib/msun/powerpc/Makefile.inc b/lib/msun/powerpc/Makefile.inc
index d0e6078e358c..ecbbe1277543 100644
--- a/lib/msun/powerpc/Makefile.inc
+++ b/lib/msun/powerpc/Makefile.inc
@@ -1,8 +1,5 @@
 .if ${MACHINE_ARCH} == "powerpc64le"
 LDBL_PREC = 113
-ARCH_SRCS = ld128_compat.c
-CFLAGS.ld128_compat.c+= -fno-builtin
-SYM_MAPS+= ${.CURDIR}/${ARCH_SUBDIR}/Symbol_f128.map
 .else
 LDBL_PREC = 53
 .endif
diff --git a/lib/msun/powerpc/ld128_compat.c b/lib/msun/powerpc/ld128_compat.c
deleted file mode 100644
index 94d6bdc2f09b..000000000000
--- a/lib/msun/powerpc/ld128_compat.c
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * On powerpc64le, long double is IEEE binary128, which the compiler treats as
- * _Float128.  clang lowers long double libm calls to the f128-suffixed entry
- * points (sinf128, powf128, ...) rather than the *l names.  Provide those entry
- * points as thin forwarders to the existing long double implementations.
- *
- * This file is compiled with -fno-builtin so the calls below are not themselves
- * rewritten back to the f128 names, which would recurse infinitely.
- */
-#include <math.h>
-
-long double acosf128(long double x) { return acosl(x); }
-long double asinf128(long double x) { return asinl(x); }
-long double atanf128(long double x) { return atanl(x); }
-long double atan2f128(long double y, long double x) { return atan2l(y, x); }
-long double ceilf128(long double x) { return ceill(x); }
-long double cosf128(long double x) { return cosl(x); }
-long double coshf128(long double x) { return coshl(x); }
-long double expf128(long double x) { return expl(x); }
-long double exp2f128(long double x) { return exp2l(x); }
-long double floorf128(long double x) { return floorl(x); }
-long double fmaf128(long double x, long double y, long double z) { return fmal(x, y, z); }
-long double fmaxf128(long double x, long double y) { return fmaxl(x, y); }
-long double fminf128(long double x, long double y) { return fminl(x, y); }
-long double fmodf128(long double x, long double y) { return fmodl(x, y); }
-long double ldexpf128(long double x, int n) { return ldexpl(x, n); }
-long long llroundf128(long double x) { return llroundl(x); }
-long double logf128(long double x) { return logl(x); }
-long double log10f128(long double x) { return log10l(x); }
-long double log2f128(long double x) { return log2l(x); }
-long lroundf128(long double x) { return lroundl(x); }
-long double modff128(long double x, long double *iptr) { return modfl(x, iptr); }
-long double nearbyintf128(long double x) { return nearbyintl(x); }
-long double powf128(long double x, long double y) { return powl(x, y); }
-long double rintf128(long double x) { return rintl(x); }
-long double roundf128(long double x) { return roundl(x); }
-void sincosf128(long double x, long double *s, long double *c) { sincosl(x, s, c); }
-long double sinf128(long double x) { return sinl(x); }
-long double sinhf128(long double x) { return sinhl(x); }
-long double sqrtf128(long double x) { return sqrtl(x); }
-long double tanf128(long double x) { return tanl(x); }
-long double tanhf128(long double x) { return tanhl(x); }
-long double truncf128(long double x) { return truncl(x); }
diff --git a/lib/msun/src/e_acoshl.c b/lib/msun/src/e_acoshl.c
index 6bfa6244df09..750ed75126b6 100644
--- a/lib/msun/src/e_acoshl.c
+++ b/lib/msun/src/e_acoshl.c
@@ -83,3 +83,7 @@ acoshl(long double x)
 	    RETURNI(log1pl(t+sqrtl(2.0*t+t*t)));
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(acoshl, acoshf128);
+#endif
diff --git a/lib/msun/src/e_acosl.c b/lib/msun/src/e_acosl.c
index 209814383e51..d2537b74c40a 100644
--- a/lib/msun/src/e_acosl.c
+++ b/lib/msun/src/e_acosl.c
@@ -81,3 +81,7 @@ acosl(long double x)
 	    return 2.0*(df+w);
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(acosl, acosf128);
+#endif
diff --git a/lib/msun/src/e_asinl.c b/lib/msun/src/e_asinl.c
index bb2320e129e7..2147077ef546 100644
--- a/lib/msun/src/e_asinl.c
+++ b/lib/msun/src/e_asinl.c
@@ -71,3 +71,7 @@ asinl(long double x)
 	}    
 	if(expsign>0) return t; else return -t;    
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(asinl, asinf128);
+#endif
diff --git a/lib/msun/src/e_atan2l.c b/lib/msun/src/e_atan2l.c
index a27fd3efc141..9f7906bf9a85 100644
--- a/lib/msun/src/e_atan2l.c
+++ b/lib/msun/src/e_atan2l.c
@@ -114,3 +114,7 @@ atan2l(long double y, long double x)
 	    	    return  (z-pi_lo)-pi;/* atan(-,-) */
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(atan2l, atan2f128);
+#endif
diff --git a/lib/msun/src/e_atanhl.c b/lib/msun/src/e_atanhl.c
index cb707272a66c..c6c59512c594 100644
--- a/lib/msun/src/e_atanhl.c
+++ b/lib/msun/src/e_atanhl.c
@@ -68,3 +68,7 @@ atanhl(long double x)
 	    t = 0.5*log1pl((x+x)/(one-x));
 	RETURNI((hx & 0x8000) == 0 ? t : -t);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(atanhl, atanhf128);
+#endif
diff --git a/lib/msun/src/e_coshl.c b/lib/msun/src/e_coshl.c
index efb5094d39f9..e978b2b595f3 100644
--- a/lib/msun/src/e_coshl.c
+++ b/lib/msun/src/e_coshl.c
@@ -127,3 +127,7 @@ coshl(long double x)
     /* |x| > o_threshold, cosh(x) overflow */
 	RETURNI(huge*huge);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(coshl, coshf128);
+#endif
diff --git a/lib/msun/src/e_fmodl.c b/lib/msun/src/e_fmodl.c
index d5997e1f4e47..01697bd7ba57 100644
--- a/lib/msun/src/e_fmodl.c
+++ b/lib/msun/src/e_fmodl.c
@@ -143,3 +143,7 @@ fmodl(long double x, long double y)
 	x = ux.e * one;		/* create necessary signal */
 	return x;		/* exact output */
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fmodl, fmodf128);
+#endif
diff --git a/lib/msun/src/e_hypotl.c b/lib/msun/src/e_hypotl.c
index d8e060a66184..22df513cd158 100644
--- a/lib/msun/src/e_hypotl.c
+++ b/lib/msun/src/e_hypotl.c
@@ -118,3 +118,7 @@ hypotl(long double x, long double y)
 	    return t1*w;
 	} else return w;
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(hypotl, hypotf128);
+#endif
diff --git a/lib/msun/src/e_lgammal.c b/lib/msun/src/e_lgammal.c
index 51e3216a8220..79b17ccac432 100644
--- a/lib/msun/src/e_lgammal.c
+++ b/lib/msun/src/e_lgammal.c
@@ -10,6 +10,7 @@
  */
 
 #include "math.h"
+#include <float.h>
 #include "math_private.h"
 
 extern int signgam;
@@ -19,3 +20,7 @@ lgammal(long double x)
 {
 	return lgammal_r(x,&signgam);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(lgammal, lgammaf128);
+#endif
diff --git a/lib/msun/src/e_remainderl.c b/lib/msun/src/e_remainderl.c
index 7a681cdb1289..014b53cb7a63 100644
--- a/lib/msun/src/e_remainderl.c
+++ b/lib/msun/src/e_remainderl.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 long double
 remainderl(long double x, long double y)
@@ -35,3 +36,7 @@ remainderl(long double x, long double y)
 
 	return (remquol(x, y, &quo));
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(remainderl, remainderf128);
+#endif
diff --git a/lib/msun/src/e_sinhl.c b/lib/msun/src/e_sinhl.c
index cf481b2abd96..928fcaa59fc9 100644
--- a/lib/msun/src/e_sinhl.c
+++ b/lib/msun/src/e_sinhl.c
@@ -129,3 +129,7 @@ sinhl(long double x)
     /* |x| > o_threshold, sinh(x) overflow */
 	return x*shuge;
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(sinhl, sinhf128);
+#endif
diff --git a/lib/msun/src/e_sqrtl.c b/lib/msun/src/e_sqrtl.c
index a785536ea7e2..95b5eccc980d 100644
--- a/lib/msun/src/e_sqrtl.c
+++ b/lib/msun/src/e_sqrtl.c
@@ -156,3 +156,7 @@ sqrtl(long double x)
 	u.bits.exp--;
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(sqrtl, sqrtf128);
+#endif
diff --git a/lib/msun/src/s_asinhl.c b/lib/msun/src/s_asinhl.c
index b939fae8fbef..d2339d36c758 100644
--- a/lib/msun/src/s_asinhl.c
+++ b/lib/msun/src/s_asinhl.c
@@ -85,3 +85,7 @@ asinhl(long double x)
 	}
 	RETURNI((hx & 0x8000) == 0 ? w : -w);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(asinhl, asinhf128);
+#endif
diff --git a/lib/msun/src/s_atanl.c b/lib/msun/src/s_atanl.c
index d9e617455499..73129570ddb1 100644
--- a/lib/msun/src/s_atanl.c
+++ b/lib/msun/src/s_atanl.c
@@ -79,3 +79,7 @@ atanl(long double x)
 	    return (expsign<0)? -z:z;
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(atanl, atanf128);
+#endif
diff --git a/lib/msun/src/s_cbrtl.c b/lib/msun/src/s_cbrtl.c
index ff527cc5e5e7..690629119ca1 100644
--- a/lib/msun/src/s_cbrtl.c
+++ b/lib/msun/src/s_cbrtl.c
@@ -138,3 +138,7 @@ cbrtl(long double x)
 	t *= v.e;
 	RETURNI(t);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(cbrtl, cbrtf128);
+#endif
diff --git a/lib/msun/src/s_ceill.c b/lib/msun/src/s_ceill.c
index ded36c1ebe1b..392e4db09b40 100644
--- a/lib/msun/src/s_ceill.c
+++ b/lib/msun/src/s_ceill.c
@@ -94,3 +94,7 @@ ceill(long double x)
 	}
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(ceill, ceilf128);
+#endif
diff --git a/lib/msun/src/s_copysignl.c b/lib/msun/src/s_copysignl.c
index 0c4bc0758278..f958bd4f63d4 100644
--- a/lib/msun/src/s_copysignl.c
+++ b/lib/msun/src/s_copysignl.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #include "fpmath.h"
 
@@ -40,3 +41,7 @@ copysignl(long double x, long double y)
 	ux.bits.sign = uy.bits.sign;
 	return (ux.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(copysignl, copysignf128);
+#endif
diff --git a/lib/msun/src/s_cosl.c b/lib/msun/src/s_cosl.c
index 32fc8b26a206..f4a54493cdd8 100644
--- a/lib/msun/src/s_cosl.c
+++ b/lib/msun/src/s_cosl.c
@@ -97,3 +97,7 @@ cosl(long double x)
 	
 	RETURNI(hi);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(cosl, cosf128);
+#endif
diff --git a/lib/msun/src/s_fabsl.c b/lib/msun/src/s_fabsl.c
index 3339701bc2d7..f153a9c4ce2b 100644
--- a/lib/msun/src/s_fabsl.c
+++ b/lib/msun/src/s_fabsl.c
@@ -29,6 +29,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #include "fpmath.h"
 
@@ -41,3 +42,7 @@ fabsl(long double x)
 	u.bits.sign = 0;
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fabsl, fabsf128);
+#endif
diff --git a/lib/msun/src/s_fdim.c b/lib/msun/src/s_fdim.c
index 4f56ee4b3482..f3af30d558bb 100644
--- a/lib/msun/src/s_fdim.c
+++ b/lib/msun/src/s_fdim.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #define	DECL(type, fn)			\
 type					\
@@ -43,3 +44,7 @@ fn(type x, type y)			\
 DECL(double, fdim)
 DECL(float, fdimf)
 DECL(long double, fdiml)
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fdiml, fdimf128);
+#endif
diff --git a/lib/msun/src/s_floorl.c b/lib/msun/src/s_floorl.c
index 3b54cabe7237..9ec89ea060fc 100644
--- a/lib/msun/src/s_floorl.c
+++ b/lib/msun/src/s_floorl.c
@@ -94,3 +94,7 @@ floorl(long double x)
 	}
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(floorl, floorf128);
+#endif
diff --git a/lib/msun/src/s_fmal.c b/lib/msun/src/s_fmal.c
index 2fca20610157..064e72c631cb 100644
--- a/lib/msun/src/s_fmal.c
+++ b/lib/msun/src/s_fmal.c
@@ -269,3 +269,7 @@ fmal(long double x, long double y, long double z)
 	else
 		return (add_and_denormalize(r.hi, adj, spread));
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fmal, fmaf128);
+#endif
diff --git a/lib/msun/src/s_fmaxl.c b/lib/msun/src/s_fmaxl.c
index 1019612696c1..ef23be5321da 100644
--- a/lib/msun/src/s_fmaxl.c
+++ b/lib/msun/src/s_fmaxl.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #include "fpmath.h"
 
@@ -52,3 +53,7 @@ fmaxl(long double x, long double y)
 
 	return (x > y ? x : y);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fmaxl, fmaxf128);
+#endif
diff --git a/lib/msun/src/s_fminl.c b/lib/msun/src/s_fminl.c
index 5af3bf45087a..75e45bffb31e 100644
--- a/lib/msun/src/s_fminl.c
+++ b/lib/msun/src/s_fminl.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #include "fpmath.h"
 
@@ -52,3 +53,7 @@ fminl(long double x, long double y)
 
 	return (x < y ? x : y);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(fminl, fminf128);
+#endif
diff --git a/lib/msun/src/s_frexpl.c b/lib/msun/src/s_frexpl.c
index 32f12641897f..88eb78159200 100644
--- a/lib/msun/src/s_frexpl.c
+++ b/lib/msun/src/s_frexpl.c
@@ -60,3 +60,7 @@ frexpl(long double x, int *ex)
 	}
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(frexpl, frexpf128);
+#endif
diff --git a/lib/msun/src/s_ilogbl.c b/lib/msun/src/s_ilogbl.c
index 4d8fb8fa3cde..83ddb90a6d44 100644
--- a/lib/msun/src/s_ilogbl.c
+++ b/lib/msun/src/s_ilogbl.c
@@ -47,3 +47,7 @@ ilogbl(long double x)
 	else
 		return (INT_MAX);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(ilogbl, ilogbf128);
+#endif
diff --git a/lib/msun/src/s_llrintl.c b/lib/msun/src/s_llrintl.c
index 82f4529dc815..afaea8b1c8b6 100644
--- a/lib/msun/src/s_llrintl.c
+++ b/lib/msun/src/s_llrintl.c
@@ -3,4 +3,9 @@
 #define dtype		long long
 #define	fn		llrintl
 
+#include <float.h>
 #include "s_lrint.c"
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(llrintl, llrintf128);
+#endif
diff --git a/lib/msun/src/s_llroundl.c b/lib/msun/src/s_llroundl.c
index 40cad84c56f5..8bb7d53a6920 100644
--- a/lib/msun/src/s_llroundl.c
+++ b/lib/msun/src/s_llroundl.c
@@ -5,4 +5,9 @@
 #define	DTYPE_MAX	LLONG_MAX
 #define	fn		llroundl
 
+#include <float.h>
 #include "s_lround.c"
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(llroundl, llroundf128);
+#endif
diff --git a/lib/msun/src/s_logbl.c b/lib/msun/src/s_logbl.c
index 1641dfb1a951..0ca1cf290871 100644
--- a/lib/msun/src/s_logbl.c
+++ b/lib/msun/src/s_logbl.c
@@ -48,3 +48,7 @@ logbl(long double x)
 	else						/* +/- inf or nan */
 		return (x * x);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(logbl, logbf128);
+#endif
diff --git a/lib/msun/src/s_lrintl.c b/lib/msun/src/s_lrintl.c
index 91614e8ad264..25761dce0fda 100644
--- a/lib/msun/src/s_lrintl.c
+++ b/lib/msun/src/s_lrintl.c
@@ -3,4 +3,9 @@
 #define dtype		long
 #define	fn		lrintl
 
+#include <float.h>
 #include "s_lrint.c"
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(lrintl, lrintf128);
+#endif
diff --git a/lib/msun/src/s_lroundl.c b/lib/msun/src/s_lroundl.c
index 57a2e90fc48e..064951e48ffd 100644
--- a/lib/msun/src/s_lroundl.c
+++ b/lib/msun/src/s_lroundl.c
@@ -5,4 +5,9 @@
 #define	DTYPE_MAX	LONG_MAX
 #define	fn		lroundl
 
+#include <float.h>
 #include "s_lround.c"
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(lroundl, lroundf128);
+#endif
diff --git a/lib/msun/src/s_modfl.c b/lib/msun/src/s_modfl.c
index 32470eba8dbd..856442a6030f 100644
--- a/lib/msun/src/s_modfl.c
+++ b/lib/msun/src/s_modfl.c
@@ -99,3 +99,7 @@ modfl(long double x, long double *iptr)
 		}
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(modfl, modff128);
+#endif
diff --git a/lib/msun/src/s_nearbyint.c b/lib/msun/src/s_nearbyint.c
index 6558ab0358b4..fa86d47f1007 100644
--- a/lib/msun/src/s_nearbyint.c
+++ b/lib/msun/src/s_nearbyint.c
@@ -28,6 +28,7 @@
 
 #include <fenv.h>
 #include <math.h>
+#include <float.h>
 
 #pragma STDC FENV_ACCESS ON
 
@@ -61,3 +62,7 @@ fn(type x)			\
 DECL(double, nearbyint, rint)
 DECL(float, nearbyintf, rintf)
 DECL(long double, nearbyintl, rintl)
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(nearbyintl, nearbyintf128);
+#endif
diff --git a/lib/msun/src/s_nextafterl.c b/lib/msun/src/s_nextafterl.c
index a73aabc9b6e1..65717aa461a8 100644
--- a/lib/msun/src/s_nextafterl.c
+++ b/lib/msun/src/s_nextafterl.c
@@ -72,3 +72,7 @@ nextafterl(long double x, long double y)
 }
 
 __strong_reference(nextafterl, nexttowardl);
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(nextafterl, nextafterf128);
+#endif
diff --git a/lib/msun/src/s_remquol.c b/lib/msun/src/s_remquol.c
index 0dadceaf5aa7..6d1c557e98d6 100644
--- a/lib/msun/src/s_remquol.c
+++ b/lib/msun/src/s_remquol.c
@@ -167,3 +167,7 @@ fixup:
 	*quo = (sxy ? -q : q);
 	return x;
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(remquol, remquof128);
+#endif
diff --git a/lib/msun/src/s_rintl.c b/lib/msun/src/s_rintl.c
index 72c9cabd1a91..412cd9626463 100644
--- a/lib/msun/src/s_rintl.c
+++ b/lib/msun/src/s_rintl.c
@@ -87,3 +87,7 @@ rintl(long double x)
 
 	return (x);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(rintl, rintf128);
+#endif
diff --git a/lib/msun/src/s_roundl.c b/lib/msun/src/s_roundl.c
index bc5dfe550165..1e49b020bc6b 100644
--- a/lib/msun/src/s_roundl.c
+++ b/lib/msun/src/s_roundl.c
@@ -59,3 +59,7 @@ roundl(long double x)
 		RETURNI(-t);
 	}
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(roundl, roundf128);
+#endif
diff --git a/lib/msun/src/s_scalbln.c b/lib/msun/src/s_scalbln.c
index 42e4669b3986..0a2ba365f148 100644
--- a/lib/msun/src/s_scalbln.c
+++ b/lib/msun/src/s_scalbln.c
@@ -27,6 +27,7 @@
  */
 
 #include <math.h>
+#include <float.h>
 
 #define	NMAX	65536
 #define	NMIN	-65536
@@ -51,3 +52,7 @@ scalblnl(long double x, long n)
 
 	return (scalbnl(x, (n > NMAX) ? NMAX : (n < NMIN) ? NMIN : (int)n));
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(scalblnl, scalblnf128);
+#endif
diff --git a/lib/msun/src/s_scalbnl.c b/lib/msun/src/s_scalbnl.c
index 6044c1b1d4f7..6d4906774c64 100644
--- a/lib/msun/src/s_scalbnl.c
+++ b/lib/msun/src/s_scalbnl.c
@@ -47,3 +47,8 @@ long double scalbnl(long double x, int n)
 __strong_reference(scalbnl, ldexpl);
 #endif
 
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(scalbnl, scalbnf128);
+__weak_reference(ldexpl, ldexpf128);
+#endif
diff --git a/lib/msun/src/s_sincosl.c b/lib/msun/src/s_sincosl.c
index 7fb69aa4d4dd..b992caf2d2f7 100644
--- a/lib/msun/src/s_sincosl.c
+++ b/lib/msun/src/s_sincosl.c
@@ -99,3 +99,7 @@ sincosl(long double x, long double *sn, long double *cs)
 
 	RETURNV();
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(sincosl, sincosf128);
+#endif
diff --git a/lib/msun/src/s_sinl.c b/lib/msun/src/s_sinl.c
index d0b7b34718f8..afbe0221addf 100644
--- a/lib/msun/src/s_sinl.c
+++ b/lib/msun/src/s_sinl.c
@@ -90,3 +90,7 @@ sinl(long double x)
 	
 	RETURNI(hi);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(sinl, sinf128);
+#endif
diff --git a/lib/msun/src/s_tanhl.c b/lib/msun/src/s_tanhl.c
index 3285b9afd0bd..bedb35a6e48d 100644
--- a/lib/msun/src/s_tanhl.c
+++ b/lib/msun/src/s_tanhl.c
@@ -168,3 +168,7 @@ tanhl(long double x)
 	if (jx<0) s = -1;
 	RETURNI(s*z);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(tanhl, tanhf128);
+#endif
diff --git a/lib/msun/src/s_tanl.c b/lib/msun/src/s_tanl.c
index 3736477922dc..2c25a3949f79 100644
--- a/lib/msun/src/s_tanl.c
+++ b/lib/msun/src/s_tanl.c
@@ -92,3 +92,7 @@ tanl(long double x)
 
 	RETURNI(hi);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(tanl, tanf128);
+#endif
diff --git a/lib/msun/src/s_truncl.c b/lib/msun/src/s_truncl.c
index 81e794d71b79..810183c12b4a 100644
--- a/lib/msun/src/s_truncl.c
+++ b/lib/msun/src/s_truncl.c
@@ -61,3 +61,7 @@ truncl(long double x)
 	}
 	return (u.e);
 }
+
+#if LDBL_MANT_DIG == 113
+__weak_reference(truncl, truncf128);
+#endif