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

Commit 846e91e

Browse files
committed
Get rid of use of dlltool in Mingw builds.
We are almost completely out of the dlltool game, if this works. Hiroshi Inoue
1 parent cba6ffa commit 846e91e

File tree

3 files changed

+25
-36
lines changed

3 files changed

+25
-36
lines changed

src/Makefile.shlib

+20-21
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,6 @@
3434
# SO_MINOR_VERSION Minor version number to use for shared library
3535
# (If you want a patchlevel, include it in SO_MINOR_VERSION, e.g., "6.2".)
3636
#
37-
# Optional flags when building DLL's (only applicable to win32 and cygwin
38-
# platforms).
39-
# DLLTOOL_DEFFLAGS Additional flags when creating the dll .def file
40-
# DLLTOOL_LIBFLAGS Additional flags when creating the lib<module>.a file
41-
# DLLWRAP_FLAGS Additional flags to dllwrap
42-
#
4337
# The module Makefile must also include
4438
# $(top_builddir)/src/Makefile.global before including this file.
4539
# (Makefile.global sets PORTNAME and other needed symbols.)
@@ -358,35 +352,40 @@ endif # PORTNAME == aix
358352

359353
else # PORTNAME == cygwin || PORTNAME == win32
360354

361-
# Cygwin or Win32 case
362-
363-
# If SHLIB_EXPORTS is set, the rules below will build a .def file from
364-
# that. Else we build a temporary one here.
365355
ifeq ($(PORTNAME), cygwin)
356+
357+
# Cygwin case
358+
366359
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
367360
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) $(LDAP_LIBS_BE)
368361

369362
$(stlib): $(OBJS) | $(SHLIB_PREREQS)
370363
$(LINK.static) $@ $^
371364
$(RANLIB) $@
372365

373-
374366
else
375-
ifeq (,$(SHLIB_EXPORTS))
376-
DLL_DEFFILE = lib$(NAME)dll.def
377-
exports_file = $(DLL_DEFFILE)
378367

379-
$(exports_file): $(OBJS)
380-
$(DLLTOOL) --export-all $(DLLTOOL_DEFFLAGS) --output-def $@ $^
368+
# Win32 case
369+
370+
# There is no correct way to write a rule that generates two files.
371+
# Rules with two targets don't have that meaning, they are merely
372+
# shorthand for two otherwise separate rules. To be safe for parallel
373+
# make, we must chain the dependencies like this. The semicolon is
374+
# important, otherwise make will choose some built-in rule.
375+
376+
$(stlib): $(shlib) ;
377+
378+
# If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
379+
# Else we just use --export-all-symbols.
380+
ifeq (,$(SHLIB_EXPORTS))
381+
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
382+
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
381383
else
382384
DLL_DEFFILE = lib$(NAME)dll.def
383-
endif
384385

385386
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
386-
$(DLLWRAP) -o $@ --dllname $(shlib) $(DLLWRAP_FLAGS) --def $(DLL_DEFFILE) $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK)
387-
388-
$(stlib): $(shlib) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
389-
$(DLLTOOL) --dllname $(shlib) $(DLLTOOL_LIBFLAGS) --def $(DLL_DEFFILE) --output-lib $@
387+
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) $(DLL_DEFFILE) -Wl,--out-implib=$(stlib)
388+
endif
390389

391390
endif # PORTNAME == cgywin
392391
endif # PORTNAME == cygwin || PORTNAME == win32

src/backend/Makefile

+4-12
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,10 @@ endif # cygwin
7878
ifeq ($(PORTNAME), win32)
7979
LIBS += -lsecur32
8080

81-
postgres: $(OBJS) postgres.def libpostgres.a $(WIN32RES)
82-
$(DLLTOOL) --dllname $@$(X) --output-exp $@.exp --def postgres.def
83-
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -o $@$(X) -Wl,--base-file,$@.base $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
84-
$(DLLTOOL) --dllname $@$(X) --base-file $@.base --output-exp $@.exp --def postgres.def
85-
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -o $@$(X) $@.exp $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS)
86-
rm -f $@.exp $@.base
81+
postgres: $(OBJS) $(WIN32RES)
82+
$(CC) $(CFLAGS) $(LDFLAGS) $(LDFLAGS_EX) -Wl,--stack=$(WIN32_STACK_RLIMIT) -Wl,--export-all-symbols -Wl,--out-implib=libpostgres.a $(call expand_subsys,$(OBJS)) $(WIN32RES) $(LIBS) -o $@$(X)
8783

88-
postgres.def: $(OBJS)
89-
$(DLLTOOL) --export-all --output-def $@ $(call expand_subsys,$^)
90-
91-
libpostgres.a: postgres.def
92-
$(DLLTOOL) --dllname postgres.exe --def postgres.def --output-lib $@
84+
libpostgres.a: postgres ;
9385

9486
endif # win32
9587

@@ -296,7 +288,7 @@ ifeq ($(PORTNAME), cygwin)
296288
rm -f postgres.dll libpostgres.a
297289
endif
298290
ifeq ($(PORTNAME), win32)
299-
rm -f postgres.dll postgres.def libpostgres.a $(WIN32RES)
291+
rm -f postgres.dll libpostgres.a $(WIN32RES)
300292
endif
301293

302294
distclean: clean

src/makefiles/Makefile.win32

+1-3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,4 @@ win32ver.o: win32ver.rc
7272

7373
# Rule for building a shared library from a single .o file
7474
%.dll: %.o
75-
$(DLLTOOL) --export-all --output-def $*.def $<
76-
$(DLLWRAP) -o $@ --def $*.def $< $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)
77-
rm -f $*.def
75+
$(CC) $(CFLAGS) -shared -o $@ $< -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)

0 commit comments

Comments
 (0)