From 16e948781c5a7348f392ba2f26cb03b52fc60942 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Fri, 7 Jul 2000 01:23:44 +0000 Subject: [PATCH] |> 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? Andreas Schwab --- src/Makefile.shlib | 8 ++++---- src/interfaces/odbc/psqlodbc.c | 16 ++++++++++++++-- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/Makefile.shlib b/src/Makefile.shlib index 1f06d19388..467cfc18d7 100644 --- a/src/Makefile.shlib +++ b/src/Makefile.shlib @@ -6,7 +6,7 @@ # Copyright (c) 1998, Regents of the University of California # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.21 2000/06/28 18:29:13 petere Exp $ +# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.22 2000/07/07 01:23:43 momjian Exp $ # #------------------------------------------------------------------------- @@ -143,9 +143,9 @@ endif ifeq ($(PORTNAME), linux) 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 diff --git a/src/interfaces/odbc/psqlodbc.c b/src/interfaces/odbc/psqlodbc.c index 0df56ee1e7..a4598383fc 100644 --- a/src/interfaces/odbc/psqlodbc.c +++ b/src/interfaces/odbc/psqlodbc.c @@ -33,8 +33,6 @@ GLOBAL_VALUES globals; -BOOL _init(void); -BOOL _fini(void); RETCODE SQL_API SQLDummyOrdinal(void); #ifdef WIN32 @@ -97,6 +95,20 @@ WSADATA wsaData; #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. */