From 33a6b67b517e55908fa8ad96d5e8a3aaac5c751d Mon Sep 17 00:00:00 2001
From: Bruce Momjian <bruce@momjian.us>
Date: Wed, 9 Oct 2002 16:21:54 +0000
Subject: [PATCH] > > > > and mb conversions (pg_ascii2mic and pg_mic2ascii not
 > > > > found in the postmaster and not included from elsewhere) > > > >
 shared libs on AIX need to be able to resolve all symbols at linkage time. >
 > Those two symbols are in backend/utils/SUBSYS.o but not in the postgres > >
 executable. > > They are defined in backend/utils/mb/conv.c and declared in >
 include/mb/pg_wchar.h.  They're also linked into the > postmaster.  I don't
 see anything unusual.

Attached is a patch to fix the mb linking problems on AIX. As a nice side effect

it reduces the duplicate symbol warnings to linking libpq.so and libecpg.so
(all shlibs that are not postmaster loadable modules).

Please apply to current (only affects AIX).

The _LARGE_FILES problem is unfortunately still open, unless Peter
has fixed it per his recent idea.

Zeugswetter Andreas SB SD
---
 doc/FAQ_AIX                        |  5 ++++-
 src/Makefile.shlib                 |  8 ++++----
 src/backend/Makefile               | 21 ++++++++++++++++++++-
 src/backend/port/aix/mkldexport.sh |  2 +-
 src/makefiles/Makefile.aix         | 23 +++++------------------
 5 files changed, 34 insertions(+), 25 deletions(-)

diff --git a/doc/FAQ_AIX b/doc/FAQ_AIX
index 74a1fd57688..8d6d346ed8b 100644
--- a/doc/FAQ_AIX
+++ b/doc/FAQ_AIX
@@ -1,5 +1,5 @@
 From: Zeugswetter Andreas <ZeugswetterA@spardat.at>
-Fri Feb  1 17:24:51 NFT 2002
+Fri Sep 27 12:33:36 MSZ 2002
 
 On AIX 4.3.2 PostgreSQL compiled with the native IBM compiler xlc 
 (vac.C 5.0.1) passes all regression tests.
@@ -22,6 +22,9 @@ which you can safely ignore.
 Compiling PostgreSQL with gcc (2.95.3) on AIX also works.
 Use the configure flags: --with-CC=gcc
 
+You need libm.a that is in the fileset bos.adt.libm (try following command)
+$ lslpp -l bos.adt.libm
+
 Since the mktime() function does not work on AIX for dates before
 1970, all localtime formatted datetimes will not use summer time for
 dates before 1970.
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index bf746a46338..eaf341855f7 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.64 2002/09/05 18:28:46 petere Exp $
+#    $Header: /cvsroot/pgsql/src/Makefile.shlib,v 1.65 2002/10/09 16:21:54 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -77,7 +77,7 @@ soname = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
 
 ifeq ($(PORTNAME), aix)
   shlib			:= lib$(NAME)$(DLSUFFIX)
-  SHLIB_LINK		+= -lc
+#   SHLIB_LINK		+= -lc
 endif
 
 ifeq ($(PORTNAME), darwin)
@@ -267,8 +267,8 @@ else # PORTNAME == aix
 # AIX case
 $(shlib): lib$(NAME).a
 	$(MKLDEXPORT) lib$(NAME).a > lib$(NAME)$(EXPSUFF)
-	$(COMPILER) -Wl,-H512 -Wl,-bM:SRE -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:lib$(NAME)$(EXPSUFF) -o $@ $< $(LDFLAGS) $(SHLIB_LINK) $(LDFLAGS_SL) -Wl,-bnoentry
-
+	$(COMPILER) $(LDFLAGS_SL) -o $@ $< $(LDFLAGS) $(SHLIB_LINK) -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:lib$(NAME)$(EXPSUFF)
+	
 endif # PORTNAME == aix
 
 else # PORTNAME == win
diff --git a/src/backend/Makefile b/src/backend/Makefile
index df445615ae0..5cdfecac543 100644
--- a/src/backend/Makefile
+++ b/src/backend/Makefile
@@ -4,7 +4,7 @@
 #
 # Copyright (c) 1994, Regents of the University of California
 #
-# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.87 2002/09/05 18:28:46 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/Makefile,v 1.88 2002/10/09 16:21:54 momjian Exp $
 #
 #-------------------------------------------------------------------------
 
@@ -53,6 +53,25 @@ libpostgres.a: postgres.def
 
 endif # win
 
+ifeq ($(PORTNAME), aix)
+
+postgres: $(POSTGRES_IMP)
+	$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -Wl,-bE:$(top_builddir)/src/backend/$(POSTGRES_IMP) $(LIBS) -o $@
+
+$(POSTGRES_IMP): $(OBJS)
+	$(LD) $(LDREL) $(LDOUT) SUBSYS.o $^
+ifeq ($(host_os), aix3.2.5)
+	$(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
+else
+ifneq (,$(findstring aix4.1, $(host_os)))
+	$(MKLDEXPORT) SUBSYS.o $(bindir)/postgres > $@
+else
+	$(MKLDEXPORT) SUBSYS.o . > $@
+endif
+endif
+	@rm -f SUBSYS.o
+
+endif # aix
 
 # Parallel make trickery
 $(OBJS): $(DIRS:%=%-recursive) ;
diff --git a/src/backend/port/aix/mkldexport.sh b/src/backend/port/aix/mkldexport.sh
index ccf09887393..5eca61be605 100755
--- a/src/backend/port/aix/mkldexport.sh
+++ b/src/backend/port/aix/mkldexport.sh
@@ -47,7 +47,7 @@ else
 		# for the base executable (AIX 4.2 and up)
 		echo '#! .'
 	else
-		echo '#!' $2/$OBJNAME
+		echo '#!' $2
 	fi
 fi
 $NM -BCg $1 | \
diff --git a/src/makefiles/Makefile.aix b/src/makefiles/Makefile.aix
index 0044a8f3ca2..bb0c2fd58b8 100644
--- a/src/makefiles/Makefile.aix
+++ b/src/makefiles/Makefile.aix
@@ -7,12 +7,12 @@ MK_NO_LORDER= true
 AROPT = crs
 
 DLSUFFIX = .so
-ifneq ($(GCC), yes)
 ifeq ($(host_os), aix3.2.5)
-	LDFLAGS_SL = -e _nostart
-else
-	LDFLAGS_SL = -bnoentry
+ifneq ($(GCC), yes)
+	LDFLAGS_SL = -e _nostart -H512 -bM:SRE
 endif
+else
+	LDFLAGS_SL = -Wl,-bnoentry -Wl,-H512 -Wl,-bM:SRE
 endif
 
 
@@ -23,24 +23,11 @@ POSTGRES_IMP= postgres$(IMPSUFF)
 
 MKLDEXPORT=$(top_srcdir)/src/backend/port/aix/mkldexport.sh
 
-$(POSTGRES_IMP):
-	@echo Making $@
-ifeq ($(host_os), aix3.2.5)
-	$(MKLDEXPORT) postgres $(bindir) > $@
-else
-ifneq (,$(findstring aix4.1, $(host_os)))
-	$(MKLDEXPORT) postgres $(bindir) > $@
-else
-	$(MKLDEXPORT) postgres . > $@
-endif
-endif
-	$(CC) -Wl,-bE:$(top_builddir)/src/backend/$@ -o postgres $(OBJS) $(LDFLAGS) $(LIBS)
-
 %$(EXPSUFF): %.o
 	$(MKLDEXPORT) $*.o > $*$(EXPSUFF)
 
 %$(DLSUFFIX): %.o %$(EXPSUFF)
 	@echo Making shared library $@ from $*.o, $*$(EXPSUFF) and postgres.imp
-	$(CC) -Wl,-H512 -Wl,-bM:SRE -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:$*$(EXPSUFF) -o $@ $*.o $(LDFLAGS) $(LIBS) $(LDFLAGS_SL)
+	$(CC) $(LDFLAGS) $(LDFLAGS_SL) -o $@ $*.o -Wl,-bI:$(top_builddir)/src/backend/$(POSTGRES_IMP) -Wl,-bE:$*$(EXPSUFF) $(LIBS)
 
 sqlmansect = 7
-- 
GitLab