Re: [PORTS] gcc 4.0 build failures on m68k, mips, and mipsel
Martin Pitt <[email protected]>
| Newsgroups | gmane.comp.db.postgresql.ports |
|---|---|
| Message-ID | <[email protected]> |
Hi again, Martin Pitt [2005-07-24 17:59 +0200]: > I noticed that PostgreSQL does not build any more with gcc 4.0 on > m68k, mips, and mipsel because of bugs/incompatibilities in > src/include/storage/s_lock.h. > [...] > However, since I don't have access to a mips/mipsel machine with gcc > 4.0, I was unable to fix the problem myself, so I just disabled > spinlocks on these two architectures in Debian for now (which sucks, > but at least the package builds and works). Does anybody here have a > MIPS machine and could try this? A better workaround than disabling spinlocks at all is to compile s_lock.c with -fno-unit-at-a-time (this is the default in gcc 4 and breaks it; that was the reason why it worked with gcc 3.3). However, Thiemo Seufer dealt with this and created a proper tas() function for PostgreSQL on mips, which also works with gcc 4. Of course this is much better, so I applied his patch in Debian. I attach the patch. Do you consider applying it upstream? Thanks and have a nice weekend, Martin -- Martin Pitt http://www.piware.de Ubuntu Developer http://www.ubuntu.com Debian Developer http://www.debian.org
14-mips-gcc4.patch
(text/plain, 1.6 KB)
diff -ruN postgresql-8.0.3-old/src/backend/storage/lmgr/s_lock.c postgresql-8.0.3/src/backend/storage/lmgr/s_lock.c
--- postgresql-8.0.3-old/src/backend/storage/lmgr/s_lock.c 2004-12-31 23:01:05.000000000 +0100
+++ postgresql-8.0.3/src/backend/storage/lmgr/s_lock.c 2005-08-20 17:32:15.000000000 +0200
@@ -172,7 +172,7 @@
#endif /* __m68k__ */
-#if defined(__mips__) && !defined(__sgi)
+#if defined(__mips__) && !defined(__sgi) && !defined(__linux__)
static void
tas_dummy()
{
diff -ruN postgresql-8.0.3-old/src/include/storage/s_lock.h postgresql-8.0.3/src/include/storage/s_lock.h
--- postgresql-8.0.3-old/src/include/storage/s_lock.h 2005-08-20 17:30:57.000000000 +0200
+++ postgresql-8.0.3/src/include/storage/s_lock.h 2005-08-20 17:32:15.000000000 +0200
@@ -367,6 +367,33 @@
#endif /* __vax__ */
+#if defined(__mips__) && defined(__linux__)
+#define TAS(lock) tas(lock)
+
+static __inline__ int
+tas(volatile slock_t *lock)
+{
+ register volatile slock_t *__l = lock;
+ register int __r;
+
+ __asm__ __volatile__(
+ " .set push \n"
+ " .set mips2 \n"
+ " .set noreorder \n"
+ " .set nomacro \n"
+ "1: ll %0, %1 \n"
+ " bne %0, $0, 1f \n"
+ " xori %0, 1 \n"
+ " sc %0, %1 \n"
+ " beq %0, $0, 1b \n"
+ " sync \n"
+ "1: .set pop "
+ : "=&r" (__r), "+R" (*__l));
+ return __r;
+}
+
+#endif /* mips */
+
#if defined(__ns32k__)
#define HAS_TEST_AND_SET
signature.asc
(application/pgp-signature, 189 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) iD8DBQFDB078DecnbV4Fd/IRAq0bAJoC/aQRTS1qH5PWiY8SlcMM31rRzACgj8Yi DEMo6sZDZOgd4AXWlJHkpxo= =k55h -----END PGP SIGNATURE-----