Skip to content

Commit 2f51f42

Browse files
committed
MinGW: Use -static-libgcc when linking a DLL.
When commit 846e91e 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.
1 parent 9e02e20 commit 2f51f42

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Makefile.shlib

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,16 +375,22 @@ else
375375

376376
$(stlib): $(shlib) ;
377377

378+
# XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
379+
# uncleanly, hence -static-libgcc. (Last verified with MinGW-w64 compilers
380+
# from i686-4.9.1-release-win32-dwarf-rt_v3-rev1.) Shared libgcc has better
381+
# support for C++/Java exceptions; while core PostgreSQL does not use them, it
382+
# would be nice to support shared libgcc for the benefit of extensions.
383+
#
378384
# If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
379385
# Else we just use --export-all-symbols.
380386
ifeq (,$(SHLIB_EXPORTS))
381387
$(shlib): $(OBJS) | $(SHLIB_PREREQS)
382-
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
388+
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
383389
else
384390
DLL_DEFFILE = lib$(NAME)dll.def
385391

386392
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
387-
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
393+
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
388394
endif
389395

390396
endif # PORTNAME == cgywin

src/makefiles/Makefile.win32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ win32ver.o: win32ver.rc
7272

7373
# Rule for building a shared library from a single .o file
7474
%.dll: %.o
75-
$(CC) $(CFLAGS) -shared -o $@ $< -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)
75+
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $< -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy