diff --git a/libgcc/gthr.h b/libgcc/gthr.h
index 31c404250b828331c323196725c54c999743f312..53a5f0f7458a115723cf123b4f746ab1c4bc2e4d 100644
--- a/libgcc/gthr.h
+++ b/libgcc/gthr.h
@@ -141,6 +141,15 @@ see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
 #define GTHREAD_USE_WEAK 0
 #endif
 
+#ifdef __GLIBC_PREREQ
+#if __GLIBC_PREREQ(2, 34)
+/* glibc 2.34 and later has all pthread_* APIs inside of libc,
+   no need to link separately with -lpthread.  */
+#undef GTHREAD_USE_WEAK
+#define GTHREAD_USE_WEAK 0
+#endif
+#endif
+
 #ifndef GTHREAD_USE_WEAK
 #define GTHREAD_USE_WEAK 1
 #endif