NetBSD Problem Report #10543

Received: (qmail 24600 invoked from network); 9 Jul 2000 00:08:56 -0000
Message-Id: <200007090009.UAA24654@tome.neutralgood.org>
Date: Sat, 8 Jul 2000 20:09:28 -0400 (EDT)
From: "Kevin P. Neal" <kpn@neutralgood.org>
Reply-To: kpn@neutralgood.org
To: gnats-bugs@gnats.netbsd.org
Subject: Minimal patches for PostgreSQL on the Alpha
X-Send-Pr-Version: 3.95

>Number:         10543
>Category:       port-alpha
>Synopsis:       Minimal patches for PostgreSQL on the Alpha
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-alpha-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Jul 09 00:09:00 +0000 2000
>Closed-Date:    Tue Jan 22 01:56:15 +0000 2002
>Last-Modified:  Tue Jan 22 01:56:15 +0000 2002
>Originator:     Kevin P. Neal
>Release:        1.4.1, PostgreSQL 6.5.3? 7? (sorry!)
>Organization:
-- 
Kevin P. Neal                                http://www.pobox.com/~kpn/

"You know, I think I can hear the machine screaming from here...  \
'help me! hellpp meeee!'"  - Heather Flanagan, 14:52:23 Wed Jun 10 1998
>Environment:
System: NetBSD tome.neutralgood.org 1.4.2 NetBSD 1.4.2 (TOME) #42: Fri Jun 2 23:24:20 EDT 2000 kpn@tome.neutralgood.org:/usr/src/sys/arch/alpha/compile/TOME alpha

>Description:
   PostgreSQL doesn't run on the Alpha. Here are my minimal patches to
get it limping along, but it is a long way from actually passing the
self tests. Basic "select * from foo where bar = quux" works.

I don't actually use PostgreSQL anymore (my e-commerce class ended),
but I don't want the patches to get lost. I sent them to the PostgreSQL
people, but last I heard they wanted an "Alpha guru" to .... heck, I 
don't know. 

They told me this, I claimed that my patches work, explained why, and
they subscribed me to pgsql-bugs (or something -- I haven't heard anything
from that list ever). I was also asked if I had a piece of code to
demonstrate the gcc problem. I haven't written one, but I might get around
to it one of these months as a diversion away from my regular work 
(currently, MVS prelinker goo).

>How-To-Repeat:
Try and get PostgreSQL running on NetBSD/Alpha. Notice that gcc
boogers up inlining of a function defined in a header with assembly
in an __asm__ block that uses two registers. The two registers used
(%0 and %1, which expand into whatever at the inline point) are
scheduled for other variables, and so something gets stomped. Blamo,
core dump. 

Oh, and notice that I also fix things so that slock_t is 32 bits in size
on the Alpha.

Sorry, I don't remember exactly which release of PostgreSQL this patch
set is for. It shouldn't matter much, really.

>Fix:
Apply these patches.


*** ./old/src/backend/main/main.c	Wed Jan 26 00:56:30 2000
--- ./new/src/backend/main/main.c	Fri Apr  7 22:19:30 2000
***************
*** 12,27 ****
--- 12,31 ----
   *
   *-------------------------------------------------------------------------
   */
  #include <unistd.h>

+ #if defined(__NetBSD__)
+ #include <sys/param.h>
+ #else
  #if defined(__alpha__) && !defined(linux)
  #include <sys/sysinfo.h>
  #include "machine/hal_sysinfo.h"
  #define ASSEMBLER
  #include <sys/proc.h>
  #undef ASSEMBLER
+ #endif
  #endif

  #include "postgres.h"
  #ifdef USE_LOCALE
  #include <locale.h>
*** ./old/src/include/port/netbsd.h	Tue Mar  7 20:58:23 2000
--- ./new/src/include/port/netbsd.h	Sun Apr  9 23:49:37 2000
***************
*** 1,43 ****
  #define USE_POSIX_TIME

  #if defined(__i386__)
  #define NEED_I386_TAS_ASM
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__sparc__)
  #define NEED_SPARC_TAS_ASM
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__vax__)
  #define NEED_VAX_TAS_ASM
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__ns32k__)
  #define NEED_NS32K_TAS_ASM
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__m68k__)
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__arm__)
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__mips__)
  /* #	undef HAS_TEST_AND_SET */
  #endif

! #if defined(__powerpc__)
  #define HAS_TEST_AND_SET
  #endif

  #if defined(__powerpc__)
  typedef unsigned int slock_t;
- #else
- typedef unsigned char slock_t;
  #endif
--- 1,50 ----
  #define USE_POSIX_TIME

  #if defined(__i386__)
  #define NEED_I386_TAS_ASM
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__sparc__)
  #define NEED_SPARC_TAS_ASM
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__vax__)
  #define NEED_VAX_TAS_ASM
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__ns32k__)
  #define NEED_NS32K_TAS_ASM
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__m68k__)
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__arm__)
  #define HAS_TEST_AND_SET
+ typedef unsigned char slock_t;
  #endif

  #if defined(__mips__)
  /* #	undef HAS_TEST_AND_SET */
+ typedef unsigned char slock_t;
  #endif

! #if defined(__alpha__)
  #define HAS_TEST_AND_SET
+ typedef unsigned long int slock_t;
  #endif

  #if defined(__powerpc__)
+ #define HAS_TEST_AND_SET
  typedef unsigned int slock_t;
  #endif
*** ./old/src/include/storage/s_lock.h	Wed Jan 26 00:58:33 2000
--- ./new/src/include/storage/s_lock.h	Sun Apr  9 23:56:46 2000
***************
*** 260,270 ****
--- 260,275 ----
  #else /* i.e. not __osf__ */

  #define TAS(lock) tas(lock)
  #define S_UNLOCK(lock) { __asm__("mb"); *(lock) = 0; }

+ #if defined(__GNUC__)
+ static int              /* GCC on the Alpha doesn't appear to handle
+                            inlining of assembly with %0 or %1 properly. */
+ #else
  static __inline__ int
+ #endif
  tas(volatile slock_t *lock)
  {
   register slock_t _res;

  __asm__("	 ldq   $0, %0			   \n\
>Release-Note:
>Audit-Trail:

From: "Johnny C. Lam" <lamj@stat.cmu.edu>
To: kpn@neutralgood.org
Cc: gnats-bugs@gnats.netbsd.org
Subject: Re: pkg/10543: Minimal patches for PostgreSQL on the Alpha 
Date: Sat, 22 Jul 2000 02:18:19 -0400

 "Kevin P. Neal" <kpn@neutralgood.org> writes:
 >    PostgreSQL doesn't run on the Alpha. Here are my minimal patches to
 > get it limping along, but it is a long way from actually passing the
 > self tests. Basic "select * from foo where bar = quux" works.

 Thank you for your patches.  I've added them to the PostgreSQL
 package.  I'm reassigning this PR to the "alpha" category since the
 part of the problem you describe which hasn't been dealt with is
 apparently a registers problem with GCC on the alpha.

      -- Johnny C. Lam <lamj@stat.cmu.edu>
         Department of Statistics, Carnegie Mellon University
         http://www.stat.cmu.edu/~lamj/


Responsible-Changed-From-To: pkg-manager->port-alpha-maintainer 
Responsible-Changed-By: jlam 
Responsible-Changed-When: Fri Jul 21 23:22:19 PDT 2000 
Responsible-Changed-Why:  
The pkgsrc patches have been applied, but the underlying problem with 
GCC optimatization on alpha reported by the author are still apparently 
still there.  The PR is now properly an bug on port-alpha. 
State-Changed-From-To: open->feedback 
State-Changed-By: ross 
State-Changed-When: Mon Jan 21 16:07:14 PST 2002 
State-Changed-Why:  
There isn't enough information in 10543 to reproduce the possible 
asm() problem, and we have updated our gcc version since this PR 
was filed. I will go ahead and build the pkg on alpha and take a 
look, but even if we had a fix are you able to test this? 
State-Changed-From-To: feedback->closed 
State-Changed-By: ross 
State-Changed-When: Mon Jan 21 17:55:31 PST 2002 
State-Changed-Why:  
checked with originator, closing it seems to be ok. (a different 
patch was applied, and the pkg does build on alpha now) 
>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.