diff --git a/math/Versions b/math/Versions
index 78dac9d165..2611a6872f 100644
--- a/math/Versions
+++ b/math/Versions
@@ -674,5 +674,6 @@ libm {
   GLIBC_2.42 {
     # No SVID compatible error handling.
     log10f;
+    lgammaf; lgammaf_r;
   }
 }
diff --git a/math/lgamma-compat.h b/math/lgamma-compat.h
index bf4acef559..f50bacce8f 100644
--- a/math/lgamma-compat.h
+++ b/math/lgamma-compat.h
@@ -34,10 +34,17 @@
    old glibc.
 
    Users of this file define USE_AS_COMPAT to 0 when building the main
-   version of lgamma, 1 when building the compatibility version.  */
+   version of lgamma, 1 when building the compatibility version that
+   handles signgam visibility, and 2 when building the compatibility
+   that handles SVID support).  */
 
+#if USE_AS_COMPAT <= 1
 #define LGAMMA_OLD_VER GLIBC_2_0
 #define LGAMMA_NEW_VER GLIBC_2_23
+#elif USE_AS_COMPAT == 2
+#define LGAMMA_OLD_VER    GLIBC_2_23
+#define LGAMMA_NEW_VER    GLIBC_2_42
+#endif
 #define HAVE_LGAMMA_COMPAT SHLIB_COMPAT (libm, LGAMMA_OLD_VER, LGAMMA_NEW_VER)
 
 /* Whether to build this version at all.  */
@@ -45,8 +52,10 @@
   (LIBM_SVID_COMPAT && (HAVE_LGAMMA_COMPAT || !USE_AS_COMPAT))
 
 /* The name to use for this version.  */
-#if USE_AS_COMPAT
+#if USE_AS_COMPAT == 1
 # define LGFUNC(FUNC) FUNC ## _compat
+#elif USE_AS_COMPAT == 2
+# define LGFUNC(FUNC) FUNC ## _compat2
 #else
 # define LGFUNC(FUNC) FUNC
 #endif
@@ -54,7 +63,7 @@
 /* If there is a compatibility version, gamma (not an ISO C function,
    so never a problem for it to set signgam) points directly to it
    rather than having separate versions.  */
-#define GAMMA_ALIAS (USE_AS_COMPAT ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT)
+#define GAMMA_ALIAS (USE_AS_COMPAT == 1 ? HAVE_LGAMMA_COMPAT : !HAVE_LGAMMA_COMPAT)
 
 /* How to call the underlying lgamma_r function.  */
 #define CALL_LGAMMA(TYPE, FUNC, ARG)			\
diff --git a/math/w_lgammaf_compat2.c b/math/w_lgammaf_compat2.c
index 5fc402260c..3a942dbe04 100644
--- a/math/w_lgammaf_compat2.c
+++ b/math/w_lgammaf_compat2.c
@@ -1,2 +1,2 @@
-#define USE_AS_COMPAT 0
+#define USE_AS_COMPAT 2
 #include <w_lgammaf_main.c>
diff --git a/math/w_lgammaf_main.c b/math/w_lgammaf_main.c
index 22b7f8fc53..8d475d3a6c 100644
--- a/math/w_lgammaf_main.c
+++ b/math/w_lgammaf_main.c
@@ -33,12 +33,7 @@ LGFUNC (__lgammaf) (float x)
 
 	return y;
 }
-# if USE_AS_COMPAT
-compat_symbol (libm, __lgammaf_compat, lgammaf, LGAMMA_OLD_VER);
-# else
-versioned_symbol (libm, __lgammaf, lgammaf, LGAMMA_NEW_VER);
-libm_alias_float_other (__lgamma, lgamma)
-# endif
+compat_symbol (libm, LGFUNC (__lgammaf), lgammaf, LGAMMA_OLD_VER);
 # if GAMMA_ALIAS
 strong_alias (LGFUNC (__lgammaf), __gammaf)
 weak_alias (__gammaf, gammaf)
diff --git a/sysdeps/ieee754/flt-32/e_lgammaf_r.c b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
index 75ec25fb9e..378ada14dd 100644
--- a/sysdeps/ieee754/flt-32/e_lgammaf_r.c
+++ b/sysdeps/ieee754/flt-32/e_lgammaf_r.c
@@ -36,6 +36,8 @@ SOFTWARE.
 #include <math.h>
 #include <libm-alias-finite.h>
 #include <limits.h>
+#include <libm-alias-float.h>
+#include <math-svid-compat.h>
 #include <math-narrow-eval.h>
 #include "math_config.h"
 
@@ -108,7 +110,7 @@ as_ln (double x)
 }
 
 float
-__ieee754_lgammaf_r (float x, int *signgamp)
+__lgamma_rf (float x, int *signgamp)
 {
   static const struct
   {
@@ -363,4 +365,10 @@ __ieee754_lgammaf_r (float x, int *signgamp)
     }
   return r;
 }
