This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
[PATCH] i386: Fix GCC running out of registers for bits/string.h
- From: "Maciej W. Rozycki" <macro at linux-mips dot org>
- To: libc-alpha at sources dot redhat dot com
- Cc: Jan-Benedict Glaw <jbglaw at lug-owl dot de>
- Date: Wed, 8 Jun 2005 19:12:06 +0100 (BST)
- Subject: [PATCH] i386: Fix GCC running out of registers for bits/string.h
Hello,
When building for the i386 as follows:
$ ../configure --prefix=/usr --enable-add-ons --enable-omitfp --build=i386-linux
$ make
using GCC 4.0.0 I have got the following error:
dcigettext.c: In function '_nl_find_msg':
../sysdeps/i386/bits/string.h:655: error: can't find a register in class 'GENERAL_REGS' while reloading 'asm'
for "dcigettext.os". I have looked at the failing function, which is
strcspn() in sysdeps/i386/bits/string.h and it attempts to reserve five
registers for an asm in this configuration. This leaves GCC with no free
registers in the general class as %esp is obviously unavailable, %ebx is
fixed for the GOT pointer, and %ebp is used for the frame pointer as the
calling function uses alloca(). Therefore the failure is justified and
that's a bug in glibc rather than a problem with GCC.
Rather than fixing just this single function I've looked through the file
and there are a few others trying to use five registers for an asm. They
are all going to fail or build depending on whether their caller uses
alloca() or not. An obvious fix follows.
2005-06-08 Maciej W. Rozycki <macro@linux-mips.org>
* sysdeps/i386/bits/string.h (strcspn): Use the general operand
constraint for __reject.
(strspn): Likewise for __accept.
(strpbrk): Likewise.
(strstr): Likewise for __needle.
Please apply to HEAD.
Maciej
glibc-2.3.5-i386-string.patch
diff -up --recursive --new-file glibc-2.3.5.macro/sysdeps/i386/bits/string.h glibc-2.3.5/sysdeps/i386/bits/string.h
--- glibc-2.3.5.macro/sysdeps/i386/bits/string.h 2004-06-15 20:11:53.000000000 +0000
+++ glibc-2.3.5/sysdeps/i386/bits/string.h 2005-06-02 00:02:01.000000000 +0000
@@ -671,7 +671,7 @@ strcspn (__const char *__s, __const char
"2:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "d" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
+ : "g" (__reject), "0" (__s), "1" (0), "2" (0xffffffff),
"m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
@@ -737,7 +737,7 @@ strspn (__const char *__s, __const char
"2:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
"m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return (__res - 1) - __s;
@@ -806,7 +806,7 @@ strpbrk (__const char *__s, __const char
"3:\n\t"
"popl %%ebx"
: "=&S" (__res), "=&a" (__d0), "=&c" (__d1), "=&D" (__d2)
- : "r" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
+ : "g" (__accept), "0" (__s), "1" (0), "2" (0xffffffff),
"m" ( *(struct { char __x[0xfffffff]; } *)__s)
: "cc");
return __res;
@@ -878,7 +878,7 @@ strstr (__const char *__haystack, __cons
"2:\n\t"
"popl %%ebx"
: "=&a" (__res), "=&c" (__d0), "=&S" (__d1), "=&D" (__d2)
- : "r" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
+ : "g" (__needle), "0" (0), "1" (0xffffffff), "2" (__haystack)
: "memory", "cc");
return __res;
}