summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Allsopp <david.allsopp@metastack.com>2020-11-25 15:31:08 +0000
committerDavid Allsopp <david.allsopp@metastack.com>2020-11-25 15:31:08 +0000
commit7a6f02ec6a30ae37432bb5c6eaa775b1780a67f9 (patch)
treed566c6aeb3b79ccbd7bdc08e066f1327f59a1c87
parent10c91b3a8d6a526b847a4d3995b452e568627473 (diff)
downloadocaml-7a6f02ec6a30ae37432bb5c6eaa775b1780a67f9.tar.gz
Link DLLs with -static-libgcc on mingw-w64 i686
This has become necessary with version 8.0.0 of the mingw-w64 runtime which causes libgcc_s_sjlj-1.dll to be linked with all DLLs, It does not appear to be doing this for executables, which means that executables using C++ should still be able to operate as before (in particular, ocaml-mccs).
-rw-r--r--Changes5
-rw-r--r--Makefile.build_config.in4
-rwxr-xr-xconfigure10
-rw-r--r--configure.ac7
-rw-r--r--otherlibs/win32unix/Makefile4
-rw-r--r--testsuite/Makefile3
-rw-r--r--utils/Makefile2
-rw-r--r--utils/config.mlp4
8 files changed, 30 insertions, 9 deletions
diff --git a/Changes b/Changes
index 3e76eee7ff..0248d3d998 100644
--- a/Changes
+++ b/Changes
@@ -453,6 +453,11 @@ OCaml 4.12.0
- #10008: Improve error message for aliases to the current compilation unit.
(Leo White, review by Gabriel Scherer)
+- #10046: Link all DLLs with -static-libgcc on mingw32 to prevent dependency
+ on libgcc_s_sjlj-1.dll with mingw-w64 runtime 8.0.0 (previously this was
+ only needed for dllunix.dll).
+ (David Allsopp, report by Andreas Hauptmann, review by ???)
+
### Internal/compiler-libs changes:
- #8987: Make some locations more accurate
diff --git a/Makefile.build_config.in b/Makefile.build_config.in
index fa6b2b71e3..49a3f14c0c 100644
--- a/Makefile.build_config.in
+++ b/Makefile.build_config.in
@@ -27,3 +27,7 @@ INSTALL_PROG ?= @INSTALL_PROGRAM@
# The command to generate C dependency information
DEP_CC=@DEP_CC@ -MM
COMPUTE_DEPS=@compute_deps@
+
+# This is munged into utils/config.ml, not overridable by other parts of
+# the build system.
+OC_DLL_LDFLAGS=@oc_dll_ldflags@
diff --git a/configure b/configure
index e47435a011..16536c5b1a 100755
--- a/configure
+++ b/configure
@@ -803,6 +803,7 @@ ocamlc_cppflags
ocamlc_cflags
nativecclibs
bytecclibs
+oc_dll_ldflags
oc_ldflags
oc_cppflags
oc_cflags
@@ -2780,6 +2781,7 @@ internal_cppflags=""
ocamlc_cflags=""
ocamlc_cppflags=""
oc_ldflags=""
+oc_dll_ldflags=""
with_sharedlibs=true
ostype="Unix"
iflexdir=""
@@ -2886,6 +2888,7 @@ VERSION=4.13.0+dev0-2020-10-19
+
# TODO: rename this variable
@@ -12783,7 +12786,7 @@ fi
if $with_sharedlibs; then :
case $host in #(
i686-*-*) :
- flexdll_chain="mingw" ;; #(
+ flexdll_chain="mingw"; oc_dll_ldflags="-static-libgcc" ;; #(
x86_64-*-*) :
flexdll_chain="mingw64" ;; #(
*) :
@@ -13629,6 +13632,11 @@ if test x"$enable_shared" != "xno"; then :
*-*-mingw32) :
mksharedlib='$(FLEXLINK)'
mkmaindll='$(FLEXLINK) -maindll'
+ if test -n "$oc_dll_ldflags"; then :
+
+ mksharedlib="$mksharedlib -link \"$oc_dll_ldflags\""
+ mkmaindll="$mkmaindll -link \"$oc_dll_ldflags\""
+fi
shared_libraries_supported=$with_sharedlibs ;; #(
*-pc-windows) :
mksharedlib='$(FLEXLINK)'
diff --git a/configure.ac b/configure.ac
index c1e52891e3..f1c90241a1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,6 +52,7 @@ internal_cppflags=""
ocamlc_cflags=""
ocamlc_cppflags=""
oc_ldflags=""
+oc_dll_ldflags=""
with_sharedlibs=true
ostype="Unix"
iflexdir=""
@@ -108,6 +109,7 @@ AC_SUBST([toolchain])
AC_SUBST([oc_cflags])
AC_SUBST([oc_cppflags])
AC_SUBST([oc_ldflags])
+AC_SUBST([oc_dll_ldflags])
AC_SUBST([bytecclibs])
AC_SUBST([nativecclibs])
AC_SUBST([ocamlc_cflags])
@@ -679,7 +681,7 @@ AS_CASE([$CC,$host],
[*,*-*-mingw32],
[AS_IF([$with_sharedlibs],
[AS_CASE([$host],
- [i686-*-*], [flexdll_chain="mingw"],
+ [i686-*-*], [flexdll_chain="mingw"; oc_dll_ldflags="-static-libgcc"],
[x86_64-*-*], [flexdll_chain="mingw64"])
flexlink="flexlink -chain $flexdll_chain -merge-manifest -stack 16777216"
flexdir=`$flexlink -where | tr -d '\015'`
@@ -822,6 +824,9 @@ AS_IF([test x"$enable_shared" != "xno"],
[*-*-mingw32],
[mksharedlib='$(FLEXLINK)'
mkmaindll='$(FLEXLINK) -maindll'
+ AS_IF([test -n "$oc_dll_ldflags"],[
+ mksharedlib="$mksharedlib -link \"$oc_dll_ldflags\""
+ mkmaindll="$mkmaindll -link \"$oc_dll_ldflags\""])
shared_libraries_supported=$with_sharedlibs],
[*-pc-windows],
[mksharedlib='$(FLEXLINK)'
diff --git a/otherlibs/win32unix/Makefile b/otherlibs/win32unix/Makefile
index 0d6fafea34..149b8e9382 100644
--- a/otherlibs/win32unix/Makefile
+++ b/otherlibs/win32unix/Makefile
@@ -54,11 +54,7 @@ unixLabels.cmi: \
include ../Makefile.otherlibs.common
-ifeq "$(SYSTEM)" "mingw"
-LDOPTS=-ldopt "-link -static-libgcc" $(addprefix -ldopt ,$(WIN32_LIBS))
-else
LDOPTS=$(addprefix -ldopt ,$(WIN32_LIBS))
-endif
clean::
rm -f $(UNIX_FILES) $(UNIX_CAML_FILES)
diff --git a/testsuite/Makefile b/testsuite/Makefile
index 6ca578464b..d7fc326ea3 100644
--- a/testsuite/Makefile
+++ b/testsuite/Makefile
@@ -58,8 +58,9 @@ else
ifeq "$(FLEXLINK_ENV)" ""
ocamltest := MKDLL="$(MKDLL)" SORT=$(SORT) MAKE=$(MAKE) $(ocamltest_program)
else
+ FLEXLINK_DLL_LDFLAGS=$(if $(OC_DLL_LDFLAGS), -link "$(OC_DLL_LDFLAGS)")
MKDLL=$(WINTOPDIR)/boot/ocamlrun $(WINTOPDIR)/flexdll/flexlink.exe \
- $(FLEXLINK_FLAGS)
+ $(FLEXLINK_FLAGS) $(FLEXLINK_DLL_LDFLAGS)
ocamltest := $(FLEXLINK_ENV) MKDLL="$(MKDLL)" SORT=$(SORT) MAKE=$(MAKE) \
$(ocamltest_program)
diff --git a/utils/Makefile b/utils/Makefile
index 871fc2fe59..11e2cebe2e 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -39,6 +39,7 @@ SUBST_QUOTE2=\
SUBST_QUOTE=$(call SUBST_QUOTE2,$1,$($1))
FLEXLINK_LDFLAGS=$(if $(OC_LDFLAGS), -link "$(OC_LDFLAGS)")
+FLEXLINK_DLL_LDFLAGS=$(if $(OC_DLL_LDFLAGS), -link "$(OC_DLL_LDFLAGS)")
config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile
sed $(call SUBST,AFL_INSTRUMENT) \
@@ -64,6 +65,7 @@ config.ml: config.mlp $(ROOTDIR)/Makefile.config Makefile
$(call SUBST_STRING,MKDLL) \
$(call SUBST_STRING,MKEXE) \
$(call SUBST_STRING,FLEXLINK_LDFLAGS) \
+ $(call SUBST_STRING,FLEXLINK_DLL_LDFLAGS) \
$(call SUBST_STRING,MKMAINDLL) \
$(call SUBST,MODEL) \
$(call SUBST_STRING,NATIVECCLIBS) \
diff --git a/utils/config.mlp b/utils/config.mlp
index 10df2bdbe7..5bfa30d694 100644
--- a/utils/config.mlp
+++ b/utils/config.mlp
@@ -65,9 +65,9 @@ let mkdll, mkexe, mkmaindll =
let c = flexlink.[i] in
if c = '/' then '\\' else c in
(String.init (String.length flexlink) f) ^ " %%FLEXLINK_FLAGS%%" in
- flexlink,
+ flexlink ^ "%%FLEXLINK_DLL_LDFLAGS%%",
flexlink ^ " -exe%%FLEXLINK_LDFLAGS%%",
- flexlink ^ " -maindll"
+ flexlink ^ " -maindll%%FLEXLINK_DLL_LDFLAGS%%"
with Not_found ->
"%%MKDLL%%", "%%MKEXE%%", "%%MKMAINDLL%%"
else