-libm_alias_finite (__ieee754_lgammaf_r, __lgammaf_r)
+strong_alias (__lgamma_rf, __ieee754_lgammaf_r)
+libm_alias_finite (__lgamma_rf, __lgammaf_r)
+#if LIBM_SVID_COMPAT
+versioned_symbol (libm, __lgamma_rf, lgammaf_r, GLIBC_2_42);
+#else
+libm_alias_float (__lgamma_r, lgamma_r)
+#endif
diff --git a/sysdeps/ieee754/flt-32/w_lgammaf.c b/sysdeps/ieee754/flt-32/w_lgammaf.c
new file mode 100644
index 0000000000..01ea82546a
--- /dev/null
+++ b/sysdeps/ieee754/flt-32/w_lgammaf.c
@@ -0,0 +1,17 @@
+#include <math-svid-compat.h>
+#include <math.h>
+#include <libm-alias-float.h>
+
+float
+__lgammaf (float x)
+{
+  return __lgammaf_r (x, &__signgam);
+}
+#if LIBM_SVID_COMPAT
+versioned_symbol (libm, __lgammaf, lgammaf, GLIBC_2_42);
+libm_alias_float_other (__lgamma, lgamma)
+#else
+libm_alias_float (__lgamma, lgamma)
+strong_alias (__lgammaf, __gammaf)
+weak_alias (__gammaf, gammaf)
+#endif
diff --git a/sysdeps/mach/hurd/i386/libm.abilist b/sysdeps/mach/hurd/i386/libm.abilist
index d7bb4cfa16..050722cb73 100644
--- a/sysdeps/mach/hurd/i386/libm.abilist
+++ b/sysdeps/mach/hurd/i386/libm.abilist
@@ -1277,4 +1277,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/aarch64/libm.abilist b/sysdeps/unix/sysv/linux/aarch64/libm.abilist
index f4c1c78ef0..41bd47abeb 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/aarch64/libm.abilist
@@ -1245,4 +1245,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/alpha/libm.abilist b/sysdeps/unix/sysv/linux/alpha/libm.abilist
index 787599b70d..02a85f4998 100644
--- a/sysdeps/unix/sysv/linux/alpha/libm.abilist
+++ b/sysdeps/unix/sysv/linux/alpha/libm.abilist
@@ -1404,4 +1404,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/arm/be/libm.abilist b/sysdeps/unix/sysv/linux/arm/be/libm.abilist
index eb1b81eccf..5b0eabbc7c 100644
--- a/sysdeps/unix/sysv/linux/arm/be/libm.abilist
+++ b/sysdeps/unix/sysv/linux/arm/be/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/arm/le/libm.abilist b/sysdeps/unix/sysv/linux/arm/le/libm.abilist
index eb1b81eccf..5b0eabbc7c 100644
--- a/sysdeps/unix/sysv/linux/arm/le/libm.abilist
+++ b/sysdeps/unix/sysv/linux/arm/le/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/hppa/libm.abilist b/sysdeps/unix/sysv/linux/hppa/libm.abilist
index 8a5c1c5b86..6efb2e5e83 100644
--- a/sysdeps/unix/sysv/linux/hppa/libm.abilist
+++ b/sysdeps/unix/sysv/linux/hppa/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/i386/libm.abilist b/sysdeps/unix/sysv/linux/i386/libm.abilist
index c4d074dfdc..4b277fa849 100644
--- a/sysdeps/unix/sysv/linux/i386/libm.abilist
+++ b/sysdeps/unix/sysv/linux/i386/libm.abilist
@@ -1284,4 +1284,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
index eb1b81eccf..5b0eabbc7c 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
index c3c23fd02d..197e85b7bb 100644
--- a/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
+++ b/sysdeps/unix/sysv/linux/m68k/m680x0/libm.abilist
@@ -956,3 +956,5 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
diff --git a/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist b/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist
index 2b768e5376..dad4910e3b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/be/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist b/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist
index 2b768e5376..dad4910e3b 100644
--- a/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist
+++ b/sysdeps/unix/sysv/linux/microblaze/le/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
index 52f526d732..2435460eef 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips32/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
index af762481aa..d1fe3c91ea 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/mips/mips64/libm.abilist
@@ -1245,4 +1245,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
index deeba94b9c..d46ae7cef1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libm.abilist
@@ -1067,4 +1067,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
index d13d81cc13..e90314df44 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libm.abilist
@@ -1066,4 +1066,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libm.abilist
index abc30421a5..9e84016a29 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/be/libm.abilist
@@ -1060,4 +1060,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
index ea38df2a87..685cad8e2c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/le/libm.abilist
@@ -1429,4 +1429,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist b/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
index 1ed2a31928..0c5b2d0aaf 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/libm.abilist
@@ -1348,4 +1348,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist b/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
index acd20230a2..be929adce1 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/libm.abilist
@@ -1348,4 +1348,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/sh/be/libm.abilist b/sysdeps/unix/sysv/linux/sh/be/libm.abilist
index 7b228e449a..bb3dcaebf7 100644
--- a/sysdeps/unix/sysv/linux/sh/be/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sh/be/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/sh/le/libm.abilist b/sysdeps/unix/sysv/linux/sh/le/libm.abilist
index 7b228e449a..bb3dcaebf7 100644
--- a/sysdeps/unix/sysv/linux/sh/le/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sh/le/libm.abilist
@@ -920,4 +920,6 @@ GLIBC_2.41 tanpif32 F
 GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
index 1e7f7309c6..ff5f932ddf 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc32/libm.abilist
@@ -1355,4 +1355,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist b/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
index ae1f040772..052a0012fe 100644
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/libm.abilist
@@ -1245,4 +1245,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist b/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
index c5b759ad37..0794c4ad52 100644
--- a/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/64/libm.abilist
@@ -1278,4 +1278,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist b/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
index 3f4be241db..19ffca6af2 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/libm.abilist
@@ -1278,4 +1278,6 @@ GLIBC_2.41 tanpif32x F
 GLIBC_2.41 tanpif64 F
 GLIBC_2.41 tanpif64x F
 GLIBC_2.41 tanpil F
+GLIBC_2.42 lgammaf F
+GLIBC_2.42 lgammaf_r F
 GLIBC_2.42 log10f F
