Clean up MinGW def file generation
I was mystified by this comment in Makefile.shlib:
# We need several not-quite-identical variants of .DEF files to build
# DLLs for Windows. These are made from the single source file
# exports.txt. Since we can't assume that Windows boxes will have
# sed, the .DEF files are always built and included in distribution
# tarballs.
ifneq (,$(SHLIB_EXPORTS))
distprep: lib$(NAME)dll.def lib$(NAME)ddll.def
...
This doesn't make much sense (anymore?) since MinGW surely has sed and
MSVC doesn't use this (and has Perl). I think this is a leftover from
various ancient client-only ad-hoc Windows build provisions (those
win32.mak files we used to have around). Also, the ddll.def (debug
build) isn't used by anything anymore AFAICT.
I think we can clean this up and just have the regular ddl.def built
normally at build time if required.
Does anyone know more about this?
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Clean-up-MinGW-def-file-generation.patchtext/plain; charset=UTF-8; name=0001-Clean-up-MinGW-def-file-generation.patch; x-mac-creator=0; x-mac-type=0Download
From 5cf449d76be516b207bb77b7802585f7612a776f Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Tue, 15 Oct 2019 08:48:35 +0200
Subject: [PATCH] Clean up MinGW def file generation
There were some leftovers from ancient ad-hoc ways to build on
Windows, prior to the standardization on MSVC and MinGW. We don't
need to build a lib$(NAME)ddll.def (debug build, as opposed to
lib$(NAME)dll.def) for MinGW, since nothing uses that. We also don't
need to build the regular .def file during distprep, since the MinGW
build environment is perfectly capable of creating that normally at
build time.
---
src/Makefile.shlib | 40 ++++++-------------------
src/interfaces/ecpg/compatlib/Makefile | 2 +-
src/interfaces/ecpg/ecpglib/Makefile | 2 +-
src/interfaces/ecpg/pgtypeslib/Makefile | 2 +-
src/interfaces/libpq/Makefile | 2 +-
5 files changed, 13 insertions(+), 35 deletions(-)
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index c4893edfc3..526361f31b 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -49,7 +49,6 @@
# installdirs-lib create installation directory $(libdir)
# uninstall-lib remove the libraries from $(libdir)
# clean-lib delete the static and shared libraries from the build dir
-# maintainer-clean-lib delete .def files built for win32
#
# Typically you would add `all-lib' to the `all' target so that `make all'
# builds the libraries. In the most simple case it would look like this:
@@ -374,6 +373,13 @@ DLL_DEFFILE = lib$(NAME)dll.def
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
+
+UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
+
+$(DLL_DEFFILE): $(SHLIB_EXPORTS)
+ echo 'LIBRARY LIB$(UC_NAME).dll' >$@
+ echo 'EXPORTS' >>$@
+ sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
endif
endif # PORTNAME == cygwin
@@ -397,32 +403,6 @@ endif # PORTNAME == cygwin || PORTNAME == win32
echo 'Libs.private: $(sort $(filter-out -L.% -L$(top_srcdir)/%,$(filter -L%,$(LDFLAGS) $(SHLIB_LINK)))) $(filter-out $(PKG_CONFIG_REQUIRES_PRIVATE:lib%=-l%),$(filter -l%,$(SHLIB_LINK)))' >>$@
-# We need several not-quite-identical variants of .DEF files to build
-# DLLs for Windows. These are made from the single source file
-# exports.txt. Since we can't assume that Windows boxes will have
-# sed, the .DEF files are always built and included in distribution
-# tarballs.
-
-ifneq (,$(SHLIB_EXPORTS))
-distprep: lib$(NAME)dll.def lib$(NAME)ddll.def
-
-UC_NAME = $(shell echo $(NAME) | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')
-
-lib$(NAME)dll.def: $(SHLIB_EXPORTS)
- echo '; DEF file for Makefile.shlib (MinGW)' >$@
- echo 'LIBRARY LIB$(UC_NAME).dll' >>$@
- echo 'EXPORTS' >>$@
- sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
-
-lib$(NAME)ddll.def: $(SHLIB_EXPORTS)
- echo '; DEF file for Makefile.shlib (MinGW)' >$@
- echo 'LIBRARY LIB$(UC_NAME)D.dll' >>$@
- echo 'EXPORTS' >>$@
- sed -e '/^#/d' -e 's/^\(.*[ ]\)\([0-9][0-9]*\)/ \1@ \2/' $< >>$@
-
-endif # SHLIB_EXPORTS
-
-
##
## INSTALL
##
@@ -505,8 +485,6 @@ endif # no soname
.PHONY: clean-lib
clean-lib:
rm -f $(shlib) $(shlib_bare) $(shlib_major) $(stlib) $(exports_file) lib$(NAME).pc
-
-ifneq (,$(SHLIB_EXPORTS))
-maintainer-clean-lib:
- rm -f lib$(NAME)dll.def lib$(NAME)ddll.def
+ifneq (,$(DLL_DEFFILE))
+ rm -f $(DLL_DEFFILE)
endif
diff --git a/src/interfaces/ecpg/compatlib/Makefile b/src/interfaces/ecpg/compatlib/Makefile
index cd9879ba75..b9a4fbe9c0 100644
--- a/src/interfaces/ecpg/compatlib/Makefile
+++ b/src/interfaces/ecpg/compatlib/Makefile
@@ -54,4 +54,4 @@ uninstall: uninstall-lib
clean distclean: clean-lib
rm -f $(OBJS)
-maintainer-clean: distclean maintainer-clean-lib
+maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/ecpglib/Makefile b/src/interfaces/ecpg/ecpglib/Makefile
index 8827a17fec..e888205dee 100644
--- a/src/interfaces/ecpg/ecpglib/Makefile
+++ b/src/interfaces/ecpg/ecpglib/Makefile
@@ -57,4 +57,4 @@ uninstall: uninstall-lib
clean distclean: clean-lib
rm -f $(OBJS)
-maintainer-clean: distclean maintainer-clean-lib
+maintainer-clean: distclean
diff --git a/src/interfaces/ecpg/pgtypeslib/Makefile b/src/interfaces/ecpg/pgtypeslib/Makefile
index fcc18c193c..899ff40cf6 100644
--- a/src/interfaces/ecpg/pgtypeslib/Makefile
+++ b/src/interfaces/ecpg/pgtypeslib/Makefile
@@ -44,4 +44,4 @@ uninstall: uninstall-lib
clean distclean: clean-lib
rm -f $(OBJS)
-maintainer-clean: distclean maintainer-clean-lib
+maintainer-clean: distclean
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index c734965d63..0eb457d373 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -139,6 +139,6 @@ clean distclean: clean-lib
# Remove files we (may have) symlinked in from other places
rm -f encnames.c wchar.c
-maintainer-clean: distclean maintainer-clean-lib
+maintainer-clean: distclean
$(MAKE) -C test $@
rm -f libpq-dist.rc
--
2.23.0
On Tue, Oct 15, 2019 at 09:00:23AM +0200, Peter Eisentraut wrote:
This doesn't make much sense (anymore?) since MinGW surely has sed and
MSVC doesn't use this (and has Perl). I think this is a leftover from
various ancient client-only ad-hoc Windows build provisions (those
win32.mak files we used to have around). Also, the ddll.def (debug
build) isn't used by anything anymore AFAICT.
sed is present in MinGW for some time, at least 2009 if you look here:
https://sourceforge.net/projects/mingw/files/MSYS/Base/sed/
Cygwin also includes sed, so this cleanup makes sense.
I think we can clean this up and just have the regular ddl.def built
normally at build time if required.Does anyone know more about this?
This comes from here, but I cannot see a thread about this topic
around this date:
commit: a1d5d8574751d62a039d8ceb44329ee7c637196a
author: Peter Eisentraut <peter_e@gmx.net>
date: Tue, 26 Feb 2008 06:41:24 +0000
Refactor the code that creates the shared library export files to appear
only once in Makefile.shlib and not in four copies.
--
Michael
On 2019-Oct-17, Michael Paquier wrote:
On Tue, Oct 15, 2019 at 09:00:23AM +0200, Peter Eisentraut wrote:
I think we can clean this up and just have the regular ddl.def built
normally at build time if required.Does anyone know more about this?
This comes from here, but I cannot see a thread about this topic
around this date:
commit: a1d5d8574751d62a039d8ceb44329ee7c637196a
author: Peter Eisentraut <peter_e@gmx.net>
date: Tue, 26 Feb 2008 06:41:24 +0000
Refactor the code that creates the shared library export files to appear
only once in Makefile.shlib and not in four copies.
Well, yes, but that code originates from much earlier. For example
2a63c1602d9d (Tom Lane, Oct. 2004) is the one that created the libpq
ones. But even that ancient one seems to be just refactoring some stuff
that was already there, namely something that seems to have been created
by commit 53cd7cd8a916:
commit 53cd7cd8a9168d4b2e2feb52129336429cc99b98
Author: Bruce Momjian <bruce@momjian.us>
AuthorDate: Tue Mar 9 04:53:37 2004 +0000
CommitDate: Tue Mar 9 04:53:37 2004 +0000
Make a separate win32 debug DLL along with the non-debug version:
Currently, src/interfaces/libpq/win32.mak builds a statically-linked
library "libpq.lib", a debug dll "libpq.dll", import library for the
debug dll "libpqdll.lib", a release dll "libpq.dll", import library for
the release dll "libpqdll.lib". To avoid naming clashes, I would make
the debug dll and import libraries "libpqd.dll" and "libpqddll.lib".
Basically, the debug build uses the cl flags: "/MDd /D _DEBUG", and the
release build uses the cl flags "/MD /D NDEBUG". Usually the debug
build has a "D" suffix on the file name, so for example:
libpqd.dll libpq, debug build
libpqd.lib libpq, debug build, import library
libpq.dll libpq, release build
libpq.lib libpq, release build, import library
David Turner
This stuff was used by win32.mak, but I don't know if that tells anyone
anything.
--
�lvaro Herrera https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Alvaro Herrera <alvherre@2ndquadrant.com> writes:
On 2019-Oct-17, Michael Paquier wrote:
On Tue, Oct 15, 2019 at 09:00:23AM +0200, Peter Eisentraut wrote:
I think we can clean this up and just have the regular ddl.def built
normally at build time if required.
Does anyone know more about this?
Well, yes, but that code originates from much earlier. For example
2a63c1602d9d (Tom Lane, Oct. 2004) is the one that created the libpq
ones.
Yeah, the comment that Peter complained about is mine. I believe the
desire to avoid depending on "sed" at build time was focused on our
old support for building libpq with Borland C (and not much else).
Since this makefile infrastructure is now only used for MinGW, I agree
we ought to be able to quit shipping those files in tarballs.
I think there could be some .gitignore cleanup done along with this.
Notably, I see exclusions for /exports.list in several places, but no
other references to that name --- isn't that an intermediate file that
we used to generate while creating these files?
regards, tom lane
On 2019-10-18 15:00, Tom Lane wrote:
Yeah, the comment that Peter complained about is mine. I believe the
desire to avoid depending on "sed" at build time was focused on our
old support for building libpq with Borland C (and not much else).
Since this makefile infrastructure is now only used for MinGW, I agree
we ought to be able to quit shipping those files in tarballs.
Yeah, it all makes sense now. I have committed my patch now.
I think there could be some .gitignore cleanup done along with this.
Notably, I see exclusions for /exports.list in several places, but no
other references to that name --- isn't that an intermediate file that
we used to generate while creating these files?
exports.list is built from exports.txt on non-Windows platforms and
AFAICT it is not cleaned up as an intermediate file. So I think the
current arrangement is correct.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
On 2019-10-20 10:26, Peter Eisentraut wrote:
On 2019-10-18 15:00, Tom Lane wrote:
Yeah, the comment that Peter complained about is mine. I believe the
desire to avoid depending on "sed" at build time was focused on our
old support for building libpq with Borland C (and not much else).
Since this makefile infrastructure is now only used for MinGW, I agree
we ought to be able to quit shipping those files in tarballs.Yeah, it all makes sense now. I have committed my patch now.
Very related, I believe the file libpq-dist.rc is also obsolete; see
attached patch.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:
0001-Remove-libpq-dist.rc.patchtext/plain; charset=UTF-8; name=0001-Remove-libpq-dist.rc.patch; x-mac-creator=0; x-mac-type=0Download
From a098f5edc3477c774d06ddd9324364c2bad2c6fe Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter@eisentraut.org>
Date: Sun, 20 Oct 2019 23:57:57 +0200
Subject: [PATCH] Remove libpq-dist.rc
The use of this was removed by
6da56f3f84d430671d5edd8f9336bd744c089e31.
---
src/interfaces/libpq/.gitignore | 1 -
src/interfaces/libpq/Makefile | 7 +------
2 files changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/interfaces/libpq/.gitignore b/src/interfaces/libpq/.gitignore
index 38779b23a4..9be338dec8 100644
--- a/src/interfaces/libpq/.gitignore
+++ b/src/interfaces/libpq/.gitignore
@@ -1,6 +1,5 @@
/exports.list
/libpq.rc
-/libpq-dist.rc
# .c files that are symlinked in from elsewhere
/encnames.c
/wchar.c
diff --git a/src/interfaces/libpq/Makefile b/src/interfaces/libpq/Makefile
index 6626f87e76..2fad1bc44c 100644
--- a/src/interfaces/libpq/Makefile
+++ b/src/interfaces/libpq/Makefile
@@ -94,14 +94,10 @@ encnames.c wchar.c: % : $(backend_src)/utils/mb/%
rm -f $@ && $(LN_S) $< .
-distprep: libpq-dist.rc
-
-libpq.rc libpq-dist.rc: libpq.rc.in
+libpq.rc: libpq.rc.in
sed -e 's/\(VERSION.*\),0 *$$/\1,'`date '+%y%j' | sed 's/^0*//'`'/' $< >$@
# Depend on Makefile.global to force rebuild on re-run of configure.
-# (But libpq-dist.rc is shipped in the distribution for shell-less
-# installations and is only updated by distprep.)
libpq.rc: $(top_builddir)/src/Makefile.global
# Make dependencies on pg_config_paths.h visible, too.
@@ -141,4 +137,3 @@ clean distclean: clean-lib
maintainer-clean: distclean
$(MAKE) -C test $@
- rm -f libpq-dist.rc
--
2.23.0
On 2019-10-21 00:07, Peter Eisentraut wrote:
On 2019-10-20 10:26, Peter Eisentraut wrote:
On 2019-10-18 15:00, Tom Lane wrote:
Yeah, the comment that Peter complained about is mine. I believe the
desire to avoid depending on "sed" at build time was focused on our
old support for building libpq with Borland C (and not much else).
Since this makefile infrastructure is now only used for MinGW, I agree
we ought to be able to quit shipping those files in tarballs.Yeah, it all makes sense now. I have committed my patch now.
Very related, I believe the file libpq-dist.rc is also obsolete; see
attached patch.
committed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services