[m-rev.] for review: more fixes for building on Windows

Julien Fischer jfischer at opturion.com
Thu Jan 23 14:51:47 AEDT 2020


More fixes for building on Windows.

The configuration types returned by autoconf for MinGW have a long and
complicated history. For the current version of config.sub we use they will
match one of:

     *-pc-msys      (i.e. executables linked against the MSYS DLLs)
     *-pc-mingw32   (i.e. 32-bit native executables)
     *-pc-mingw64   (i.e. 64-bit native executables)

We do not support the first possibility, but do support the other two.

Older versions of config.sub reported MinGW64 as *-w64-mingw{32,64} and pieces
of the existing configure script still assume that. This diff changes the
configure script to match what is currently returned by config.sub.

Fix a problem when compiling using MSVC on the -mingw64 architecture.
(Autoconf doesn't recognise MSVC as a "thing" so we need to handle it
specially, regardless of what the build environment is.)

configure.ac:
     Adjust the error message we generate when attempting to build on
     the *-pc-msys architecture.

     Eliminate references to the -w64- component in configuration types;
     it should now be -pc-.

     Set the thread options correctly for MSVC on the *-mingw64 platforms.
     (Note that this is still the 32-bit version of MSVC; we do not yet support
     the 64-bit version.)

README.MinGW:
     Delete the stuff about setting the host to x86_64-w64-mingw32; that is
     no longer required.

     Add a warning about the -pc-msys configuration not being supported.

     Update the list of MinGW configuration names.

compiler/Mmakefile:
     Increase the stack size for all MinGW configurations.
     (XXX I am not sure this is necessary on all of them any longer, but it
     can't hurt.)

Julien.

diff --git a/README.MinGW b/README.MinGW
index 57df999..b0d54d9 100644
--- a/README.MinGW
+++ b/README.MinGW
@@ -1,6 +1,6 @@
  This file documents the port of Mercury to Windows using either the MinGW
-or MinGW-w64 ports of GCC, i.e. the i686-pc-mingw32, i686-w64-mingw32 or
-x86_64-w64-mingw32 configurations.
+or MinGW-w64 ports of GCC, i.e. the i686-pc-mingw32 or x86_64-pc-mingw{32,64}
+configurations.

  NOTE: There are currently problems with 64-bit executables in the 'asm_fast*'
  grade.  The 'none*' and 'reg*' grades do appear to work correctly in our
@@ -98,15 +98,12 @@ To build the source distribution under MSYS follow these steps:
      path with a drive letter (except use `/' instead of `\').
      Do not use a path like `/mercury', because that
      will be interpreted differently by the MSYS shell than by the generated
-    executables, resulting in a broken installation. 
+    executables, resulting in a broken installation.

-    If you are using the MSYS or MSYS2 shell with MinGW-w64 then you must also
-    invoke configure with the following option:
-
-       --host=x86_64-w64-mingw32
-
-    This will cause mmake to use the MinGW-w64 tool chain.  Ensure that the
-    MinGW-w64 tools are in your PATH before running configure.
+    Note that it is important that the configuration reported by autoconf
+    be one of the '*-pc-mingw32' or '*-pc-mingw64' configurations. Using the
+    '*-pc-msys' configuration will *not* work. You can use the config.guess
+    script to check the configuration that autoconf will detect.

  5.  run: `make' and then `make install'.

diff --git a/compiler/Mmakefile b/compiler/Mmakefile
index fda76ef..0297b05 100644
--- a/compiler/Mmakefile
+++ b/compiler/Mmakefile
@@ -72,7 +72,7 @@ endif
  # When we support the 64-bit version of the Microsoft toolchain, we will
  # need to do something different here.
  #
-ifneq ("$(findstring x86_64-w64-mingw32,$(FULLARCH))","")
+ifneq ("$(findstring mingw,$(FULLARCH))","")
  LDFLAGS += -Wl,--stack=8388608
  endif

diff --git a/configure.ac b/configure.ac
index 8a68912..3f061e4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -260,11 +260,11 @@ fi
  # Ensure that the user does not try to build MSYS executables; we do not
  # (currently) support that.

-case "$host" in x86_64-pc-msys)
+case "$host" in *-pc-msys)
     AC_MSG_ERROR(
  [
-***** The x86_64-pc-msys architecture is not supported.
-***** You probably meant to use one of: x86_64-pc-mingw32, x86_64-pc_mingw64.])
+***** The $host architecture is not supported.
+***** You probably meant to use one of: {i686,x86_64}-pc-mingw32, x86_64-pc-mingw64.])
     exit 1
     ;;
  esac
@@ -3246,7 +3246,7 @@ case "$host" in
          # avoid_sbrk?
          ;;

-    i*86-pc-mingw*)
+    *-pc-mingw32*)
          THREAD_LIBS=""
          case "$mercury_cv_cc_type" in
              msvc)
@@ -3278,12 +3278,22 @@ case "$host" in
          esac
          ;;

-    *-w64-mingw*)
-        CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
-        BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS $WIN32_GC_THREADLIB"
-        THREAD_LIBS="-lpthread"
-        ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
-        ENABLE_BOEHM_PARALLEL_MARK="-DPARALLEL_MARK"
+    *-pc-mingw64*)
+        THREAD_LIBS=""
+        case "$mercury_cv_cc_type" in
+            msvc)
+                CFLAGS_FOR_THREADS="-DGC_THREADS -MD"
+                LDFLAGS_FOR_THREADS="-MD"
+                LD_LIBFLAGS_FOR_THREADS="-MD"
+                ;;
+            *)
+                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
+                BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS $WIN32_GC_THREADLIB"
+                THREAD_LIBS="-lpthread"
+                ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
+                ENABLE_BOEHM_PARALLEL_MARK="-DPARALLEL_MARK"
+            ;;
+        esac
          ;;

      *apple*darwin*)


More information about the reviews mailing list