Thread: Patch for Linux-IA64
Hi, attached to this mail is a patch from a colleague that makes PostgreSQL-7.0.2 run on Linux for the Intel-IA64 architecture. It also fixes a bug in the configure scripts that caused configure to fail on the fcntl(F_SETLK) test. This fix triggered a bug in the fcntl(F_SETLK) code of the Linux kernel when used on unix domain sockets resulting in postmaster to segfault immediately after startup. There is a fix available and included in the kernel that will be on SuSE Linux 7.0, but kernels <= 2.2.16 still have this bug. Therefore we decided to disable the calls to fcntl(F_SETLK) in src/backend/libpq/pqcomm.c as workarround for the PostgreSQL RPMs for SuSE Linux which I am currently working on. The patch (hack) doing this is also included. Regards, Reinhard Max -- If you put garbage in a computer nothing comes out but garbage. But this garbage, having passed through a very expensive machine, is somehow enobled and none dare criticize it.
Attachment
OK, I have applied part of this patch. I skipped the changes to Makefile.shlib, and the hack to disable flock in pqcomm.c. By the time this code is released in 7.1, hopefully the Linux kernel will be fixed. The Makefile.shlib changes will have to be discussed with other Linux developers so we are sure it will work on all platforms. I am attaching the part of the patch that I applied. Thanks. > Hi, > > attached to this mail is a patch from a colleague that makes > PostgreSQL-7.0.2 run on Linux for the Intel-IA64 architecture. It also > fixes a bug in the configure scripts that caused configure to fail on > the fcntl(F_SETLK) test. > > This fix triggered a bug in the fcntl(F_SETLK) code of the Linux > kernel when used on unix domain sockets resulting in postmaster to > segfault immediately after startup. There is a fix available and > included in the kernel that will be on SuSE Linux 7.0, but kernels <= > 2.2.16 still have this bug. > > Therefore we decided to disable the calls to fcntl(F_SETLK) in > src/backend/libpq/pqcomm.c as workarround for the PostgreSQL RPMs for > SuSE Linux which I am currently working on. The patch (hack) doing > this is also included. > > Regards, > > Reinhard Max > -- > If you put garbage in a computer nothing comes out but garbage. > But this garbage, having passed through a very expensive machine, > is somehow enobled and none dare criticize it. Content-Description: Patch for IA64 -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026 --- configure.in +++ configure.in 2000/06/20 09:17:54 @@ -786,7 +786,8 @@ AC_MSG_RESULT(no)) AC_MSG_CHECKING(for fcntl(F_SETLK)) -AC_TRY_LINK([#include <fcntl.h>], +AC_TRY_LINK([#include <stdio.h> +#include <fcntl.h>], [struct flock lck; lck.l_whence = SEEK_SET; lck.l_start = lck.l_len = 0; lck.l_type = F_WRLCK; --- src/include/port/linux.h +++ src/include/port/linux.h 2000/06/20 09:35:00 @@ -33,7 +33,12 @@ #define HAS_TEST_AND_SET #elif defined(__arm__) -typedef unsigned char slock_t +typedef unsigned char slock_t; + +#define HAS_TEST_AND_SET + +#elif defined(__ia64__) +typedef unsigned int slock_t; #define HAS_TEST_AND_SET --- src/include/storage/s_lock.h +++ src/include/storage/s_lock.h 2000/06/20 09:40:50 @@ -95,6 +95,24 @@ #endif /* __i386__ */ +#ifdef __ia64__ +#define TAS(lock) tas(lock) + +static __inline__ int +tas (volatile slock_t *lock) +{ + long int ret; + + __asm__ __volatile__( + "xchg4 %0=%1,%2" + : "=r"(ret), "=m"(*lock) + : "r"(1), "1"(*lock) + : "memory"); + + return (int) ret; +} +#endif /* __ia64__ */ + #if defined(__arm__) || defined(__arm__) #define TAS(lock) tas(lock)
Bruce Momjian <pgman@candle.pha.pa.us> writes: |> The Makefile.shlib changes will have to be discussed with other Linux |> developers so we are sure it will work on all platforms. The problem with the current settings is that the linker is called directly. This is wrong, it should always be called through the compiler driver (the only exception is `ld -r'). This will make sure that the necessary libraries like libgcc are linked in. But there is still a different problem with the setting of LDFLAGS_ODBC. The psqlodbc module defines the functions _init and _fini which are reserved for the shared library initialisation. These should be changed to constructor functions. Then LDFLAGS_ODBC can be changed to be just `-lm'. Btw, why does it use -Bsymbolic? Here is a patch to implement this: --- src/Makefile.shlib +++ src/Makefile.shlib 2000/07/05 16:51:27 @@ -145,9 +145,9 @@ ifeq ($(PORTNAME), linux) install-shlib-dep := install-shlib shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) - LDFLAGS_SL := -Bdynamic -shared -soname $(shlib) - LDFLAGS_ODBC := -Bsymbolic -lc -lm - SHLIB_LINK += -lc + LD := $(CC) + LDFLAGS_SL := -shared -Wl,-soname,$(shlib) + LDFLAGS_ODBC := -lm CFLAGS += $(CFLAGS_SL) endif --- src/interfaces/odbc/psqlodbc.c +++ src/interfaces/odbc/psqlodbc.c 2000/07/06 10:01:04 @@ -33,8 +33,6 @@ GLOBAL_VALUES globals; -BOOL _init(void); -BOOL _fini(void); RETCODE SQL_API SQLDummyOrdinal(void); #ifdef WIN32 @@ -96,6 +94,20 @@ #ifndef FALSE #define FALSE (BOOL)0 #endif + +#ifdef __GNUC__ + +/* This function is called at library initialization time. */ + +static BOOL +__attribute__((constructor)) +init(void) +{ + getGlobalDefaults(DBMS_NAME, ODBCINST_INI, FALSE); + return TRUE; +} + +#else /* These two functions do shared library initialziation on UNIX, well at least * on Linux. I don't know about other systems. Andreas. -- Andreas Schwab "And now for something SuSE Labs completely different." Andreas.Schwab@suse.de SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
Applied. Thanks. [ Charset ISO-8859-1 unsupported, converting... ] > Bruce Momjian <pgman@candle.pha.pa.us> writes: > > |> The Makefile.shlib changes will have to be discussed with other Linux > |> developers so we are sure it will work on all platforms. > > The problem with the current settings is that the linker is called > directly. This is wrong, it should always be called through the compiler > driver (the only exception is `ld -r'). This will make sure that the > necessary libraries like libgcc are linked in. > > But there is still a different problem with the setting of LDFLAGS_ODBC. > The psqlodbc module defines the functions _init and _fini which are > reserved for the shared library initialisation. These should be changed > to constructor functions. Then LDFLAGS_ODBC can be changed to be just > `-lm'. Btw, why does it use -Bsymbolic? > > Here is a patch to implement this: > > --- src/Makefile.shlib > +++ src/Makefile.shlib 2000/07/05 16:51:27 > @@ -145,9 +145,9 @@ > ifeq ($(PORTNAME), linux) > install-shlib-dep := install-shlib > shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION) > - LDFLAGS_SL := -Bdynamic -shared -soname $(shlib) > - LDFLAGS_ODBC := -Bsymbolic -lc -lm > - SHLIB_LINK += -lc > + LD := $(CC) > + LDFLAGS_SL := -shared -Wl,-soname,$(shlib) > + LDFLAGS_ODBC := -lm > CFLAGS += $(CFLAGS_SL) > endif > > --- src/interfaces/odbc/psqlodbc.c > +++ src/interfaces/odbc/psqlodbc.c 2000/07/06 10:01:04 > @@ -33,8 +33,6 @@ > > GLOBAL_VALUES globals; > > -BOOL _init(void); > -BOOL _fini(void); > RETCODE SQL_API SQLDummyOrdinal(void); > > #ifdef WIN32 > @@ -96,6 +94,20 @@ > #ifndef FALSE > #define FALSE (BOOL)0 > #endif > + > +#ifdef __GNUC__ > + > +/* This function is called at library initialization time. */ > + > +static BOOL > +__attribute__((constructor)) > +init(void) > +{ > + getGlobalDefaults(DBMS_NAME, ODBCINST_INI, FALSE); > + return TRUE; > +} > + > +#else > > /* These two functions do shared library initialziation on UNIX, well at least > * on Linux. I don't know about other systems. > > Andreas. > > -- > Andreas Schwab "And now for something > SuSE Labs completely different." > Andreas.Schwab@suse.de > SuSE GmbH, Schanz?ckerstr. 10, D-90443 N?rnberg > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026