Skip to content

Commit 16e9487

Browse files
committed
|> 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
1 parent d800532 commit 16e9487

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/Makefile.shlib

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
# Copyright (c) 1998, Regents of the University of California
77
#
88
# IDENTIFICATION
9-
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.21 2000/06/28 18:29:13 petere Exp $
9+
# $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.22 2000/07/07 01:23:43 momjian Exp $
1010
#
1111
#-------------------------------------------------------------------------
1212

@@ -143,9 +143,9 @@ endif
143143

144144
ifeq ($(PORTNAME), linux)
145145
shlib := lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION).$(SO_MINOR_VERSION)
146-
LDFLAGS_SL := -Bdynamic -shared -soname $(shlib)
147-
LDFLAGS_ODBC := -Bsymbolic -lc -lm
148-
SHLIB_LINK += -lc
146+
LD := $(CC)
147+
LDFLAGS_SL := -shared -Wl,-soname,$(shlib)
148+
LDFLAGS_ODBC := -lm
149149
CFLAGS += $(CFLAGS_SL)
150150
endif
151151

src/interfaces/odbc/psqlodbc.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@
3333

3434
GLOBAL_VALUES globals;
3535

36-
BOOL _init(void);
37-
BOOL _fini(void);
3836
RETCODE SQL_API SQLDummyOrdinal(void);
3937

4038
#ifdef WIN32
@@ -97,6 +95,20 @@ WSADATA wsaData;
9795
#define FALSE (BOOL)0
9896
#endif
9997

98+
#ifdef __GNUC__
99+
100+
/* This function is called at library initialization time. */
101+
102+
static BOOL
103+
__attribute__((constructor))
104+
init(void)
105+
{
106+
getGlobalDefaults(DBMS_NAME, ODBCINST_INI, FALSE);
107+
return TRUE;
108+
}
109+
110+
#else
111+
100112
/* These two functions do shared library initialziation on UNIX, well at least
101113
* on Linux. I don't know about other systems.
102114
*/

0 commit comments

Comments
 (0)