[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Seeking help with porting postgresql+gcc 4 to MIPS

On Mon, Aug 15, 2005 at 05:32:48PM +0200, Martin Pitt wrote:
> Hi MIPS porters!

> postgresql-7.4 and -8.0 built fine with gcc-3.3, but since the gcc 4
> switch, they constantly fail on mips and mipsel:
> http://buildd.debian.org/fetch.php?&pkg=postgresql-7.4&ver=1%3A7.4.8-14&arch=mips&stamp=1122629954&file=log&as=raw
> cc -g -Wall -O2 -fno-strict-aliasing -g -Wall -Wmissing-prototypes -Wmissing-declarations -L../../src/port  -Wl,-E access/SUBSYS.o bootstrap/SUBSYS.o catalog/SUBSYS.o parser/SUBSYS.o commands/SUBSYS.o executor/SUBSYS.o lib/SUBSYS.o libpq/SUBSYS.o main/SUBSYS.o nodes/SUBSYS.o optimizer/SUBSYS.o port/SUBSYS.o postmaster/SUBSYS.o regex/SUBSYS.o rewrite/SUBSYS.o storage/SUBSYS.o tcop/SUBSYS.o utils/SUBSYS.o -lpam -lssl -lcrypto -lkrb5 -lz -lreadline -lcrypt -lresolv -lnsl -ldl -lm  -lpgport -o postgres
> access/SUBSYS.o: In function `GetRedoRecPtr':
> /build/buildd/postgresql-7.4-7.4.8/build-tree/postgresql-7.4.8/src/backend/access/transam/xlog.c:3075: undefined reference to `tas'
> tas() defines test-and-set for implementing spinlocks efficiently, and
> is arch specific. I tried to debug this on casals and vaughan, but
> neither host has the postgresql-7.4 build deps installed in the sid
> dchroot, and thus I didn't come very far. The definition of the
> symbols __mips__ and __sgi (which are tested in s_lock.c) hasn't
> changed between 3.3 and 4.0, so this seems to be really tricky.
> In a followup upload I tried to disable spinlocks entirely; this
> helped for postgresql-8.0, so that this will be slow as hell on mips,
> but at least it built. However, it didn't help with 7.4, it is still
> Is anybody of you interested in helping me to fix this? Installing the
> -7.4 and 8.0 build dependencies would probably be enough for me to
> debug this myself. However, any further help from you is of course
> highly appreciated. :-)
As I am only a Debian developer with a mips machine, I can't install
those packages. However, I have found the problem from postgresql-7.4.
You will find attached a patch to fix it. Basically the problems comes
from the -funit-at-a-time option which is now enabled by default by gcc
with the -O2 option. Here is a part of the manpage:

      Parse the whole compilation unit before starting to produce code.  This
      allows some extra optimizations to take place but consumes more memory (in
      general).  There are some compatibility issues with unit-at-at-time mode:

      *   enabling unit-at-a-time mode may change the order in which functions,
          variables, and top-level "asm" statements are emitted, and will likely
          break code relying on some particular ordering.  The majority of such
          top-level "asm" statements, though, can be replaced by "section"
      *   unit-at-a-time mode removes unreferenced static variables and functions
          are removed.  This may result in undefined references when an "asm"
          statement refers directly to variables or functions that are otherwise
          unused.  In that case either the variable/function shall be listed as an
          operand of the "asm" statement operand or, in the case of top-level
          "asm" statements the attribute "used" shall be used on the declaration.

      *   Static functions now can use non-standard passing conventions that may 
          break "asm" statements calling functions directly. Again, attribute
          "used" will prevent this behavior.

My patch fixes that by passing the -fno-unit-at-a-time option when 
building s_lock.c. A proper fix would be to write inline code that will
go to s_lock.h, but I don't have enough knowledge in the mips assembly
to write such a code.

For postgresql-8.0, I suppose the problem is the same, I'll have a look

> Another issue: postgresql-8.0 8.0.3-12 is built on mips for days now,
> but the buildd doesn't upload it. This blocks the testing migration
> and I don't want to do another upload before the current version is in
> Etch. Any idea what causes this?

Again, as a simple developer, I can't have a look at that. The only thing 
I could do is build it and upload it.


  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian GNU/Linux developer | Electrical Engineer
 `. `'   aurel32@debian.org         | aurelien@aurel32.net
   `-    people.debian.org/~aurel32 | www.aurel32.net
diff -u postgresql-7.4-7.4.8/debian/control postgresql-7.4-7.4.8/debian/control
--- postgresql-7.4-7.4.8/debian/control
+++ postgresql-7.4-7.4.8/debian/control
@@ -4,7 +4,7 @@
 Maintainer: Martin Pitt <mpitt@debian.org>
 Uploaders: Oliver Elphick <Oliver.Elphick@lfix.co.uk>
 Standards-Version: 3.6.2
-Build-Depends: debhelper (>= 4.1.46), cdbs, bison, perl (>= 5.8), libperl-dev, tk8.4-dev, flex, libreadline5-dev (>= 4.2), libssl-dev, zlib1g-dev | libz-dev, libpam0g-dev | libpam-dev, libxml2-dev, libkrb5-dev, python-dev, gettext, bzip2, gcc-3.3 [mipsel mips]
+Build-Depends: debhelper (>= 4.1.46), cdbs, bison, perl (>= 5.8), libperl-dev, tk8.4-dev, flex, libreadline5-dev (>= 4.2), libssl-dev, zlib1g-dev | libz-dev, libpam0g-dev | libpam-dev, libxml2-dev, libkrb5-dev, python-dev, gettext, bzip2
 Package: postgresql-7.4
 Architecture: any
diff -u postgresql-7.4-7.4.8/debian/rules postgresql-7.4-7.4.8/debian/rules
--- postgresql-7.4-7.4.8/debian/rules
+++ postgresql-7.4-7.4.8/debian/rules
@@ -7,15 +7,6 @@
 include /usr/share/cdbs/1/class/autotools.mk
 include /usr/share/cdbs/1/rules/debhelper.mk
-# spinlocks don't compile with gcc-4.0 on mips[el]
-ifeq ($(DEB_BUILD_ARCH),mips)
-    ARCH_OPTS+= CC=gcc-3.3
-ifeq ($(DEB_BUILD_ARCH),mipsel)
-    ARCH_OPTS+= CC=gcc-3.3
                     --build=$(DEB_BUILD_GNU_TYPE) \
--- postgresql-7.4-7.4.8.orig/debian/patches/37_gcc-4.0_asm.patch
+++ postgresql-7.4-7.4.8/debian/patches/37_gcc-4.0_asm.patch
@@ -0,0 +1,12 @@
+--- postgresql-7.4.8.orig/src/backend/storage/lmgr/Makefile	2001-09-29 04:02:24.000000000 +0000
++++ postgresql-7.4.8/src/backend/storage/lmgrMakefile	2005-08-17 18:54:50.000000000 +0000
+@@ -19,6 +19,9 @@
++s_lock.o: s_lock.c
++	$(CC) $(CPPFLAGS) $(CFLAGS) -fno-unit-at-a-time -c -o s_lock.o s_lock.c
+ s_lock_test: s_lock.c
+ 	$(CC) $(CPPFLAGS) $(CFLAGS) -DS_LOCK_TEST=1 s_lock.c -o s_lock_test
+ 	./s_lock_test

Reply to: