Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit ae47e0b

Browse files
anarazelpull[bot]
authored andcommitted
aix: No need to use mkldexport when we want to export all symbols
When building a shared library with exports.txt there's no need to build an intermediary static library, we can just pass -Wl,-bE:... when generating the .so. When building a shared library without exports.txt, there's no need to call mkldexport.sh to export all symbols, because all symbols are exported anyway, and we don't need the export file on the import side (like we do for postgres.imp). This makes building .so's on aix a lot more similar to building on other platforms. In particular, we don't create and remove a .a of the same name but different contents anymore. Discussion: https://postgr.es/m/20220820174213.d574qde4ptwdzoqz@awork3.anarazel.de
1 parent 7af00aa commit ae47e0b

File tree

2 files changed

+20
-33
lines changed

2 files changed

+20
-33
lines changed

src/Makefile.shlib

Lines changed: 18 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,17 @@ override CPPFLAGS += -DSO_MAJOR_VERSION=$(SO_MAJOR_VERSION)
107107
endif
108108

109109
ifeq ($(PORTNAME), aix)
110+
LINK.shared = $(COMPILER)
110111
ifdef SO_MAJOR_VERSION
111112
shlib = lib$(NAME)$(DLSUFFIX).$(SO_MAJOR_VERSION)
112113
endif
113114
haslibarule = yes
114115
# $(exports_file) is also usable as an import file
115116
exports_file = lib$(NAME).exp
117+
BUILD.exports = ( echo '\#! $(shlib)'; $(AWK) '/^[^\#]/ {printf "%s\n",$$1}' $< ) > $@
118+
ifneq (,$(SHLIB_EXPORTS))
119+
LINK.shared += -Wl,-bE:$(exports_file)
120+
endif
116121
endif
117122

118123
ifeq ($(PORTNAME), darwin)
@@ -259,9 +264,15 @@ $(stlib): $(OBJS) | $(SHLIB_PREREQS)
259264
touch $@
260265
endif #haslibarule
261266

267+
# AIX wraps shared libraries inside a static library, can be used both
268+
# for static and shared linking
269+
ifeq ($(PORTNAME), aix)
270+
$(stlib): $(shlib)
271+
rm -f $(stlib)
272+
$(AR) $(AROPT) $(stlib) $(shlib)
273+
endif # aix
262274

263275
ifeq (,$(filter cygwin win32,$(PORTNAME)))
264-
ifneq ($(PORTNAME), aix)
265276

266277
# Normal case
267278
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
@@ -274,9 +285,12 @@ ifneq ($(shlib), $(shlib_major))
274285
endif
275286
# Make sure we have a link to a name without any version numbers
276287
ifneq ($(shlib), $(shlib_bare))
288+
# except on AIX, where that's not a thing
289+
ifneq ($(PORTNAME), aix)
277290
rm -f $(shlib_bare)
278291
$(LN_S) $(shlib) $(shlib_bare)
279-
endif
292+
endif # aix
293+
endif # shlib_bare
280294
endif # shlib_major
281295

282296
# Where possible, restrict the symbols exported by the library to just the
@@ -285,36 +299,13 @@ endif # shlib_major
285299
# libpgport along with libpq.
286300
ifneq (,$(SHLIB_EXPORTS))
287301
ifdef BUILD.exports
288-
$(shlib): $(SHLIB_EXPORTS:%.txt=%.list)
302+
$(shlib): $(exports_file)
289303

290-
$(SHLIB_EXPORTS:%.txt=%.list): %.list: %.txt
304+
$(exports_file): $(SHLIB_EXPORTS)
291305
$(BUILD.exports)
292306
endif
293307
endif
294308

295-
else # PORTNAME == aix
296-
297-
# AIX case
298-
299-
# See notes in src/backend/parser/Makefile about the following two rules
300-
$(stlib): $(shlib)
301-
touch $@
302-
303-
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
304-
rm -f $(stlib)
305-
$(LINK.static) $(stlib) $^
306-
$(RANLIB) $(stlib)
307-
ifeq (,$(SHLIB_EXPORTS))
308-
$(MKLDEXPORT) $(stlib) $(shlib) >$(exports_file)
309-
else
310-
( echo '#! $(shlib)'; $(AWK) '/^[^#]/ {printf "%s\n",$$1}' ${srcdir}/$(SHLIB_EXPORTS) ) >$(exports_file)
311-
endif
312-
$(COMPILER) -o $(shlib) $(stlib) -Wl,-bE:$(exports_file) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)
313-
rm -f $(stlib)
314-
$(AR) $(AROPT) $(stlib) $(shlib)
315-
316-
endif # PORTNAME == aix
317-
318309
else # PORTNAME == cygwin || PORTNAME == win32
319310

320311
ifeq ($(PORTNAME), cygwin)

src/makefiles/Makefile.aix

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,5 @@ endif
3838
MKLDEXPORT_DIR=src/backend/port/aix
3939
MKLDEXPORT=$(top_srcdir)/$(MKLDEXPORT_DIR)/mkldexport.sh
4040

41-
%.exp: %.o
42-
$(MKLDEXPORT) $^ >$@
43-
44-
# Rule for building a shared library from a single .o file
45-
%$(DLSUFFIX): %.o %.exp
46-
$(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ -Wl,-bE:$*.exp $(BE_DLLLIBS)
41+
%$(DLSUFFIX): %.o
42+
$(CC) $(CFLAGS) $*.o $(LDFLAGS) $(LDFLAGS_SL) -o $@ $(BE_DLLLIBS)

0 commit comments

Comments
 (0)