summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNoah Misch <noah@leadboat.com>2014-10-21 22:55:47 -0400
committerNoah Misch <noah@leadboat.com>2014-10-21 22:56:42 -0400
commit2f51f424bb362dadeb4fabf03845961e563da4ba (patch)
tree5a8d17b543986f93815b0bf2fb3269fea9e11cef /src
parent9e02e20ab6df093e1ab751157dfb5c51a420187b (diff)
MinGW: Use -static-libgcc when linking a DLL.
When commit 846e91e0223cf9f2821c3ad4dfffffbb929cb027 switched the linker driver from dlltool/dllwrap to gcc, it became possible for linking to choose shared libgcc. Backends having loaded a module dynamically linked to libgcc can exit abnormally, which the postmaster treats like a crash. Resume use of static libgcc exclusively, like 9.3 and earlier. Back-patch to 9.4.
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.shlib10
-rw-r--r--src/makefiles/Makefile.win322
2 files changed, 9 insertions, 3 deletions
diff --git a/src/Makefile.shlib b/src/Makefile.shlib
index 029c7e96fcb..8a571ba4896 100644
--- a/src/Makefile.shlib
+++ b/src/Makefile.shlib
@@ -375,16 +375,22 @@ else
$(stlib): $(shlib) ;
+# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
+# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers
+# from i686-4.9.1-release-win32-dwarf-rt_v3-rev1.) Shared libgcc has better
+# support for C++/Java exceptions; while core PostgreSQL does not use them, it
+# would be nice to support shared libgcc for the benefit of extensions.
+#
# If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
# Else we just use --export-all-symbols.
ifeq (,$(SHLIB_EXPORTS))
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
- $(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
+ $(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
else
DLL_DEFFILE = lib$(NAME)dll.def
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
- $(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
+ $(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
endif
endif # PORTNAME == cgywin
diff --git a/src/makefiles/Makefile.win32 b/src/makefiles/Makefile.win32
index b18621b2f8b..dee2adf7f10 100644
--- a/src/makefiles/Makefile.win32
+++ b/src/makefiles/Makefile.win32
@@ -72,4 +72,4 @@ win32ver.o: win32ver.rc
# Rule for building a shared library from a single .o file
%.dll: %.o
- $(CC) $(CFLAGS) -shared -o $@ $< -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)
+ $(CC) $(CFLAGS) -shared -static-libgcc -o $@ $< -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)