Re: [PATCHES] Patch for Linux-IA64

From: Andreas Schwab <schwab(at)suse(dot)de>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Reinhard Max <max(at)suse(dot)de>, pgsql-bugs(at)postgresql(dot)org, pgsql-patches(at)postgresql(dot)org
Subject: Re: [PATCHES] Patch for Linux-IA64
Date: 2000-07-06 10:02:55
Message-ID: 200007061002.MAA20318@hawking.suse.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)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(dot)Schwab(at)suse(dot)de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Jan Ehrhardt 2000-07-06 12:35:31 Bug??: getattproperties fails !!
Previous Message Tom Lane 2000-07-06 07:18:59 Re: upper() problem in 7.0.2

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2000-07-07 01:23:28 Re: [PATCHES] Patch for Linux-IA64
Previous Message Tom Lane 2000-07-05 22:33:28 Re: Re: fix residual space in memory block