Skip to content

Commit 284590e

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 53566fc commit 284590e

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
@@ -371,16 +371,22 @@ else
371371

372372
$(stlib): $(shlib) ;
373373

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

382388
$(shlib): $(OBJS) $(DLL_DEFFILE) | $(SHLIB_PREREQS)
383-
$(CC) $(CFLAGS) -shared -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
389+
$(CC) $(CFLAGS) -shared -static-libgcc -o $@ $(OBJS) $(DLL_DEFFILE) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--out-implib=$(stlib)
384390
endif
385391

386392
endif # PORTNAME == cgywin

src/makefiles/Makefile.win32

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

7777
# Rule for building a shared library from a single .o file
7878
%.dll: %.o $(WIN32RES)
79-
$(CC) $(CFLAGS) -shared -o $@ $^ -Wl,--export-all-symbols $(LDFLAGS) $(LDFLAGS_SL) $(BE_DLLLIBS)
79+
$(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