Index: lib/System/Unix/Unix.h
===================================================================
--- lib/System/Unix/Unix.h	(revision 73341)
+++ lib/System/Unix/Unix.h	(working copy)
@@ -83,8 +83,19 @@
     errnum = errno;
 #ifdef HAVE_STRERROR_R
   // strerror_r is thread-safe.
-  if (errnum)
+  if (errnum) {
+# ifndef _GNU_SOURCE
     strerror_r(errnum,buffer,MAXPATHLEN-1);
+# else
+    // glibc defines its own incompatible version of strerror_r
+    // which may not use the buffer supplied.
+    char *str = strerror_r(errnum,buffer,MAXPATHLEN-1);
+    if (str != buffer) {
+      strncpy(buffer,str,MAXPATHLEN-1);
+      buffer[MAXPATHLEN-1] = 0;
+    }
+# endif
+  }
 #elif HAVE_STRERROR
   // Copy the thread un-safe result of strerror into
   // the buffer as fast as possible to minimize impact
