[m-rev.] diff: workaround a C stack overflow on MinGW64

Julien Fischer jfischer at opturion.com
Mon Mar 25 18:22:32 AEDT 2013


Workaround a C stack overflow on MinGW64.

The hlc.gc version of the Mercury compiler exhausts the C stack while compiling
the standard library.  This is because the default size of the C stack on
Windows is ridiculously low.


compiler/Mmakefile:
    On the x86_64-w64-mingw32 architecture, bump the default size
    of the C stack up to something more reasonable.

    XXX in the long term, i.e. when we support 64-bit MSVC, we
    should add a --stack option to the ml script and use that.
    (The above is specific to GCC.)

Julien.

diff --git a/compiler/Mmakefile b/compiler/Mmakefile
index d38fbf4..045d8f5 100644
--- a/compiler/Mmakefile
+++ b/compiler/Mmakefile
@@ -53,7 +53,7 @@ ALL_MLLIBS    = $(MLLIBS) $(EXTRA_MLLIBS)
 MLFLAGS      += --shared
 C2INITARGS   += $(MDBCOMP_DIR)/$(MDBCOMP_LIB_NAME).init

-#
+
 # Work-around for a fixed limit: on alpha-dec-osf3.2, if we compile with
 # `-O5', then when linking mercury_compile we get an error message of the form
 #
@@ -68,7 +68,7 @@ MLFLAGS += --static
 MCFLAGS += --linkage static
 endif

-# -Xmx256m doesn't always seem to be enough memory to build the complier.
+# -Xmx256m doesn't always seem to be enough memory to build the compiler.
 # This bumps up the memory when building the compiler if the javac executable
 # accepts the -J-Xmx flag, without bumping up the memory requirements in
 # general.
@@ -76,6 +76,18 @@ ifneq ("$(findstring -J\"-Xmx,$(JAVACFLAGS))","")
 JAVACFLAGS   += -J\"-Xmx2048m\"
 endif

+# The default C stack size of 1Mb on Windows is not enough to compile the
+# standard library in the hlc.gc grade using a Mercury compiler built in
+# the hlc.gc grade with MinGW64.
+# XXX we must match against the full architecture string here since we only
+# want to pass --stack to the linker for MinGW64 GCC.
+# When we support the 64-bit version of the Microsoft toolchain, we will
+# need to do something different here.
+#
+ifeq ($(FULLARCH),x86_64-w64-mingw32)
+LDFLAGS += -Wl,--stack=8388608
+endif
+
 #-----------------------------------------------------------------------------#

 # targets



More information about the reviews mailing list